Alamo
Isotropic.H
Go to the documentation of this file.
1//
2// This model implements an isotropic linear elastic material.
3// See `this link <https://en.wikipedia.org/wiki/Linear_elasticity#(An)isotropic_(in)homogeneous_media>`_
4// for more information about the theory.
5//
6// Free energy for a linear material is defined as
7//
8// .. math::
9//
10// W(\nabla\mathbf{u}) =
11// \frac{1}{2}\nabla\mathbf{u}\cdot\mathbb{C}\,\nabla\mathbf{u}
12//
13// For an isotropic material, stress and strain are related through
14//
15// .. math::
16//
17// \mathbb{C}_{ijkl} = \lambda \delta_{ij}\varepsilon_{kk} + 2\mu\varepsilon_{ij}
18//
19// where :math:`\lambda` and :math:`\mu` are the Lame constant and shear modulus, respectively.
20// Users can specify these either through (:code:`lame` and :code:`shear`)
21// OR (:code:`lambda` and :code:`mu`) OR (:code:`E` and :code:`nu`).
22//
23// Class methods:
24//
25// #. :code:`Isotropic()`:
26// Basic constructor. Does nothing, and leaves all values initiated as NAN.
27// #. :code:`Isotropic(Solid<Set::Sym::Isotropic> base)`
28// Basic constructor. Does nothing gut allows for inheritance.
29// #. :code:`Isotropic(Set::Scalar a_mu, Set::Scalar a_lambda)`
30// BAD old-fashioned constructor. Do not use!
31// #. :code:`~Isotropic()`
32// Simple destructor. Don't need to change it.
33// #. :code:`void Define(Set::Scalar a_mu, Set::Scalar a_lambda)`
34// BAD old-fashioned way of doing things. Use :code:`Parse` instead.
35// #. :code:`Set::Scalar W(const Set::Matrix & gradu) const override`
36// Returns elastic free energy density
37// #. :code:`Set::Matrix DW(const Set::Matrix & gradu) const override`
38// Returns first derivative of free energy, the stress tensor
39// #. :code:`Set::Matrix4<...> DDW(const Set::Matrix & ) const override`
40// Returns second derivative of free energy, the modulus tensor
41// #. :code:`virtual void Print(std::ostream &out) const override`
42// Prints the modulus tensor object to output stream (usually the terminal)
43// #. :code:`static Isotropic Random()`
44// Static method that generates a random yet acceptable model.
45// #. :code:`static Isotropic Zero()`
46// Static method that generates a "zero" element (so that there is no effect under addition)
47// #. :code:`static void Parse(Isotropic & value, IO::ParmParse & pp)`
48// Parser where all the IO occurs
49//
50//
51
52#ifndef MODEL_SOLID_LINEAR_ISOTROPIC_H_
53#define MODEL_SOLID_LINEAR_ISOTROPIC_H_
54
55#include "Model/Solid/Solid.H"
56#include "IO/ParmParse.H"
57
58namespace Model
59{
60namespace Solid
61{
62namespace Linear
63{
64class Isotropic : public Solid<Set::Sym::Isotropic>
65{
66public:
67
71 {
72 Define(a_mu,a_lambda);
73 };
74 virtual ~Isotropic() {};
75
76 void Define(Set::Scalar a_mu, Set::Scalar a_lambda)
77 {
79 }
80
81 Set::Scalar W(const Set::Matrix & gradu) const override
82 {
83 return ( 0.5 * gradu.transpose() * (ddw*gradu) ).trace();
84 }
85 Set::Matrix DW(const Set::Matrix & gradu) const override
86 {
87 return ddw*gradu;
88 }
90 {
91 return ddw;
92 }
93 virtual void Print(std::ostream &out) const override
94 {
95 out << ddw;
96 }
97
98public:
101
102public:
104 {
105 Isotropic ret;
107 return ret;
108 }
110 {
111 Isotropic ret;
112 ret.Define(0.,0.);
113 return ret;
114 }
115 static void Parse(Isotropic & value, IO::ParmParse & pp)
116 {
117 Set::Scalar mu = NAN, lambda = NAN;
118 bool planestress = false;
119 std::pair<std::string, Set::Scalar> moduli[2];
120
121 pp.forbid("lame","Use 'lambda' instead for lame constant");
122 pp.forbid("shear","Use 'mu' instead for shear modulus");
123 pp.forbid("bulk","Use 'kappa' instead for bulk modulus");
124
125 // Specify exactly two of: lame constant \‍(\lambda\‍),
126 // shear modulus \‍(\mu\‍), Young's modulus \‍(E\‍), Poisson's ratio \‍(\nu\‍),
127 // bulk modulus \‍(\kappa\‍).
128 // \‍(\mu\‍) and \‍(\lambda\‍) are how the final values are stored.
129 pp.query_exactly<2>({"lambda","mu","E","nu","kappa"}, moduli);
130
131 if (moduli[0].first == "lambda" && moduli[1].first == "mu")
132 {
133 lambda = moduli[0].second;
134 mu = moduli[1].second;
135 }
136 else if (moduli[0].first == "lambda" && moduli[1].first == "E")
137 {
138 lambda = moduli[0].second;
139 Set::Scalar E = moduli[1].second;
140 mu = (E - 3.0 * lambda + sqrt(E * E + 9.0 * lambda * lambda + 2.0 * E * lambda)) / 4.0;
141 }
142 else if (moduli[0].first == "lambda" && moduli[1].first == "nu")
143 {
144 lambda = moduli[0].second;
145 Set::Scalar nu = moduli[1].second;
146 mu = lambda * (1.0 - 2.0 * nu) / 2.0 / nu;
147 }
148 else if (moduli[0].first == "mu" && moduli[1].first == "E")
149 {
150 mu = moduli[0].second;
151 Set::Scalar E = moduli[1].second;
152 lambda = mu * (E - 2.0 * mu) / (3.0 * mu - E);
153 }
154 else if (moduli[0].first == "mu" && moduli[1].first == "nu")
155 {
156 mu = moduli[0].second;
157 Set::Scalar nu = moduli[1].second;
158 lambda = 2.0 * mu * nu / (1.0 - 2.0 * nu);
159 }
160 else if (moduli[0].first == "mu" && moduli[1].first == "K")
161 {
162 mu = moduli[0].second;
163 Set::Scalar K = moduli[1].second;
164 lambda = K - (2.0 * mu / 3.0);
165 }
166 else if (moduli[0].first == "E" && moduli[1].first == "nu")
167 {
168 Set::Scalar E = moduli[0].second, nu = moduli[1].second;
169 lambda = E * nu / (1.0 + nu) / (1.0 - 2.0 * nu);
170 mu = E / 2.0 / (1.0 + nu);
171 }
172 else
173 {
174 Util::Exception(INFO,"Haven't implemented ",moduli[0].first," and ",moduli[1].first," (sorry!)");
175 }
176
177 // Whether or not to use the
178 // `plane stress <https://en.wikipedia.org/wiki/Plane_stress>`_
179 // approximation.
180 pp.query_default("planestress",planestress, false);
181
182 if (AMREX_SPACEDIM==2 && planestress)
183 value.Define(mu,lambda*(1.0 - lambda/(2.*mu + lambda)));
184 else
185 value.Define(mu,lambda);
186 }
187
188 #define OP_CLASS Isotropic
189 #define OP_VARS X(ddw)
191};
193
194
195
196}
197}
198}
199
200#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
void query_exactly(std::vector< std::string > names, std::pair< std::string, Set::Scalar > values[N])
Definition ParmParse.H:778
int query_default(std::string name, T &value, T defaultvalue, std::string="", std::string="", int=-1)
Definition ParmParse.H:185
Set::Matrix4< AMREX_SPACEDIM, Set::Sym::Isotropic > DDW(const Set::Matrix &) const override
Definition Isotropic.H:89
Isotropic(Solid< Set::Sym::Isotropic > base)
Definition Isotropic.H:69
Set::Matrix DW(const Set::Matrix &gradu) const override
Definition Isotropic.H:85
Isotropic(Set::Scalar a_mu, Set::Scalar a_lambda)
Definition Isotropic.H:70
static const KinematicVariable kinvar
Definition Isotropic.H:100
Set::Scalar W(const Set::Matrix &gradu) const override
Definition Isotropic.H:81
static Isotropic Random()
Definition Isotropic.H:103
virtual void Print(std::ostream &out) const override
Definition Isotropic.H:93
static void Parse(Isotropic &value, IO::ParmParse &pp)
Definition Isotropic.H:115
void Define(Set::Scalar a_mu, Set::Scalar a_lambda)
Definition Isotropic.H:76
Set::Matrix4< AMREX_SPACEDIM, Set::Sym::Isotropic > ddw
Definition Isotropic.H:99
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