Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
19da18a
The updated adhesion with the development branch
Mar 6, 2025
949045a
Merge branch 'development' into adhesion
Mar 7, 2025
fcab9a6
Merging development into adhesion
Mar 27, 2025
0bbc22b
Merging development into adhesion modifying the style error
Mar 27, 2025
4021170
Merging development into adhesion modifying all errors
Mar 27, 2025
d6718e7
Modifying clang and documentation and adding regression tests
Apr 1, 2025
237c76d
Modifying in clang format and documentation and adding regression tes…
Apr 1, 2025
e545217
Modifying in clang format and documentation and adding regression tes…
Apr 1, 2025
ad2abc8
Merge branch 'development' into adhesion
Apr 1, 2025
b09fa44
Documentation and adding regression tests and clang format
Apr 3, 2025
2af1525
Merge branch 'adhesion' of github.com:solidsgroup/alamo into adhesion
Apr 3, 2025
be5570f
Documentation of the adhesion and adding the regression tests and cla…
Apr 3, 2025
58ace0e
Documentation of Adhesion model and adding regression tests and clang…
Apr 3, 2025
9c944f4
Documentation of Adhesion model and adding regression tests in clang …
Apr 3, 2025
7975a92
Merge branch 'development' into adhesion
Apr 14, 2025
bd171a6
Adhesion model with the added test
Apr 14, 2025
841ef64
Adhesion model with added test
Apr 14, 2025
053f43f
Final tweaks
bsrunnels Apr 14, 2025
ef83cbf
removing extra code and bringing into compliance
bsrunnels Apr 14, 2025
0a436fe
integrating with nh
bsrunnels Apr 14, 2025
5c7b42a
fixed tests (issue was failing to apply symmetry in for loops for mat…
bsrunnels Apr 14, 2025
f1f4920
working test case
bsrunnels Apr 14, 2025
3e00642
working example
bsrunnels Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions src/Model/Solid/Finite/Adhesion.H

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting in this file is noncompliant with the style outlined in .clang-format.

Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation at the top of this file to outline the method. See Model::Solid::Affine::J2 for an example of suitable documentation.

#ifndef MODEL_SOLID_FINITE_ADHESION_H_
#define MODEL_SOLID_FINITE_ADHESION_H_

#include "IO/ParmParse.H"
#include "Model/Solid/Solid.H"
#include "Set/Set.H"
#include </usr/include/eigen3/Eigen/Dense> // For Eigen::Matrix3d
#include <array> // For std::array to represent fourth-order tensors
#include <cmath> // For std::pow and std::exp

namespace Set {

// Outer product for two 3x3 matrices producing a 3x3x3x3 tensor
inline std::array<std::array<std::array<std::array<double, 3>, 3>, 3>, 3>
Outer(const Eigen::Matrix3d &A, const Eigen::Matrix3d &B) {
std::array<std::array<std::array<std::array<double, 3>, 3>, 3>, 3> result = {};
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
result[i][j][k][l] = A(i, j) * B(k, l);
return result;
}

// Derivative of inverse transpose: d(F^-T) / dF
inline std::array<std::array<std::array<std::array<double, 3>, 3>, 3>, 3>
Derivative(const Eigen::Matrix3d &FinvT) {
std::array<std::array<std::array<std::array<double, 3>, 3>, 3>, 3> result = {};
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
result[i][j][k][l] = -FinvT(i, j) * FinvT(j, i);
return result;
}

} // namespace Set

namespace Model {
namespace Solid {
namespace Finite {

class Adhesion : public Solid<Set::Sym::Major> {
public:
Adhesion() {}
Adhesion(Solid<Set::Sym::Major> base) : Solid<Set::Sym::Major>(base) {}
virtual ~Adhesion() {}

// Material parameters (declared in order)
Set::Scalar d = NAN; ///< Adhesion strength
Set::Scalar mu = NAN; ///< Shear modulus
Set::Scalar kappa = NAN; ///< Bulk modulus
Set::Scalar zeta = NAN; ///< Adhesion decay parameter
Set::Scalar n = NAN; ///< Decay exponent

static Adhesion Zero() {
Adhesion adhesion;
adhesion.d = 0;
adhesion.mu = 0;
adhesion.kappa = 0;
adhesion.zeta = 0;
adhesion.n = 0;
return adhesion;
}

static Adhesion Random() {
Adhesion adhesion;
adhesion.d = Util::Random();
adhesion.mu = Util::Random();
adhesion.kappa = Util::Random();
adhesion.zeta = Util::Random();
adhesion.n = Util::Random();
return adhesion;
}

// Updated Parse function:
// If "E" and "nu" (and optionally "F0") are provided, use these to compute mu and kappa.
// Otherwise, query for "mu" and "kappa" directly.
static void Parse(Adhesion &value, IO::ParmParse &pp) {
if (pp.contains("E") && pp.contains("nu")) {
Set::Scalar E, nu;
pp_query("E", E); // Elastic modulus
pp_query("nu", nu); // Poisson's ratio
// Map E and nu to shear and bulk moduli (using a convention similar to NeoHookean citeturn0file2)
value.mu = E / (2.0 * (1.0 + nu));
value.kappa = E / (3.0 * (1.0 - 2.0 * nu));
// Consume F0 if provided, even though Adhesion does not use it.
if (pp.contains("F0")) {
Set::Matrix dummy;
pp_queryarr("F0", dummy); // F0
}
} else {
pp_query("mu", value.mu); // Shear modulus
pp_query("kappa", value.kappa); // Bulk modulus
}
// Query the remaining Adhesion-specific parameters.
pp_query("d", value.d); // Adhesion strength
pp_query("zeta", value.zeta); // Adhesion decay parameter
pp_query("n", value.n); // Decay exponent
}

Set::Scalar W(const Set::Matrix &a_F) const override {
#if AMREX_SPACEDIM == 2
Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
F(0,0) = a_F(0,0);
F(0,1) = a_F(0,1);
F(1,0) = a_F(1,0);
F(1,1) = a_F(1,1);
#elif AMREX_SPACEDIM == 3
Eigen::Matrix3d F = a_F;
#endif
Set::Scalar J = F.determinant();
Set::Scalar J23 = std::pow(fabs(J), 2.0/3.0);
Set::Scalar w = 0.0;
// Shear and bulk contributions (scaled by adhesion factor d)
w += d * (0.5 * mu * (((F.transpose() * F).trace()) - 3) / J23 +
0.5 * kappa * (J - 1.0) * (J - 1.0));
// Adhesion decay term
w += zeta / std::pow(J, n);
return w;
}

Set::Matrix DW(const Set::Matrix &a_F) const override {
#if AMREX_SPACEDIM == 2
Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
F(0,0) = a_F(0,0);
F(0,1) = a_F(0,1);
F(1,0) = a_F(1,0);
F(1,1) = a_F(1,1);
#elif AMREX_SPACEDIM == 3
Eigen::Matrix3d F = a_F;
#endif
Set::Scalar J = F.determinant();
Set::Scalar J23 = std::pow(fabs(J), 2.0/3.0);
Eigen::Matrix3d FinvT = F.inverse().transpose();

Eigen::Matrix3d dw = d * mu * (F / J23 -
(1.0/3.0) * (((F.transpose() * F).trace()) - 3) * FinvT / J23)
+ d * kappa * (J - 1.0) * J * FinvT
- zeta * n * std::pow(J, -n) * FinvT;
#if AMREX_SPACEDIM == 2
Set::Matrix r_dw;
r_dw(0,0) = dw(0,0);
r_dw(0,1) = dw(0,1);
r_dw(1,0) = dw(1,0);
r_dw(1,1) = dw(1,1);
return r_dw;
#elif AMREX_SPACEDIM == 3
return dw;
#endif
}

Set::Matrix4<AMREX_SPACEDIM, Set::Sym::Major> DDW(const Set::Matrix &a_F) const override {
#if AMREX_SPACEDIM == 2
Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
F(0,0) = a_F(0,0);
F(0,1) = a_F(0,1);
F(1,0) = a_F(1,0);
F(1,1) = a_F(1,1);
#elif AMREX_SPACEDIM == 3
Eigen::Matrix3d F = a_F;
#endif
Set::Scalar J = F.determinant();
Set::Scalar J23 = std::pow(fabs(J), 2.0/3.0);
Eigen::Matrix3d FinvT = F.inverse().transpose();
Set::Scalar trace_FTF = (F.transpose() * F).trace();

auto Deriv = ::Set::Derivative(FinvT);

Set::Matrix4<3, Set::Sym::Major> ddw;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
for (int l = 0; l < 3; ++l) {
ddw(i, j, k, l) = 0.0;
Set::Scalar t1 = 0.0, t2 = 0.0, t3 = 0.0;
// Shear-related term (mu)
if (i == k && j == l)
t1 += 1.0;
t1 -= (2.0/3.0)*F(i,j)*FinvT(k,l);
t1 -= (2.0/3.0)*FinvT(i,j)*F(k,l);
t1 += (2.0/9.0)*(trace_FTF - 3)*FinvT(i,j)*FinvT(k,l);
t1 += (1.0/3.0)*(trace_FTF - 3)*FinvT(i,l)*FinvT(k,j);
// Bulk-related term (kappa)
t2 += (2.0*J*J - J)*FinvT(i,j)*FinvT(k,l)
+ (J - J*J)*FinvT(i,l)*FinvT(k,j);
// Adhesion-related term (zeta)
t3 += (n*n)*std::pow(J, -n)*FinvT(i,j)*FinvT(k,l)
+ n*std::pow(J, -n)*FinvT(i,l)*FinvT(k,j);
ddw(i, j, k, l) = d * mu * t1 / J23 + d * kappa * t2 + zeta * t3;
}
}
}
}
#if AMREX_SPACEDIM == 2
Set::Matrix4<AMREX_SPACEDIM, Set::Sym::Major> r_ddw;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++)
for (int l = 0; l < 2; l++)
r_ddw(i, j, k, l) = ddw(i, j, k, l);
return r_ddw;
#elif AMREX_SPACEDIM == 3
return ddw;
#endif
}

virtual void Print(std::ostream &out) const override {
out << "d = " << d << ", mu = " << mu << ", kappa = " << kappa
<< ", zeta = " << zeta << ", n = " << n;
}

#define OP_CLASS Adhesion
#define OP_VARS X(d) X(mu) X(kappa) X(zeta) X(n)
#include "Model/Solid/InClassOperators.H"
};

#include "Model/Solid/ExtClassOperators.H"

} // namespace Finite
} // namespace Solid
} // namespace Model

#endif
3 changes: 3 additions & 0 deletions src/mechanics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Model/Solid/Affine/Isotropic.H"
#include "Model/Solid/Linear/Cubic.H"
#include "Model/Solid/Affine/Cubic.H"
#include "Model/Solid/Finite/Adhesion.H"
#include "Model/Solid/Finite/NeoHookean.H"
#include "Model/Solid/Finite/NeoHookeanPredeformed.H"
#include "Model/Solid/Finite/PseudoLinear/Cubic.H"
Expand Down Expand Up @@ -56,6 +57,8 @@ int main (int argc, char* argv[])
pp.select_only<Integrator::Mechanics<Model::Solid::Finite::NeoHookean>>(integrator);
else if (model == "finite.neohookeanpre")
pp.select_only<Integrator::Mechanics<Model::Solid::Finite::NeoHookeanPredeformed>>(integrator);
else if (model == "finite.adhesion")
pp.select_only<Integrator::Mechanics<Model::Solid::Finite::Adhesion>>(integrator);
else if (model == "finite.pseudolinear.cubic")
pp.select_only<Integrator::Mechanics<Model::Solid::Finite::PseudoLinear::Cubic>>(integrator);
else if (model == "finite.pseudoaffine.cubic")
Expand Down
4 changes: 3 additions & 1 deletion src/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Model/Solid/Linear/Laplacian.H"
#include "Model/Solid/Affine/Isotropic.H"
#include "Model/Solid/Affine/Cubic.H"
#include "Model/Solid/Finite/Adhesion.H"
#include "Model/Solid/Finite/NeoHookean.H"
#include "Model/Solid/Finite/NeoHookeanPredeformed.H"
#include "Model/Solid/Finite/PseudoLinear/Cubic.H"
Expand Down Expand Up @@ -57,7 +58,8 @@ int main (int argc, char* argv[])
MODELTEST(Model::Solid::Finite::PseudoLinear::Cubic);
MODELTEST(Model::Solid::Finite::NeoHookeanPredeformed);
MODELTEST(Model::Solid::Finite::PseudoAffine::Cubic);

MODELTEST(Model::Solid::Finite::Adhesion);


Util::Test::Message("Set::Matrix4");
{
Expand Down