Alamo
NeoHookean.H
Go to the documentation of this file.
1#ifndef MODEL_SOLID_FINITE_NEOHOOKEAN_H_
2#define MODEL_SOLID_FINITE_NEOHOOKEAN_H_
3
4#include "IO/ParmParse.H"
5#include "Model/Solid/Solid.H"
6
7namespace Model
8{
9namespace Solid
10{
11namespace Finite
12{
13class NeoHookean : public Solid<Set::Sym::Major>
14{
15public:
17 NeoHookean(Solid<Set::Sym::Major> base) : Solid<Set::Sym::Major>(base) {};
18 virtual ~NeoHookean() {};
19
20 Set::Scalar W(const Set::Matrix& a_F) const override
21 {
22#if AMREX_SPACEDIM==2
23 Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
24 F(0, 0) = a_F(0, 0);
25 F(0, 1) = a_F(0, 1);
26 F(1, 0) = a_F(1, 0);
27 F(1, 1) = a_F(1, 1);
28#elif AMREX_SPACEDIM==3
29 Eigen::Matrix3d F = a_F;
30#endif
31
32 Set::Scalar J = F.determinant();
33 Set::Scalar J23 = std::pow(fabs(J), 2. / 3.);
34 Set::Scalar w = 0.0;
35 w += 0.5 * mu * ((F * F.transpose()).trace() / J23 - 3.);
36 w += 0.5 * kappa * (J - 1.0) * (J - 1.0);
37 return w;
38 }
39 Set::Matrix DW(const Set::Matrix& a_F) const override
40 {
41#if AMREX_SPACEDIM==2
42 Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
43 F(0, 0) = a_F(0, 0);
44 F(0, 1) = a_F(0, 1);
45 F(1, 0) = a_F(1, 0);
46 F(1, 1) = a_F(1, 1);
47#elif AMREX_SPACEDIM==3
48 Eigen::Matrix3d F = a_F;
49#endif
50
51 Set::Scalar J = F.determinant();
52 Set::Scalar J23 = std::pow(fabs(J), 2. / 3.);
53 Eigen::Matrix3d FinvT = F.inverse().transpose();
54
55 Eigen::Matrix3d dw = Eigen::Matrix3d::Zero();
56
57 dw += mu * (F / J23 - (F * F.transpose()).trace() * FinvT / (3. * J23));
58 dw += kappa * (J - 1) * J * FinvT;
59
60#if AMREX_SPACEDIM==2
61 Set::Matrix r_dw;
62 r_dw(0, 0) = dw(0, 0);
63 r_dw(0, 1) = dw(0, 1);
64 r_dw(1, 0) = dw(1, 0);
65 r_dw(1, 1) = dw(1, 1);
66 return r_dw;
67#elif AMREX_SPACEDIM==3
68 return dw;
69#endif
70 }
72 {
73#if AMREX_SPACEDIM==2
74 Eigen::Matrix3d F = Eigen::Matrix3d::Identity();
75 F(0, 0) = a_F(0, 0);
76 F(0, 1) = a_F(0, 1);
77 F(1, 0) = a_F(1, 0);
78 F(1, 1) = a_F(1, 1);
79#elif AMREX_SPACEDIM==3
80 Eigen::Matrix3d F = a_F;
81#endif
82
84 Set::Scalar J = F.determinant();
85 Set::Scalar J23 = std::pow(fabs(J), 2. / 3.);
86 Eigen::Matrix3d FinvT = F.inverse().transpose();
87 for (int i = 0; i < 3; i++)
88 for (int j = 0; j < 3; j++)
89 for (int k = 0; k < 3; k++)
90 for (int l = 0; l < 3; l++)
91 {
92 ddw(i, j, k, l) = 0.0;
93
94 Set::Scalar t1 = 0.0, t2 = 0.0;
95
96 if (i == k && j == l) t1 += 1.0;
97 t1 -= (2. / 3.) * F(i, j) * FinvT(k, l);
98 t1 -= (2. / 3.) * FinvT(i, j) * F(k, l);
99 t1 += (2. / 9.) * (F * F.transpose()).trace() * FinvT(i, j) * FinvT(k, l);
100 t1 += (1. / 3.) * (F * F.transpose()).trace() * FinvT(i, l) * FinvT(k, j);
101
102 t2 += (2. * J - 1.) * FinvT(i, j) * FinvT(k, l);
103 t2 += (1. - J) * FinvT(i, l) * FinvT(k, j);
104
105 ddw(i, j, k, l) = (mu / J23) * t1 + kappa * J * t2;
106 }
107#if AMREX_SPACEDIM==2
109 for (int i = 0; i < 2; i++)
110 for (int j = 0; j < 2; j++)
111 for (int k = 0; k < 2; k++)
112 for (int l = 0; l < 2; l++)
113 r_ddw(i, j, k, l) = ddw(i, j, k, l);
114 return r_ddw;
115#elif AMREX_SPACEDIM==3
116 return ddw;
117#endif
118 }
119 virtual void Print(std::ostream& out) const override
120 {
121 out << "mu = " << mu << " kappa = " << kappa;
122 }
123
124public:
125 Set::Scalar mu = NAN, kappa = NAN;
127
128public:
130 {
131 NeoHookean ret;
132 ret.mu = 0.0;
133 ret.kappa = 0.0;
134 return ret;
135 }
137 {
138 NeoHookean ret;
139 ret.mu = Util::Random();
140 ret.kappa = Util::Random();
141 return ret;
142 }
143 static void Parse(NeoHookean& value, IO::ParmParse& pp)
144 {
145
146 std::pair<std::string, Set::Scalar> moduli[2];
147
148 pp.forbid("lame","Use 'lambda' instead for lame constant");
149 pp.forbid("shear","Use 'mu' instead for shear modulus");
150 pp.forbid("bulk","Use 'K' instead for bulk modulus");
151
152 // Lame constant \‍(\lambda\‍),
153 // shear modulus \‍(\mu\‍), Young's modulus \‍(E\‍), Poisson's ratio \‍(\nu\‍),
154 // bulk modulus \‍(K\‍).
155 // You can currently specify (mu and kappa), (lambda and mu), or (E and nu).
156 pp.query_exactly<2>({"lambda","mu","E","nu","kappa"}, moduli);
157
158
159 if (moduli[0].first == "mu" && moduli[1].first == "kappa")
160 {
161 value.mu = moduli[0].second;
162 value.kappa = moduli[1].second;
163 }
164 else if (moduli[0].first == "lambda" && moduli[1].first == "mu")
165 {
166 Set::Scalar lambda = moduli[0].second;
167 value.mu = moduli[1].second;
168 value.kappa = lambda + (2.0 * value.mu) / 3.0;
169 }
170 else if (pp.contains("E") && pp.contains("nu")) {
171 Set::Scalar E = moduli[0].second;
172 Set::Scalar nu = moduli[1].second;
173 value.kappa = E / (3.0 - 6.0 * nu);
174 value.mu = E / (2.0 + 2.0 * nu);
175 }
176 else
177 {
178 Util::Exception(INFO,"Haven't implemented",moduli[0].first," and ",moduli[1].first," yet (sorry!)");
179 }
180 }
181
182#define OP_CLASS NeoHookean
183#define OP_VARS X(kappa) X(mu)
185};
187
188}
189}
190}
191
192#endif
#define INFO
Definition Util.H:20
void forbid(std::string name, std::string explanation, std::string file="", std::string func="", int line=-1)
Definition ParmParse.H:140
bool contains(std::string name)
Definition ParmParse.H:154
void query_exactly(std::vector< std::string > names, std::pair< std::string, Set::Scalar > values[N])
Definition ParmParse.H:778
virtual void Print(std::ostream &out) const override
Definition NeoHookean.H:119
NeoHookean(Solid< Set::Sym::Major > base)
Definition NeoHookean.H:17
static void Parse(NeoHookean &value, IO::ParmParse &pp)
Definition NeoHookean.H:143
static constexpr KinematicVariable kinvar
Definition NeoHookean.H:126
Set::Matrix4< AMREX_SPACEDIM, Set::Sym::Major > DDW(const Set::Matrix &a_F) const override
Definition NeoHookean.H:71
Set::Matrix DW(const Set::Matrix &a_F) const override
Definition NeoHookean.H:39
Set::Scalar W(const Set::Matrix &a_F) const override
Definition NeoHookean.H:20
KinematicVariable
Definition Solid.H:26
A collection of data types and symmetry-reduced data structures.
Definition Base.H:18
amrex::Real Scalar
Definition Base.H:19
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:20
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, AMREX_SPACEDIM > Matrix
Definition Base.H:23
Set::Scalar Random()
Definition Set.cpp:9
void Exception(std::string file, std::string func, int line, Args const &... args)
Definition Util.H:205