version 0.4.1
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
35template <typename ST>
36struct NeoHookeT : public Material<NeoHookeT<ST>>
37{
38 [[nodiscard]] constexpr std::string nameImpl() const noexcept { return "NeoHooke"; }
39
45 : lambdaAndmu_{mpt} {}
46
47 using ScalarType = ST;
48 static constexpr int worldDimension = 3;
49 using StrainMatrix = Eigen::Matrix<ScalarType, worldDimension, worldDimension>;
51
53 static constexpr auto stressTag = StressTags::PK2;
55 static constexpr bool energyAcceptsVoigt = false;
56 static constexpr bool stressToVoigt = false;
57 static constexpr bool stressAcceptsVoigt = false;
58 static constexpr bool moduliToVoigt = false;
59 static constexpr bool moduliAcceptsVoigt = false;
60 static constexpr double derivativeFactor = 2;
61
68 template <typename Derived>
69 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& C) const noexcept {
70 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
71 if constexpr (!Concepts::EigenVector<Derived>) {
72 const auto traceC = C.trace();
73 const auto logdetF = log(sqrt(C.determinant()));
74 return lambdaAndmu_.mu / 2.0 * (traceC - 3 - 2 * logdetF) + lambdaAndmu_.lambda / 2.0 * logdetF * logdetF;
75 } else
76 static_assert(!Concepts::EigenVector<Derived>,
77 "NeoHooke energy can only be called with a matrix and not a vector in Voigt notation");
78 }
79
87 template <bool voigt, typename Derived>
88 auto stressesImpl(const Eigen::MatrixBase<Derived>& C) const {
89 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
90 if constexpr (!voigt) {
91 if constexpr (!Concepts::EigenVector<Derived>) {
92 const auto logdetF = log(sqrt(C.determinant()));
93 const auto invC = C.inverse().eval();
94 return (lambdaAndmu_.mu * (StrainMatrix::Identity() - invC) + lambdaAndmu_.lambda * logdetF * invC).eval();
95 } else
96 static_assert(!Concepts::EigenVector<Derived>,
97 "NeoHooke can only be called with a matrix and not a vector in Voigt notation");
98 } else
99 static_assert(voigt == false, "NeoHooke does not support returning stresses in Voigt notation");
100 }
101
109 template <bool voigt, typename Derived>
110 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& C) const {
111 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
112 if constexpr (!voigt) {
113 const auto invC = C.inverse().eval();
114 const auto logdetF = log(sqrt(C.determinant()));
115 const auto CTinv = tensorView(invC, std::array<Eigen::Index, 2>({3, 3}));
116 static_assert(Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3>>::NumIndices == 2);
117 Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<3, 3, 3, 3>> moduli =
118 (lambdaAndmu_.lambda * dyadic(CTinv, CTinv) +
119 2 * (lambdaAndmu_.mu - lambdaAndmu_.lambda * logdetF) * symTwoSlots(fourthOrderIKJL(invC, invC), {2, 3}))
120 .eval();
121 return moduli;
122 } else
123 static_assert(voigt == false, "NeoHooke does not support returning tangent moduli in Voigt notation");
124 }
125
131 template <typename STO>
132 auto rebind() const {
133 return NeoHookeT<STO>(lambdaAndmu_);
134 }
135
136private:
138};
139
144
145} // 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:145
Definition: simpleassemblers.hh:22
Interface classf or materials.
Definition: interface.hh:77
Implementation of the Neo-Hookean material model.The energy is computed as.
Definition: neohooke.hh:37
static constexpr bool energyAcceptsVoigt
Definition: neohooke.hh:55
static constexpr double derivativeFactor
Definition: neohooke.hh:60
Eigen::Matrix< ScalarType, worldDimension, worldDimension > StrainMatrix
Definition: neohooke.hh:49
StrainMatrix StressMatrix
Definition: neohooke.hh:50
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &C) const
Computes the tangent moduli in the Neo-Hookean material model.
Definition: neohooke.hh:110
static constexpr auto strainTag
Definition: neohooke.hh:52
static constexpr auto tangentModuliTag
Definition: neohooke.hh:54
constexpr std::string nameImpl() const noexcept
Definition: neohooke.hh:38
static constexpr bool stressToVoigt
Definition: neohooke.hh:56
static constexpr int worldDimension
Definition: neohooke.hh:48
static constexpr auto stressTag
Definition: neohooke.hh:53
static constexpr bool moduliAcceptsVoigt
Definition: neohooke.hh:59
auto rebind() const
Rebinds the material to a different scalar type.
Definition: neohooke.hh:132
static constexpr bool stressAcceptsVoigt
Definition: neohooke.hh:57
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &C) const noexcept
Computes the stored energy in the Neo-Hookean material model.
Definition: neohooke.hh:69
ST ScalarType
Definition: neohooke.hh:47
static constexpr bool moduliToVoigt
Definition: neohooke.hh:58
auto stressesImpl(const Eigen::MatrixBase< Derived > &C) const
Computes the stresses in the Neo-Hookean material model.
Definition: neohooke.hh:88
NeoHookeT(const LamesFirstParameterAndShearModulus &mpt)
Constructor for NeoHookeT.
Definition: neohooke.hh:44
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