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