version 0.4
neohooke.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#pragma once
11
14
15namespace Ikarus {
16
35 template <typename ScalarType_>
36 struct NeoHookeT : public Material<NeoHookeT<ScalarType_>> {
37 [[nodiscard]] constexpr std::string nameImpl() const noexcept { return "NeoHooke"; }
38
44
45 using ScalarType = ScalarType_;
46 static constexpr int worldDimension = 3;
47 using StrainMatrix = Eigen::Matrix<ScalarType, worldDimension, worldDimension>;
49
51 static constexpr auto stressTag = StressTags::PK2;
53 static constexpr bool energyAcceptsVoigt = false;
54 static constexpr bool stressToVoigt = false;
55 static constexpr bool stressAcceptsVoigt = false;
56 static constexpr bool moduliToVoigt = false;
57 static constexpr bool moduliAcceptsVoigt = false;
58 static constexpr double derivativeFactor = 2;
59
66 template <typename Derived>
67 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& C) const noexcept {
68 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
69 if constexpr (!Concepts::EigenVector<Derived>) {
70 const auto traceC = C.trace();
71 const auto logdetF = log(sqrt(C.determinant()));
72 return lambdaAndmu.mu / 2.0 * (traceC - 3 - 2 * logdetF) + lambdaAndmu.lambda / 2.0 * logdetF * logdetF;
73 } else
74 static_assert(!Concepts::EigenVector<Derived>,
75 "NeoHooke energy can only be called with a matrix and not a vector in Voigt notation");
76 }
77
85 template <bool voigt, typename Derived>
86 auto stressesImpl(const Eigen::MatrixBase<Derived>& C) const {
87 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
88 if constexpr (!voigt) {
89 if constexpr (!Concepts::EigenVector<Derived>) {
90 const auto logdetF = log(sqrt(C.determinant()));
91 const auto invC = C.inverse().eval();
92 return (lambdaAndmu.mu * (StrainMatrix::Identity() - invC) + lambdaAndmu.lambda * logdetF * invC).eval();
93 } else
94 static_assert(!Concepts::EigenVector<Derived>,
95 "NeoHooke can only be called with a matrix and not a vector in Voigt notation");
96 } else
97 static_assert(voigt == false, "NeoHooke does not support returning stresses in Voigt notation");
98 }
99
107 template <bool voigt, typename Derived>
108 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& C) const {
109 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
110 if constexpr (!voigt) {
111 const auto invC = C.inverse().eval();
112 const auto logdetF = log(sqrt(C.determinant()));
113 const auto CTinv = tensorView(invC, std::array<Eigen::Index, 2>({3, 3}));
114 static_assert(Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3>>::NumIndices == 2);
115 Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3, 3, 3>> moduli
116 = (lambdaAndmu.lambda * dyadic(CTinv, CTinv)
117 + 2 * (lambdaAndmu.mu - lambdaAndmu.lambda * logdetF) * symTwoSlots(fourthOrderIKJL(invC, invC), {2, 3}))
118 .eval();
119 return moduli;
120 } else
121 static_assert(voigt == false, "NeoHooke does not support returning tangent moduli in Voigt notation");
122 }
123
129 template <typename ScalarTypeOther>
130 auto rebind() const {
132 }
133
135 };
136
141
142} // namespace Ikarus
Helper for the Eigen::Tensor types.
Contains the Material interface class and related template functions for material properties.
Eigen::Tensor< typename Derived::Scalar, rank > tensorView(const Eigen::EigenBase< Derived > &matrix, const std::array< T, rank > &dims)
View an Eigen matrix as an Eigen Tensor with specified dimensions.
Definition: tensorutils.hh:32
auto fourthOrderIKJL(const Eigen::MatrixBase< AType > &A, const Eigen::MatrixBase< BType > &B)
Computes the IKJL product of two matrices.
Definition: tensorutils.hh:122
auto dyadic(const auto &A_ij, const auto &B_kl)
Computes the dyadic product of two Eigen tensors.
Definition: tensorutils.hh:47
auto symTwoSlots(const Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< dim, dim, dim, dim > > &t, const std::array< size_t, 2 > &slots)
Creates a symmetric fourth-order tensor in the two specified slots of the input tensor.
Definition: tensorutils.hh:146
Definition: simpleassemblers.hh:21
NeoHookeT< double > NeoHooke
Alias for NeoHookeT with double as the default scalar type.
Definition: neohooke.hh:140
Interface classf or materials.
Definition: interface.hh:75
Implementation of the Neo-Hookean material model.The energy is computed as.
Definition: neohooke.hh:36
static constexpr bool moduliAcceptsVoigt
Definition: neohooke.hh:57
NeoHookeT(const LamesFirstParameterAndShearModulus &mpt)
Constructor for NeoHookeT.
Definition: neohooke.hh:43
Eigen::Matrix< ScalarType, worldDimension, worldDimension > StrainMatrix
Definition: neohooke.hh:47
ScalarType_ ScalarType
Definition: neohooke.hh:45
auto stressesImpl(const Eigen::MatrixBase< Derived > &C) const
Computes the stresses in the Neo-Hookean material model.
Definition: neohooke.hh:86
static constexpr bool stressToVoigt
Definition: neohooke.hh:54
static constexpr double derivativeFactor
Definition: neohooke.hh:58
static constexpr bool energyAcceptsVoigt
Definition: neohooke.hh:53
constexpr std::string nameImpl() const noexcept
Definition: neohooke.hh:37
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &C) const noexcept
Computes the stored energy in the Neo-Hookean material model.
Definition: neohooke.hh:67
static constexpr auto strainTag
Definition: neohooke.hh:50
auto rebind() const
Rebinds the material to a different scalar type.
Definition: neohooke.hh:130
static constexpr int worldDimension
Definition: neohooke.hh:46
LamesFirstParameterAndShearModulus lambdaAndmu
Definition: neohooke.hh:134
static constexpr auto stressTag
Definition: neohooke.hh:51
static constexpr auto tangentModuliTag
Definition: neohooke.hh:52
StrainMatrix StressMatrix
Definition: neohooke.hh:48
static constexpr bool moduliToVoigt
Definition: neohooke.hh:56
static constexpr bool stressAcceptsVoigt
Definition: neohooke.hh:55
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &C) const
Computes the tangent moduli in the Neo-Hookean material model.
Definition: neohooke.hh:108
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