version 0.4.2
svk.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers ikarus@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10// SPDX-License-Identifier: LGPL-3.0-or-later
11
12#pragma once
13
17
18namespace Ikarus::Materials {
19
36template <typename ST>
37struct StVenantKirchhoffT : public Material<StVenantKirchhoffT<ST>>
38{
39 using ScalarType = ST;
40 static constexpr int dim = 3;
41 using StrainMatrix = Eigen::Matrix<ScalarType, dim, dim>;
43 using MaterialTensor = Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<dim, dim, dim, dim>>;
44
46
47 static constexpr auto strainTag = StrainTags::greenLagrangian;
48 static constexpr auto stressTag = StressTags::PK2;
50 static constexpr bool energyAcceptsVoigt = true;
51 static constexpr bool stressToVoigt = true;
52 static constexpr bool stressAcceptsVoigt = true;
53 static constexpr bool moduliToVoigt = true;
54 static constexpr bool moduliAcceptsVoigt = true;
55 static constexpr double derivativeFactorImpl = 1;
56
57 [[nodiscard]] constexpr static std::string nameImpl() { return "StVenantKirchhoff"; }
58
64 : materialParameter_{mpt} {}
65
69 MaterialParameters materialParametersImpl() const { return materialParameter_; }
70
77 template <typename Derived>
78 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
79 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
80 if constexpr (Concepts::EigenVector<Derived>) {
81 const ScalarType traceE = E.template segment<3>(0).sum();
82 const ScalarType squaredNorm =
83 E.template segment<3>(0).squaredNorm() + E.template segment<3>(3).squaredNorm() / ScalarType(2.0);
84 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * squaredNorm;
85 } else {
86 const auto traceE = E.trace();
87 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * E.squaredNorm();
88 }
89 }
90
98 template <bool voigt, typename Derived>
99 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
100 static_assert(Concepts::EigenMatrixOrVoigtNotation3<decltype(E.eval())>);
101 const auto& Ed = E.derived();
102 if constexpr (!voigt) {
103 if constexpr (Concepts::EigenVector<Derived>) {
104 static_assert(Concepts::EigenVector6<Derived>);
105 StressMatrix S;
106 const ScalarType traceE = Ed.template segment<3>(0).sum();
107 S.diagonal().array() =
108 materialParameter_.lambda * traceE + 2 * materialParameter_.mu * Ed.template segment<3>(0).array();
109 S(1, 2) = S(2, 1) = materialParameter_.mu * Ed(3);
110 S(0, 2) = S(2, 0) = materialParameter_.mu * Ed(4);
111 S(0, 1) = S(1, 0) = materialParameter_.mu * Ed(5); // no two since E voigt has 2* on off-diagonal terms
112 return S;
113 } else {
114 static_assert(Concepts::EigenMatrix33<Derived>);
115 return (materialParameter_.lambda * Ed.trace() * StrainMatrix::Identity() + 2 * materialParameter_.mu * Ed)
116 .eval();
117 }
118 } else {
119 if constexpr (Concepts::EigenVector<Derived>) {
120 static_assert(Concepts::EigenVector6<Derived>);
121 Eigen::Matrix<ScalarType, 6, 1> S;
122 const ScalarType traceE = Ed.template segment<3>(0).sum();
123 S.template segment<3>(0).array() = traceE * materialParameter_.lambda;
124 S.template segment<3>(0) += materialParameter_.mu * 2 * Ed.template segment<3>(0);
125 S.template segment<3>(3) =
126 materialParameter_.mu * Ed.template segment<3>(3); // no two since E voigt has 2* on off-diagonal terms
127 return S;
128 } else {
129 Eigen::Matrix<ScalarType, 6, 1> S;
130 S.template segment<3>(0).array() = Ed.trace() * materialParameter_.lambda;
131 S.template segment<3>(0) += 2 * materialParameter_.mu * Ed.diagonal();
132 S(3) = 2 * materialParameter_.mu * Ed(1, 2);
133 S(4) = 2 * materialParameter_.mu * Ed(0, 2);
134 S(5) = 2 * materialParameter_.mu * Ed(0, 1);
135 return S;
136 }
137 }
138 }
139
148 template <bool voigt, typename Derived>
149 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& /* E */) const {
150 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
151 if constexpr (!voigt) {
152 MaterialTensor moduli;
153 moduli = materialParameter_.lambda * identityFourthOrder() +
154 2 * materialParameter_.mu * symmetricIdentityFourthOrder();
155 return moduli;
156 } else {
157 Eigen::Matrix<ScalarType, 6, 6> moduli;
158 moduli.setZero();
159 moduli.template block<3, 3>(0, 0).array() = materialParameter_.lambda;
160 moduli.template block<3, 3>(0, 0).diagonal().array() += 2 * materialParameter_.mu;
161 moduli.template block<3, 3>(3, 3).diagonal().array() = materialParameter_.mu;
162 return moduli;
163 }
164 }
165
171 template <typename ScalarTypeOther>
172 auto rebind() const {
173 return StVenantKirchhoffT<ScalarTypeOther>(materialParameter_);
174 }
175
183 template <typename Derived>
184 auto materialInversionImpl(const Eigen::MatrixBase<Derived>& Sraw) const {
185 auto tangentModulus = tangentModuliImpl<true>(Eigen::Matrix3<ScalarType>::Zero());
186 auto D = tangentModulus.inverse().eval();
187 auto S = Impl::maybeToVoigt(Sraw, false);
188 auto E = (D * S).eval();
189 return std::make_pair(D, E);
190 }
191
192private:
193 MaterialParameters materialParameter_;
194};
195
200
201} // namespace Ikarus::Materials
Helper for the Eigen::Tensor types.
helper functions used by material model implementations.
auto symmetricIdentityFourthOrder()
Generates a symmetric identity fourth-order tensor.
Definition: tensorutils.hh:73
auto identityFourthOrder()
Generates an identity fourth-order tensor.
Definition: tensorutils.hh:114
Definition: arrudaboyce.hh:27
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:82
Implementation of the Saint Venant-Kirchhoff material model.The energy is computed as.
Definition: svk.hh:38
ST ScalarType
Definition: svk.hh:39
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:99
auto materialInversionImpl(const Eigen::MatrixBase< Derived > &Sraw) const
Computes the strain measure and inverse material tangent for a given stress state.
Definition: svk.hh:184
static constexpr std::string nameImpl()
Definition: svk.hh:57
static constexpr bool moduliToVoigt
Definition: svk.hh:53
LamesFirstParameterAndShearModulus MaterialParameters
Definition: svk.hh:45
static constexpr auto strainTag
Definition: svk.hh:47
static constexpr int dim
Definition: svk.hh:40
auto rebind() const
Rebinds the material to a different scalar type.
Definition: svk.hh:172
Eigen::Matrix< ScalarType, dim, dim > StrainMatrix
Definition: svk.hh:41
StrainMatrix StressMatrix
Definition: svk.hh:42
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:78
static constexpr double derivativeFactorImpl
Definition: svk.hh:55
StVenantKirchhoffT(const MaterialParameters &mpt)
Constructor for StVenantKirchhoffT.
Definition: svk.hh:63
static constexpr bool stressAcceptsVoigt
Definition: svk.hh:52
static constexpr auto stressTag
Definition: svk.hh:48
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &) const
Computes the tangent moduli in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:149
Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< dim, dim, dim, dim > > MaterialTensor
Definition: svk.hh:43
static constexpr bool moduliAcceptsVoigt
Definition: svk.hh:54
static constexpr bool stressToVoigt
Definition: svk.hh:51
static constexpr bool energyAcceptsVoigt
Definition: svk.hh:50
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: svk.hh:69
static constexpr auto tangentModuliTag
Definition: svk.hh:49
Definition: physicshelper.hh:54
double lambda
Definition: physicshelper.hh:55
double mu
Definition: physicshelper.hh:56
Concept defining the requirements for Eigen vectors.
Definition: utils/concepts.hh:365
Contains the Material interface class and related template functions for material properties.