version 0.4.1
mueslifinite.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11
12#if ENABLE_MUESLI
13
14 #include <muesli/muesli.h>
15
16 #include <Eigen/Eigen>
17
22
23namespace Ikarus::Materials {
24
32template <typename FM>
33requires(std::is_base_of_v<muesli::finiteStrainMaterial, FM>)
34struct FiniteStrain : public Material<FiniteStrain<FM>>
35{
36 using MaterialModel = FM;
37 using ScalarType = double;
38 static constexpr int dim = 3;
39 using StrainMatrix = Eigen::Matrix<ScalarType, dim, dim>;
40 using StressMatrix = StrainMatrix;
41 using MaterialTensor = Eigen::TensorFixedSize<ScalarType, Eigen::Sizes<dim, dim, dim, dim>>;
42 using MaterialParameters = muesli::materialProperties;
43
44 static constexpr auto strainTag = StrainTags::rightCauchyGreenTensor;
45 static constexpr auto stressTag = StressTags::PK2;
46 static constexpr auto tangentModuliTag = TangentModuliTags::Material;
47 static constexpr bool energyAcceptsVoigt = false;
48 static constexpr bool stressToVoigt = false;
49 static constexpr bool stressAcceptsVoigt = false;
50 static constexpr bool moduliToVoigt = false;
51 static constexpr bool moduliAcceptsVoigt = false;
52 static constexpr double derivativeFactorImpl = 2;
53
54 [[nodiscard]] constexpr static std::string nameImpl() noexcept { return "FiniteStrain: " + materialName<FM>(); }
55
60 explicit FiniteStrain(const MaterialParameters& mpt)
61 : materialParameter_{mpt},
62 material_{Dune::className<FM>(), mpt},
63 mp_{material_.createMaterialPoint()} {}
64
68 MaterialParameters materialParametersImpl() const { return materialParameter_; }
69
76 template <typename Derived>
77 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& C) const {
78 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
79 if constexpr (!Concepts::EigenVector<Derived>) {
80 updateState(C);
81 return mp_->storedEnergy();
82 } else
83 static_assert(!Concepts::EigenVector<Derived>,
84 "MuesliFiniteStrain energy can only be called with a matrix and not a vector in Voigt notation");
85 }
86
94 template <bool voigt, typename Derived>
95 auto stressesImpl(const Eigen::MatrixBase<Derived>& C) const {
96 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
97 if constexpr (!voigt) {
98 if constexpr (!Concepts::EigenVector<Derived>) {
99 updateState(C);
100 istensor stress;
101 mp_->secondPiolaKirchhoffStress(stress);
102 return toEigenMatrix(stress).eval();
103 } else
104 static_assert(!Concepts::EigenVector<Derived>,
105 "MuesliFiniteStrain can only be called with a matrix and not a vector in Voigt notation");
106 } else
107 static_assert(voigt == false, "MuesliFiniteStrain does not support returning stresses in Voigt notation");
108 }
109
117 template <bool voigt, typename Derived>
118 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& C) const {
119 static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>);
120 if constexpr (!voigt) {
121 if constexpr (!Concepts::EigenVector<Derived>) {
122 updateState(C);
123 itensor4 tangentModuli;
124
125 mp_->convectedTangent(tangentModuli);
126 return toEigenTensor(tangentModuli);
127 } else
128 static_assert(!Concepts::EigenVector<Derived>,
129 "MuesliFiniteStrain can only be called with a matrix and not a vector in Voigt notation");
130 } else
131 static_assert(voigt == false, "MuesliFiniteStrain does not support returning tangent moduli in Voigt notation");
132 }
133
138 auto& material() const { return material_; }
139
144 auto& materialPoint() const { return mp_; }
145
146 FiniteStrain(const FiniteStrain& other)
147 : materialParameter_{other.materialParameter_},
148 material_{Dune::className<FM>(), materialParameter_},
149 mp_{material_.createMaterialPoint()} {}
150
151private:
152 MaterialParameters materialParameter_;
153 MaterialModel material_;
154 std::unique_ptr<muesli::finiteStrainMP> mp_;
155
156 template <typename Derived>
157 void updateState(const Eigen::MatrixBase<Derived>& C) const {
158 Impl::checkPositiveOrAbort(C.determinant());
159 auto F = toitensor(transformStrain<strainTag, StrainTags::deformationGradient>(C));
160 mp_->updateCurrentState(0.0, F);
161 }
162};
163
164} // namespace Ikarus::Materials
165#else
166 #error Muesli materials depends on the Muesli library, which is not included
167#endif
Helper for the Eigen::Tensor types.
helper functions used by material model implementations.
Definition: arrudaboyce.hh:27
Definition: utils/dirichletvalues.hh:30
Contains the Material interface class and related template functions for material properties.