version 0.4
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
35 template <typename ScalarType_>
36 struct StVenantKirchhoffT : public Material<StVenantKirchhoffT<ScalarType_>> {
37 [[nodiscard]] constexpr std::string nameImpl() const { return "StVenantKirchhoff"; }
38
44
45 using ScalarType = ScalarType_;
46 static constexpr int worldDimension = 3;
47 using StrainMatrix = Eigen::Matrix<ScalarType, worldDimension, worldDimension>;
49
50 static constexpr auto strainTag = StrainTags::greenLagrangian;
51 static constexpr auto stressTag = StressTags::PK2;
53 static constexpr bool energyAcceptsVoigt = true;
54 static constexpr bool stressToVoigt = true;
55 static constexpr bool stressAcceptsVoigt = true;
56 static constexpr bool moduliToVoigt = true;
57 static constexpr bool moduliAcceptsVoigt = true;
58 // this factor denotes the differences between the returned stresses and moduli and the passed strain
59 // for neoHooke the inserted quantity is C the Green-Lagrangian strain tensor,
60 // the function relation between the energy and the stresses is S = 1\partial \psi(E)/ \partial E.
61 // This factor is pre factor, which is the difference to the actual derivative is written here
62 static constexpr double derivativeFactor = 1;
63
70 template <typename Derived>
71 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
72 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
73 if constexpr (Concepts::EigenVector<Derived>) {
74 const ScalarType traceE = E.template segment<3>(0).sum();
75 const ScalarType squaredNorm
76 = E.template segment<3>(0).squaredNorm() + E.template segment<3>(3).squaredNorm() / ScalarType(2.0);
77 return materialParameter.lambda / ScalarType(2.0) * traceE * traceE + materialParameter.mu * squaredNorm;
78 } else {
79 const auto traceE = E.trace();
80 return materialParameter.lambda / ScalarType(2.0) * traceE * traceE + materialParameter.mu * E.squaredNorm();
81 }
82 }
83
91 template <bool voigt, typename Derived>
92 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
93 static_assert(Concepts::EigenMatrixOrVoigtNotation3<decltype(E.eval())>);
94 const auto& Ed = E.derived();
95 if constexpr (!voigt) {
96 if constexpr (Concepts::EigenVector<Derived>) {
97 static_assert(Concepts::EigenVector6<Derived>);
98 Eigen::Matrix<ScalarType, 3, 3> S;
99 const ScalarType traceE = Ed.template segment<3>(0).sum();
100 S.diagonal().array()
101 = materialParameter.lambda * traceE + 2 * materialParameter.mu * Ed.template segment<3>(0).array();
102 S(1, 2) = S(2, 1) = materialParameter.mu * Ed(3);
103 S(0, 2) = S(2, 0) = materialParameter.mu * Ed(4);
104 S(0, 1) = S(1, 0) = materialParameter.mu * Ed(5); // no two since E voigt has 2* on off-diagonal terms
105 return S;
106 } else {
107 static_assert(Concepts::EigenMatrix33<Derived>);
108 return (materialParameter.lambda * Ed.trace() * StrainMatrix::Identity() + 2 * materialParameter.mu * Ed)
109 .eval();
110 }
111 } else {
112 if constexpr (Concepts::EigenVector<Derived>) {
113 static_assert(Concepts::EigenVector6<Derived>);
114 Eigen::Matrix<ScalarType, 6, 1> S;
115 const ScalarType traceE = Ed.template segment<3>(0).sum();
116 S.template segment<3>(0).array() = traceE * materialParameter.lambda;
117 S.template segment<3>(0) += materialParameter.mu * 2 * Ed.template segment<3>(0);
118 S.template segment<3>(3)
119 = materialParameter.mu * Ed.template segment<3>(3); // no two since E voigt has 2* on off-diagonal terms
120 return S;
121 } else {
122 Eigen::Matrix<ScalarType, 6, 1> S;
123 S.template segment<3>(0).array() = Ed.trace() * materialParameter.lambda;
124 S.template segment<3>(0) += 2 * materialParameter.mu * Ed.diagonal();
125 S(3) = 2 * materialParameter.mu * Ed(1, 2);
126 S(4) = 2 * materialParameter.mu * Ed(0, 2);
127 S(5) = 2 * materialParameter.mu * Ed(0, 1);
128 return S;
129 }
130 }
131 }
132
140 template <bool voigt, typename Derived>
141 auto tangentModuliImpl([[maybe_unused]] const Eigen::MatrixBase<Derived>& E) const {
142 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
143 if constexpr (!voigt) {
144 Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3, 3, 3>> moduli;
147 return moduli;
148 } else {
149 Eigen::Matrix<ScalarType, 6, 6> moduli;
150 moduli.setZero();
151 moduli.template block<3, 3>(0, 0).array() = materialParameter.lambda;
152 moduli.template block<3, 3>(0, 0).diagonal().array() += 2 * materialParameter.mu;
153 moduli.template block<3, 3>(3, 3).diagonal().array() = materialParameter.mu;
154 return moduli;
155 }
156 }
157
163 template <typename ScalarTypeOther>
164 auto rebind() const {
166 }
167
169 };
170
175
176} // 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:21
StVenantKirchhoffT< double > StVenantKirchhoff
Alias for StVenantKirchhoffT with double as the default scalar type.
Definition: svk.hh:174
Interface classf or materials.
Definition: interface.hh:75
Implementation of the Saint Venant-Kirchhoff material model.The energy is computed as.
Definition: svk.hh:36
static constexpr bool stressAcceptsVoigt
Definition: svk.hh:55
static constexpr auto tangentModuliTag
Definition: svk.hh:52
Eigen::Matrix< ScalarType, worldDimension, worldDimension > StrainMatrix
Definition: svk.hh:47
static constexpr bool energyAcceptsVoigt
Definition: svk.hh:53
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:71
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:92
static constexpr int worldDimension
Definition: svk.hh:46
ScalarType_ ScalarType
Definition: svk.hh:45
StVenantKirchhoffT(const LamesFirstParameterAndShearModulus &mpt)
Constructor for StVenantKirchhoffT.
Definition: svk.hh:43
static constexpr bool stressToVoigt
Definition: svk.hh:54
constexpr std::string nameImpl() const
Definition: svk.hh:37
StrainMatrix StressMatrix
Definition: svk.hh:48
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli in the Saint Venant-Kirchhoff material model.
Definition: svk.hh:141
auto rebind() const
Rebinds the material to a different scalar type.
Definition: svk.hh:164
static constexpr double derivativeFactor
Definition: svk.hh:62
static constexpr bool moduliToVoigt
Definition: svk.hh:56
static constexpr bool moduliAcceptsVoigt
Definition: svk.hh:57
LamesFirstParameterAndShearModulus materialParameter
Definition: svk.hh:168
static constexpr auto stressTag
Definition: svk.hh:51
static constexpr auto strainTag
Definition: svk.hh:50
Definition: physicshelper.hh:143
double lambda
Definition: physicshelper.hh:144
double mu
Definition: physicshelper.hh:145
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:381