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 [[nodiscard]] constexpr std::string nameImpl() const { return "StVenantKirchhoff"; }
39
45 : materialParameter_{mpt} {}
46
47 using ScalarType = ST;
48 static constexpr int worldDimension = 3;
49 using StrainMatrix = Eigen::Matrix<ScalarType, worldDimension, worldDimension>;
51
52 static constexpr auto strainTag = StrainTags::greenLagrangian;
53 static constexpr auto stressTag = StressTags::PK2;
55 static constexpr bool energyAcceptsVoigt = true;
56 static constexpr bool stressToVoigt = true;
57 static constexpr bool stressAcceptsVoigt = true;
58 static constexpr bool moduliToVoigt = true;
59 static constexpr bool moduliAcceptsVoigt = true;
60 // this factor denotes the differences between the returned stresses and moduli and the passed strain
61 // for neoHooke the inserted quantity is C the Green-Lagrangian strain tensor,
62 // the function relation between the energy and the stresses is S = 1\partial \psi(E)/ \partial E.
63 // This factor is pre factor, which is the difference to the actual derivative is written here
64 static constexpr double derivativeFactor = 1;
65
72 template <typename Derived>
73 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
74 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
75 if constexpr (Concepts::EigenVector<Derived>) {
76 const ScalarType traceE = E.template segment<3>(0).sum();
77 const ScalarType squaredNorm =
78 E.template segment<3>(0).squaredNorm() + E.template segment<3>(3).squaredNorm() / ScalarType(2.0);
79 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * squaredNorm;
80 } else {
81 const auto traceE = E.trace();
82 return materialParameter_.lambda / ScalarType(2.0) * traceE * traceE + materialParameter_.mu * E.squaredNorm();
83 }
84 }
85
93 template <bool voigt, typename Derived>
94 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
95 static_assert(Concepts::EigenMatrixOrVoigtNotation3<decltype(E.eval())>);
96 const auto& Ed = E.derived();
97 if constexpr (!voigt) {
98 if constexpr (Concepts::EigenVector<Derived>) {
99 static_assert(Concepts::EigenVector6<Derived>);
100 Eigen::Matrix<ScalarType, 3, 3> S;
101 const ScalarType traceE = Ed.template segment<3>(0).sum();
102 S.diagonal().array() =
103 materialParameter_.lambda * traceE + 2 * materialParameter_.mu * Ed.template segment<3>(0).array();
104 S(1, 2) = S(2, 1) = materialParameter_.mu * Ed(3);
105 S(0, 2) = S(2, 0) = materialParameter_.mu * Ed(4);
106 S(0, 1) = S(1, 0) = materialParameter_.mu * Ed(5); // no two since E voigt has 2* on off-diagonal terms
107 return S;
108 } else {
109 static_assert(Concepts::EigenMatrix33<Derived>);
110 return (materialParameter_.lambda * Ed.trace() * StrainMatrix::Identity() + 2 * materialParameter_.mu * Ed)
111 .eval();
112 }
113 } else {
114 if constexpr (Concepts::EigenVector<Derived>) {
115 static_assert(Concepts::EigenVector6<Derived>);
116 Eigen::Matrix<ScalarType, 6, 1> S;
117 const ScalarType traceE = Ed.template segment<3>(0).sum();
118 S.template segment<3>(0).array() = traceE * materialParameter_.lambda;
119 S.template segment<3>(0) += materialParameter_.mu * 2 * Ed.template segment<3>(0);
120 S.template segment<3>(3) =
121 materialParameter_.mu * Ed.template segment<3>(3); // no two since E voigt has 2* on off-diagonal terms
122 return S;
123 } else {
124 Eigen::Matrix<ScalarType, 6, 1> S;
125 S.template segment<3>(0).array() = Ed.trace() * materialParameter_.lambda;
126 S.template segment<3>(0) += 2 * materialParameter_.mu * Ed.diagonal();
127 S(3) = 2 * materialParameter_.mu * Ed(1, 2);
128 S(4) = 2 * materialParameter_.mu * Ed(0, 2);
129 S(5) = 2 * materialParameter_.mu * Ed(0, 1);
130 return S;
131 }
132 }
133 }
134
142 template <bool voigt, typename Derived>
143 auto tangentModuliImpl([[maybe_unused]] const Eigen::MatrixBase<Derived>& E) const {
144 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
145 if constexpr (!voigt) {
146 Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3, 3, 3>> moduli;
147 moduli = materialParameter_.lambda * identityFourthOrder() +
148 2 * materialParameter_.mu * symmetricIdentityFourthOrder();
149 return moduli;
150 } else {
151 Eigen::Matrix<ScalarType, 6, 6> moduli;
152 moduli.setZero();
153 moduli.template block<3, 3>(0, 0).array() = materialParameter_.lambda;
154 moduli.template block<3, 3>(0, 0).diagonal().array() += 2 * materialParameter_.mu;
155 moduli.template block<3, 3>(3, 3).diagonal().array() = materialParameter_.mu;
156 return moduli;
157 }
158 }
159
165 template <typename ScalarTypeOther>
166 auto rebind() const {
167 return StVenantKirchhoffT<ScalarTypeOther>(materialParameter_);
168 }
169
170private:
171 LamesFirstParameterAndShearModulus materialParameter_;
172};
173
178
179} // namespace Ikarus
Helper for the Eigen::Tensor types.
Contains the Material interface class and related template functions for material properties.
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: simpleassemblers.hh:22
Interface classf or materials.
Definition: interface.hh:77
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:73
static constexpr int worldDimension
Definition: svk.hh:48
static constexpr bool moduliAcceptsVoigt
Definition: svk.hh:59
static constexpr bool stressAcceptsVoigt
Definition: svk.hh:57
Eigen::Matrix< ScalarType, worldDimension, worldDimension > StrainMatrix
Definition: svk.hh:49
auto rebind() const
Rebinds the material to a different scalar type.
Definition: svk.hh:166
static constexpr bool moduliToVoigt
Definition: svk.hh:58
static constexpr auto strainTag
Definition: svk.hh:52
constexpr std::string nameImpl() const
Definition: svk.hh:38
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:94
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:143
static constexpr bool stressToVoigt
Definition: svk.hh:56
static constexpr auto stressTag
Definition: svk.hh:53
static constexpr double derivativeFactor
Definition: svk.hh:64
StVenantKirchhoffT(const LamesFirstParameterAndShearModulus &mpt)
Constructor for StVenantKirchhoffT.
Definition: svk.hh:44
static constexpr auto tangentModuliTag
Definition: svk.hh:54
static constexpr bool energyAcceptsVoigt
Definition: svk.hh:55
StrainMatrix StressMatrix
Definition: svk.hh:50
ST ScalarType
Definition: svk.hh:47
Definition: physicshelper.hh:88
double lambda
Definition: physicshelper.hh:89
double mu
Definition: physicshelper.hh:90
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:353