3 #include <SofaCaribou/Material/HyperelasticMaterial.h>
5 namespace SofaCaribou::material {
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;
16 : d_young_modulus(initData(&d_young_modulus,
17 Real(1000),
"young_modulus",
18 "Young's modulus of the material",
20 , d_poisson_ratio(initData(&d_poisson_ratio,
21 Real(0.3),
"poisson_ratio",
22 "Poisson's ratio of the material",
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));
38 Eigen::Matrix<Real, 2*Dimension, 2*Dimension> 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,
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;
65 Eigen::Matrix<Real, Dimension, Dimension>
66 PK2_stress(
const Real & ,
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;
73 Eigen::Matrix<Real, 6, 6>
74 PK2_stress_jacobian(
const Real & ,
const Eigen::Matrix<Real, Dimension, Dimension> & )
const override {
82 Eigen::Matrix<Real, 2*Dimension, 2*Dimension> C;
85 sofa::core::objectmodel::Data<Real> d_young_modulus;
86 sofa::core::objectmodel::Data<Real> d_poisson_ratio;