version 0.4.1
svk.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@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
16
17namespace Ikarus {
18
35template <typename ST>
36struct StVenantKirchhoffT : public Material<StVenantKirchhoffT<ST>>
37{
38 using ScalarType = ST;
39 static constexpr int worldDimension = 3;
40 using StrainMatrix = Eigen::Matrix<ScalarType, worldDimension, worldDimension>;
43
44 static constexpr auto strainTag = StrainTags::greenLagrangian;
45 static constexpr auto stressTag = StressTags::PK2;
47 static constexpr bool energyAcceptsVoigt = true;
48 static constexpr bool stressToVoigt = true;
49 static constexpr bool stressAcceptsVoigt = true;
50 static constexpr bool moduliToVoigt = true;
51 static constexpr bool moduliAcceptsVoigt = true;
52 static constexpr double derivativeFactorImpl = 1;
53
54 [[nodiscard]] constexpr static std::string nameImpl() { return "StVenantKirchhoff"; }
55
61 : materialParameter_{mpt} {}
62
66 MaterialParameters materialParametersImpl() const { return materialParameter_; }
67
74 template <typename Derived>
75 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
76 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
77 if constexpr (Concepts::EigenVector<Derived>) {
78 const ScalarType traceE = E.template segment<3>(0).sum();
79 const ScalarType squaredNorm =
80 E.template segment<3>(0).squaredNorm() + E.template segment<3>(3).squaredNorm() / ScalarType(2.0);
81 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * squaredNorm;
82 } else {
83 const auto traceE = E.trace();
84 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * E.squaredNorm();
85 }
86 }
87
95 template <bool voigt, typename Derived>
96 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
97 static_assert(Concepts::EigenMatrixOrVoigtNotation3<decltype(E.eval())>);
98 const auto& Ed = E.derived();
99 if constexpr (!voigt) {
100 if constexpr (Concepts::EigenVector<Derived>) {
101 static_assert(Concepts::EigenVector6<Derived>);
102 Eigen::Matrix<ScalarType, 3, 3> S;
103 const ScalarType traceE = Ed.template segment<3>(0).sum();
104 S.diagonal().array() =
105 materialParameter_.lambda * traceE + 2 * materialParameter_.mu * Ed.template segment<3>(0).array();
106 S(1, 2) = S(2, 1) = materialParameter_.mu * Ed(3);
107 S(0, 2) = S(2, 0) = materialParameter_.mu * Ed(4);
108 S(0, 1) = S(1, 0) = materialParameter_.mu * Ed(5); // no two since E voigt has 2* on off-diagonal terms
109 return S;
110 } else {
111 static_assert(Concepts::EigenMatrix33<Derived>);
112 return (materialParameter_.lambda * Ed.trace() * StrainMatrix::Identity() + 2 * materialParameter_.mu * Ed)
113 .eval();
114 }
115 } else {
116 if constexpr (Concepts::EigenVector<Derived>) {
117 static_assert(Concepts::EigenVector6<Derived>);
118 Eigen::Matrix<ScalarType, 6, 1> S;
119 const ScalarType traceE = Ed.template segment<3>(0).sum();
120 S.template segment<3>(0).array() = traceE * materialParameter_.lambda;
121 S.template segment<3>(0) += materialParameter_.mu * 2 * Ed.template segment<3>(0);
122 S.template segment<3>(3) =
123 materialParameter_.mu * Ed.template segment<3>(3); // no two since E voigt has 2* on off-diagonal terms
124 return S;
125 } else {
126 Eigen::Matrix<ScalarType, 6, 1> S;
127 S.template segment<3>(0).array() = Ed.trace() * materialParameter_.lambda;
128 S.template segment<3>(0) += 2 * materialParameter_.mu * Ed.diagonal();
129 S(3) = 2 * materialParameter_.mu * Ed(1, 2);
130 S(4) = 2 * materialParameter_.mu * Ed(0, 2);
131 S(5) = 2 * materialParameter_.mu * Ed(0, 1);
132 return S;
133 }
134 }
135 }
136
144 template <bool voigt, typename Derived>
145 auto tangentModuliImpl([[maybe_unused]] const Eigen::MatrixBase<Derived>& E) const {
146 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
147 if constexpr (!voigt) {
148 Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3, 3, 3>> moduli;
149 moduli = materialParameter_.lambda * identityFourthOrder() +
150 2 * materialParameter_.mu * symmetricIdentityFourthOrder();
151 return moduli;
152 } else {
153 Eigen::Matrix<ScalarType, 6, 6> moduli;
154 moduli.setZero();
155 moduli.template block<3, 3>(0, 0).array() = materialParameter_.lambda;
156 moduli.template block<3, 3>(0, 0).diagonal().array() += 2 * materialParameter_.mu;
157 moduli.template block<3, 3>(3, 3).diagonal().array() = materialParameter_.mu;
158 return moduli;
159 }
160 }
161
167 template <typename ScalarTypeOther>
168 auto rebind() const {
169 return StVenantKirchhoffT<ScalarTypeOther>(materialParameter_);
170 }
171
172private:
173 MaterialParameters materialParameter_;
174};
175
180
181} // namespace Ikarus
Helper for the Eigen::Tensor types.
auto symmetricIdentityFourthOrder()
Generates a symmetric identity fourth-order tensor.
Definition: tensorutils.hh:60
auto identityFourthOrder()
Generates an identity fourth-order tensor.
Definition: tensorutils.hh:101
Definition: assemblermanipulatorbuildingblocks.hh:22
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:80
Implementation of the Saint Venant-Kirchhoff material model.The energy is computed as.
Definition: svk.hh:37
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:75
static constexpr int worldDimension
Definition: svk.hh:39
static constexpr bool moduliAcceptsVoigt
Definition: svk.hh:51
static constexpr double derivativeFactorImpl
Definition: svk.hh:52
static constexpr bool stressAcceptsVoigt
Definition: svk.hh:49
Eigen::Matrix< ScalarType, worldDimension, worldDimension > StrainMatrix
Definition: svk.hh:40
auto rebind() const
Rebinds the material to a different scalar type.
Definition: svk.hh:168
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: svk.hh:66
static constexpr bool moduliToVoigt
Definition: svk.hh:50
static constexpr auto strainTag
Definition: svk.hh:44
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:96
LamesFirstParameterAndShearModulus MaterialParameters
Definition: svk.hh:42
StVenantKirchhoffT(const MaterialParameters &mpt)
Constructor for StVenantKirchhoffT.
Definition: svk.hh:60
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:145
static constexpr bool stressToVoigt
Definition: svk.hh:48
static constexpr std::string nameImpl()
Definition: svk.hh:54
static constexpr auto stressTag
Definition: svk.hh:45
static constexpr auto tangentModuliTag
Definition: svk.hh:46
static constexpr bool energyAcceptsVoigt
Definition: svk.hh:47
StrainMatrix StressMatrix
Definition: svk.hh:41
ST ScalarType
Definition: svk.hh:38
Definition: physicshelper.hh:54
double lambda
Definition: physicshelper.hh:55
double mu
Definition: physicshelper.hh:56
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:355
Contains the Material interface class and related template functions for material properties.