OGS 6.2.0-97-g4a610c866
Ehlers.h
Go to the documentation of this file.
1 
19 #pragma once
20 
21 #ifndef NDEBUG
22 #include <ostream>
23 #endif
24 
25 #include "BaseLib/Error.h"
26 #include "MathLib/KelvinVector.h"
27 #include "NumLib/NewtonRaphson.h"
28 #include "ParameterLib/Parameter.h"
29 
30 #include "MechanicsBase.h"
31 
32 namespace MaterialLib
33 {
34 namespace Solids
35 {
36 namespace Ehlers
37 {
38 enum class TangentType
39 {
40  Elastic,
42  Plastic
43 };
44 inline TangentType makeTangentType(std::string const& s)
45 {
46  if (s == "Elastic")
47  {
48  return TangentType::Elastic;
49  }
50  if (s == "PlasticDamageSecant")
51  {
53  }
54  if (s == "Plastic")
55  {
56  return TangentType::Plastic;
57  }
58  OGS_FATAL("Not valid string '%s' to create a tangent type from.",
59  s.c_str());
60 }
61 
66 {
68 
69  MaterialPropertiesParameters(P const& G_, P const& K_, P const& alpha_,
70  P const& beta_, P const& gamma_,
71  P const& delta_, P const& epsilon_,
72  P const& m_, P const& alpha_p_,
73  P const& beta_p_, P const& gamma_p_,
74  P const& delta_p_, P const& epsilon_p_,
75  P const& m_p_, P const& kappa_,
76  P const& hardening_coefficient_)
77  : G(G_),
78  K(K_),
79  alpha(alpha_),
80  beta(beta_),
81  gamma(gamma_),
82  delta(delta_),
83  epsilon(epsilon_),
84  m(m_),
85  alpha_p(alpha_p_),
86  beta_p(beta_p_),
87  gamma_p(gamma_p_),
88  delta_p(delta_p_),
89  epsilon_p(epsilon_p_),
90  m_p(m_p_),
91  kappa(kappa_),
92  hardening_coefficient(hardening_coefficient_)
93  {
94  }
95  // basic material parameters
96  P const& G;
97  P const& K;
98 
99  P const& alpha;
100  P const& beta;
102  P const& gamma;
103  P const& delta;
104  P const& epsilon;
105  P const& m;
106 
107  P const& alpha_p;
108  P const& beta_p;
109  P const& gamma_p;
110  P const& delta_p;
111  P const& epsilon_p;
112  P const& m_p;
113 
114  P const& kappa;
116 };
117 
119 {
121  P const& alpha_d;
122  P const& beta_d;
123  P const& h_d;
124 };
125 
128 struct MaterialProperties final
129 {
132  : G(mp.G(t, x)[0]),
133  K(mp.K(t, x)[0]),
134  alpha(mp.alpha(t, x)[0]),
135  beta(mp.beta(t, x)[0]),
136  gamma(mp.gamma(t, x)[0]),
137  delta(mp.delta(t, x)[0]),
138  epsilon(mp.epsilon(t, x)[0]),
139  m(mp.m(t, x)[0]),
140  alpha_p(mp.alpha_p(t, x)[0]),
141  beta_p(mp.beta_p(t, x)[0]),
142  gamma_p(mp.gamma_p(t, x)[0]),
143  delta_p(mp.delta_p(t, x)[0]),
144  epsilon_p(mp.epsilon_p(t, x)[0]),
145  m_p(mp.m_p(t, x)[0]),
146  kappa(mp.kappa(t, x)[0]),
147  hardening_coefficient(mp.hardening_coefficient(t, x)[0])
148  {
149  }
150  double const G;
151  double const K;
152 
153  double const alpha;
154  double const beta;
155  double const gamma;
156  double const delta;
157  double const epsilon;
158  double const m;
159 
160  double const alpha_p;
161  double const beta_p;
162  double const gamma_p;
163  double const delta_p;
164  double const epsilon_p;
165  double const m_p;
166 
167  double const kappa;
168  double const hardening_coefficient;
169 };
170 
174 {
175  DamageProperties(double const t,
177  DamagePropertiesParameters const& dp)
178  : alpha_d(dp.alpha_d(t, x)[0]),
179  beta_d(dp.beta_d(t, x)[0]),
180  h_d(dp.h_d(t, x)[0])
181  {
182  }
183  double const alpha_d;
184  double const beta_d;
185  double const h_d;
186 };
187 
188 template <typename KelvinVector>
189 struct PlasticStrain final
190 {
191  PlasticStrain() : D(KelvinVector::Zero()) {}
192  PlasticStrain(KelvinVector eps_p_D_, double const eps_p_V_,
193  double const eps_p_eff_)
194  : D(std::move(eps_p_D_)), V(eps_p_V_), eff(eps_p_eff_){};
195 
196  KelvinVector D;
197  double V = 0;
198  double eff = 0;
199 
201 };
202 
203 class Damage final
204 {
205 public:
206  Damage() = default;
207  Damage(double const kappa_d, double const value)
208  : _kappa_d(kappa_d), _value(value)
209  {
210  }
211 
212  double kappa_d() const { return _kappa_d; }
213  double value() const { return _value; }
214 
215 private:
216  double _kappa_d = 0;
217  double _value = 0;
218 };
219 
220 template <int DisplacementDim>
222  : public MechanicsBase<DisplacementDim>::MaterialStateVariables
223 {
224  StateVariables& operator=(StateVariables const&) = default;
227  state) noexcept override
228  {
229  assert(dynamic_cast<StateVariables const*>(&state) != nullptr);
230  return operator=(static_cast<StateVariables const&>(state));
231  }
232 
234  {
235  eps_p = eps_p_prev;
236  damage = damage_prev;
237  }
238 
239  void pushBackState() override
240  {
241  eps_p_prev = eps_p;
242  damage_prev = damage;
243  }
244 
245  using KelvinVector =
247 
250 
251  // Initial values from previous timestep
254 
255 #ifndef NDEBUG
256  friend std::ostream& operator<<(
257  std::ostream& os, StateVariables<DisplacementDim> const& m)
258  {
259  os << "State:\n"
260  << "eps_p_D: " << m.eps_p.D << "\n"
261  << "eps_p_eff: " << m.eps_p.eff << "\n"
262  << "kappa_d: " << m.damage.kappa_d() << "\n"
263  << "damage: " << m.damage.value() << "\n"
264  << "eps_p_D_prev: " << m.eps_p_prev.D << "\n"
265  << "eps_p_eff_prev: " << m.eps_p_prev.eff << "\n"
266  << "kappa_d_prev: " << m.damage_prev.kappa_d() << "\n"
267  << "damage_prev: " << m.damage_prev.value() << "\n"
268  << "lambda: " << m.lambda << "\n";
269  return os;
270  }
271 #endif // NDEBUG
272 
274 };
275 
276 template <int DisplacementDim>
277 class SolidEhlers final : public MechanicsBase<DisplacementDim>
278 {
279 public:
280  static int const KelvinVectorSize =
282  static int const JacobianResidualSize =
283  2 * KelvinVectorSize + 3; // 2 is the number of components in the
284  // jacobian/residual, not the space
285  // dimension. And 3 is for additional
286  // variables.
287  using ResidualVectorType = Eigen::Matrix<double, JacobianResidualSize, 1>;
288  using JacobianMatrix = Eigen::Matrix<double, JacobianResidualSize,
289  JacobianResidualSize, Eigen::RowMajor>;
290 
291 public:
292  std::unique_ptr<
295  {
296  return std::make_unique<StateVariables<DisplacementDim>>();
297  }
298 
299 public:
300  using KelvinVector =
302  using KelvinMatrix =
304 
305 public:
306  SolidEhlers(
307  NumLib::NewtonRaphsonSolverParameters nonlinear_solver_parameters,
308  MaterialPropertiesParameters material_properties,
309  std::unique_ptr<DamagePropertiesParameters>&& damage_properties,
310  TangentType tangent_type);
311 
312  double computeFreeEnergyDensity(
313  double const /*t*/,
314  ParameterLib::SpatialPosition const& /*x*/,
315  double const /*dt*/,
316  KelvinVector const& eps,
317  KelvinVector const& sigma,
319  material_state_variables) const override;
320 
321  boost::optional<std::tuple<KelvinVector,
322  std::unique_ptr<typename MechanicsBase<
323  DisplacementDim>::MaterialStateVariables>,
324  KelvinMatrix>>
325  integrateStress(
326  double const t, ParameterLib::SpatialPosition const& x, double const dt,
327  KelvinVector const& eps_prev, KelvinVector const& eps,
328  KelvinVector const& sigma_prev,
330  material_state_variables,
331  double const T) const override;
332 
333  std::vector<typename MechanicsBase<DisplacementDim>::InternalVariable>
334  getInternalVariables() const override;
335 
337  double const t, ParameterLib::SpatialPosition const& x) const
338  {
339  return MaterialProperties(t, x, _mp);
340  }
341 
343  double const t, ParameterLib::SpatialPosition const& x) const
344  {
345  return DamageProperties(t, x, *_damage_properties);
346  }
347 
348 private:
350 
352  std::unique_ptr<DamagePropertiesParameters> _damage_properties;
354 };
355 
356 extern template class SolidEhlers<2>;
357 extern template class SolidEhlers<3>;
358 } // namespace Ehlers
359 } // namespace Solids
360 } // namespace MaterialLib
KelvinVector D
deviatoric plastic strain
Definition: Ehlers.h:194
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
Damage damage
damage part of the state.
Definition: Ehlers.h:249
NumLib::NewtonRaphsonSolverParameters const _nonlinear_solver_parameters
Definition: Ehlers.h:349
Eigen::Matrix< double, JacobianResidualSize, 1 > ResidualVectorType
Definition: Ehlers.h:287
Eigen::Matrix< double, KelvinVectorDimensions< DisplacementDim >::value, KelvinVectorDimensions< DisplacementDim >::value, Eigen::RowMajor > KelvinMatrixType
Definition: KelvinVector.h:59
MathLib::KelvinVector::KelvinVectorType< DisplacementDim > KelvinVector
Definition: Ehlers.h:246
PlasticStrain< KelvinVector > eps_p
plastic part of the state.
Definition: Ehlers.h:248
Eigen::Matrix< double, JacobianResidualSize, JacobianResidualSize, Eigen::RowMajor > JacobianMatrix
Definition: Ehlers.h:289
MaterialProperties(double const t, ParameterLib::SpatialPosition const &x, MaterialPropertiesParameters const &mp)
Definition: Ehlers.h:130
DamageProperties evaluatedDamageProperties(double const t, ParameterLib::SpatialPosition const &x) const
Definition: Ehlers.h:342
friend std::ostream & operator<<(std::ostream &os, StateVariables< DisplacementDim > const &m)
Definition: Ehlers.h:256
MathLib::KelvinVector::KelvinMatrixType< DisplacementDim > KelvinMatrix
Definition: Ehlers.h:303
DamageProperties(double const t, ParameterLib::SpatialPosition const &x, DamagePropertiesParameters const &dp)
Definition: Ehlers.h:175
MaterialPropertiesParameters _mp
Definition: Ehlers.h:351
Damage(double const kappa_d, double const value)
Definition: Ehlers.h:207
PlasticStrain(KelvinVector eps_p_D_, double const eps_p_V_, double const eps_p_eff_)
Definition: Ehlers.h:192
MechanicsBase< DisplacementDim >::MaterialStateVariables & operator=(typename MechanicsBase< DisplacementDim >::MaterialStateVariables const &state) noexcept override
Definition: Ehlers.h:225
std::unique_ptr< typename MechanicsBase< DisplacementDim >::MaterialStateVariables > createMaterialStateVariables() const override
Definition: Ehlers.h:294
TangentType makeTangentType(std::string const &s)
Definition: Ehlers.h:44
Damage damage_prev
damage part of the state.
Definition: Ehlers.h:253
MaterialPropertiesParameters(P const &G_, P const &K_, P const &alpha_, P const &beta_, P const &gamma_, P const &delta_, P const &epsilon_, P const &m_, P const &alpha_p_, P const &beta_p_, P const &gamma_p_, P const &delta_p_, P const &epsilon_p_, P const &m_p_, P const &kappa_, P const &hardening_coefficient_)
Definition: Ehlers.h:69
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
MathLib::KelvinVector::KelvinVectorType< DisplacementDim > KelvinVector
Definition: Ehlers.h:301
PlasticStrain< KelvinVector > eps_p_prev
plastic part of the state.
Definition: Ehlers.h:252
std::unique_ptr< DamagePropertiesParameters > _damage_properties
Definition: Ehlers.h:352
MaterialProperties evaluatedMaterialProperties(double const t, ParameterLib::SpatialPosition const &x) const
Definition: Ehlers.h:336
Eigen::Matrix< double, KelvinVectorDimensions< DisplacementDim >::value, 1, Eigen::ColMajor > KelvinVectorType
Definition: KelvinVector.h:49