version 0.4.1
finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.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#include <dune/common/float_cmp.hh>
13
16
17namespace Ikarus::Materials {
18
34template <Concepts::DeviatoricFunction DF>
36{
37 using ScalarType = typename DF::ScalarType;
38
39 template <typename ST = ScalarType>
40 using PrincipalStretches = typename DF::template PrincipalStretches<ST>;
41 using MaterialParameters = typename DF::MaterialParameters;
42
44
45 template <typename ST = ScalarType>
46 using FirstDerivative = typename DF::template FirstDerivative<ST>;
47 template <typename ST = ScalarType>
48 using SecondDerivative = typename DF::template SecondDerivative<ST>;
49
50 static constexpr int dim = 3;
51
52 template <typename ST = ScalarType>
53 using StressMatrix = Eigen::Vector<ST, dim>;
54
55 template <typename ST = ScalarType>
56 using MaterialTensor = Eigen::TensorFixedSize<ST, Eigen::Sizes<dim, dim, dim, dim>>;
57
58 [[nodiscard]] constexpr static std::string name() noexcept { return "Deviatoric function: " + DF::name(); }
59
60 Deviatoric(const DF df)
61 : deviatoricFunction_{df} {}
62
66 const MaterialParameters materialParameters() const { return deviatoricFunction_.materialParametersImpl(); }
67
76 template <typename ST>
77 ST storedEnergy(const PrincipalStretches<ST>& lambda) const {
78 return deviatoricFunction_.storedEnergyImpl(lambda);
79 };
80
88 template <typename ST>
90 auto dWdLambda = deviatoricFunction_.firstDerivativeImpl(lambda);
91 return (dWdLambda.array() / lambda.array()).eval();
92 }
93
102 template <typename ST>
104 auto S = stresses(lambda);
105 auto dS = deviatoricFunction_.secondDerivativeImpl(lambda);
106
107 auto L = MaterialTensor<ST>{};
108 L.setZero();
109
110 for (const auto i : dimensionRange())
111 for (const auto k : dimensionRange())
112 L(i, i, k, k) = 1.0 / (lambda(i) * lambda(k)) * dS(i, k);
113
114 Eigen::ArrayXd lambdaSquared = lambda.array().square();
115 for (const auto i : dimensionRange())
116 for (const auto k : dimensionRange())
117 if (i != k) {
118 if (Dune::FloatCmp::eq(lambda(i), lambda(k), 1e-8))
119 L(i, k, i, k) = 0.5 * (L(i, i, i, i) - L(i, i, k, k));
120 else
121 L(i, k, i, k) += (S(i) - S(k)) / (lambdaSquared(i) - lambdaSquared(k));
122 }
123
124 return L;
125 };
126
132 template <typename STO>
133 auto rebind() const {
134 auto reboundDF = deviatoricFunction_.template rebind<STO>();
135 return Deviatoric<decltype(reboundDF)>{reboundDF};
136 }
137
138private:
139 DF deviatoricFunction_;
140
141 inline static constexpr auto dimensionRange() { return Dune::range(dim); }
142};
143} // namespace Ikarus::Materials
Helper for the Eigen::Tensor types.
Definition: arrudaboyce.hh:27
This is the interface implementation for the deviatoric part of a hyperelastic material....
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:36
typename DF::ScalarType ScalarType
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:37
const MaterialParameters materialParameters() const
Returns the material parameters stored in the deviatoric part of the material.
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:66
StressMatrix< ST > stresses(const PrincipalStretches< ST > &lambda) const
Returns the principal PK2 stresses obtained from the first derivative of the deviatoric function.
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:89
DF DeviatoricFunction
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:43
MaterialTensor< ST > tangentModuli(const PrincipalStretches< ST > &lambda) const
Returns the material tangent modulus obtained from the second derivative of the deviatoric function.
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:103
auto rebind() const
Rebinds the material to a different scalar type.
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:133
static constexpr std::string name() noexcept
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:58
Eigen::Vector< ST, dim > StressMatrix
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:53
static constexpr int dim
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:50
typename DF::MaterialParameters MaterialParameters
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:41
typename DF::template PrincipalStretches< ST > PrincipalStretches
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:40
ST storedEnergy(const PrincipalStretches< ST > &lambda) const
Returns the stored energy obtained from the deviatoric function.
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:77
typename DF::template FirstDerivative< ST > FirstDerivative
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:46
typename DF::template SecondDerivative< ST > SecondDerivative
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:48
Eigen::TensorFixedSize< ST, Eigen::Sizes< dim, dim, dim, dim > > MaterialTensor
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:56
Deviatoric(const DF df)
Definition: finiteelements/mechanics/materials/hyperelastic/deviatoric/interface.hh:60
Header file including concepts for hyperelastic material models.