Caribou
SaintVenantKirchhoffMaterial.h
1 #pragma once
2 
3 #include <SofaCaribou/Material/HyperelasticMaterial.h>
4 
5 namespace SofaCaribou::material {
6 
7 template<class DataTypes>
9  static constexpr auto Dimension = DataTypes::spatial_dimensions;
10  using Coord = typename DataTypes::Coord;
11  using Real = typename Coord::value_type;
12 public:
13  SOFA_CLASS(SOFA_TEMPLATE(SaintVenantKirchhoffMaterial, DataTypes), SOFA_TEMPLATE(HyperelasticMaterial, DataTypes));
14 
16  : d_young_modulus(initData(&d_young_modulus,
17  Real(1000), "young_modulus",
18  "Young's modulus of the material",
19  true /*displayed_in_GUI*/, false /*read_only_in_GUI*/))
20  , d_poisson_ratio(initData(&d_poisson_ratio,
21  Real(0.3), "poisson_ratio",
22  "Poisson's ratio of the material",
23  true /*displayed_in_GUI*/, false /*read_only_in_GUI*/))
24  {
25  }
26 
32  void before_update() override {
33  const Real young_modulus = d_young_modulus.getValue();
34  const Real poisson_ratio = d_poisson_ratio.getValue();
35  mu = young_modulus / (2.0 * (1.0 + poisson_ratio));
36  l = young_modulus * poisson_ratio / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio));
37 
38  Eigen::Matrix<Real, 2*Dimension, 2*Dimension> D;
39  D <<
40  l + 2*mu, l, l, 0, 0, 0,
41  l, l + 2*mu, l, 0, 0, 0,
42  l, l, l + 2*mu, 0, 0, 0,
43  0, 0, 0, mu, 0, 0,
44  0, 0, 0, 0, mu, 0,
45  0, 0, 0, 0, 0, mu;
46  C = D;
47  }
48 
55  Real
56  strain_energy_density(const Real & /*J*/, const Eigen::Matrix<Real, Dimension, Dimension> & C) const override {
57  static const auto Id = Eigen::Matrix<Real, Dimension, Dimension, Eigen::RowMajor>::Identity();
58  const auto E = (1/2. * (C - Id)).eval();
59  const auto trE = E.trace();
60  const auto trEE = (E*E).trace();
61  return l/2.*(trE*trE) + mu*trEE;
62  }
63 
65  Eigen::Matrix<Real, Dimension, Dimension>
66  PK2_stress(const Real & /*J*/, const Eigen::Matrix<Real, Dimension, Dimension> & C) const override {
67  static const auto Id = Eigen::Matrix<Real, Dimension, Dimension, Eigen::RowMajor>::Identity();
68  const auto E = (1/2. * (C - Id)).eval();
69  return l*E.trace()*Id + 2*mu*E;
70  }
71 
73  Eigen::Matrix<Real, 6, 6>
74  PK2_stress_jacobian(const Real & /*J*/, const Eigen::Matrix<Real, Dimension, Dimension> & /*C*/) const override {
75  return C;
76  }
77 
78 private:
79  // Private members
80  Real mu; // Lame's mu parameter
81  Real l; // Lame's lambda parameter
82  Eigen::Matrix<Real, 2*Dimension, 2*Dimension> C; // Constant elasticity matrix (jacobian of the stress tensor)
83 
84  // Data members
85  sofa::core::objectmodel::Data<Real> d_young_modulus;
86  sofa::core::objectmodel::Data<Real> d_poisson_ratio;
87 };
88 
89 } // namespace SofaCaribou::material
SofaCaribou::material::SaintVenantKirchhoffMaterial::PK2_stress_jacobian
Eigen::Matrix< Real, 6, 6 > PK2_stress_jacobian(const Real &, const Eigen::Matrix< Real, Dimension, Dimension > &) const override
Get the jacobian of the second Piola-Kirchhoff stress tensor w.r.t the right Cauchy-Green strain tens...
Definition: SaintVenantKirchhoffMaterial.h:74
SofaCaribou::material::SaintVenantKirchhoffMaterial::PK2_stress
Eigen::Matrix< Real, Dimension, Dimension > PK2_stress(const Real &, const Eigen::Matrix< Real, Dimension, Dimension > &C) const override
Get the second Piola-Kirchhoff stress tensor from the right Cauchy-Green strain tensor C.
Definition: SaintVenantKirchhoffMaterial.h:66
SofaCaribou::material::HyperelasticMaterial
Definition: HyperelasticMaterial.h:11
SofaCaribou::material::SaintVenantKirchhoffMaterial
Definition: SaintVenantKirchhoffMaterial.h:8
SofaCaribou::material::SaintVenantKirchhoffMaterial::before_update
void before_update() override
This is called just before the material is updated on every points (usually just before a Newton step...
Definition: SaintVenantKirchhoffMaterial.h:32
SofaCaribou::material::SaintVenantKirchhoffMaterial::strain_energy_density
Real strain_energy_density(const Real &, const Eigen::Matrix< Real, Dimension, Dimension > &C) const override
Get the strain energy density Psi from the right Cauchy-Green strain tensor C.
Definition: SaintVenantKirchhoffMaterial.h:56