22 template <
class MaterialImpl>
25 template <auto stressIndexPair,
typename MaterialImpl>
26 struct VanishingStress;
37 template <
typename Material,
typename Strains>
39 if constexpr (Concepts::EigenVector6<Strains> or Concepts::EigenMatrix33<Strains>)
return true;
41 return Strains::RowsAtCompileTime == Material::freeStrains;
52 template <
typename Material,
typename Strains>
74 template <
class MaterialImpl>
81 static constexpr bool isReduced = traits::isSpecializationNonTypeAndTypes<VanishingStress, MaterialImpl>::value;
88 constexpr const MaterialImpl&
impl()
const {
return static_cast<MaterialImpl const&
>(*this); }
95 constexpr MaterialImpl&
impl() {
return static_cast<MaterialImpl&
>(*this); }
102 [[nodiscard]]
constexpr std::string
name()
const {
return impl().nameImpl(); }
114 template <StrainTags tag,
typename Derived>
116 [[nodiscard]]
auto storedEnergy(
const Eigen::MatrixBase<Derived>& Eraw)
const {
117 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
118 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
121 if constexpr (MaterialImpl::energyAcceptsVoigt)
124 return impl().storedEnergyImpl(E);
126 return impl().storedEnergyImpl(E);
138 template <StrainTags tag,
bool voigt = true,
typename Derived>
140 [[nodiscard]]
auto stresses(
const Eigen::MatrixBase<Derived>& Eraw)
const {
141 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
142 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
143 if constexpr (voigt and MaterialImpl::stressToVoigt ==
false)
145 return toVoigt(stressesMaybeTransformInputToVoigt<false>(E),
false);
147 return stressesMaybeTransformInputToVoigt<voigt>(E);
159 template <StrainTags tag,
bool voigt = true,
typename Derived>
161 [[nodiscard]]
auto tangentModuli(
const Eigen::MatrixBase<Derived>& Eraw)
const {
162 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
163 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
164 if constexpr (voigt and MaterialImpl::moduliToVoigt ==
false)
166 return toVoigt(tangentModuliMaybeTransformInputToVoigt<false>(E));
168 return tangentModuliMaybeTransformInputToVoigt<voigt>(E);
179 template <
typename ScalarTypeOther>
181 return impl().template rebind<ScalarTypeOther>();
185 template <
bool voigt = true,
typename Derived>
186 auto stressesMaybeTransformInputToVoigt(
const Eigen::MatrixBase<Derived>& E)
const {
188 if constexpr (MaterialImpl::stressAcceptsVoigt)
189 return impl().template stressesImpl<voigt>(E);
191 return impl().template stressesImpl<voigt>(
fromVoigt(E.derived()));
193 return impl().template stressesImpl<voigt>(E.derived());
196 template <
bool voigt = true,
typename Derived>
197 auto tangentModuliMaybeTransformInputToVoigt(
const Eigen::MatrixBase<Derived>& E)
const {
198 if constexpr (Concepts::EigenVector<Derived>) {
199 if constexpr (MaterialImpl::moduliAcceptsVoigt)
200 return impl().template tangentModuliImpl<voigt>(E);
202 return impl().template tangentModuliImpl<voigt>(
fromVoigt(E.derived()));
204 return impl().template tangentModuliImpl<voigt>(E.derived());
Contains stl-like type traits.
Helper for the autodiff library.
Material property functions and conversion utilities.
Implementation of strain-related functions.
Definition of several material related enums.
auto fromVoigt(const Eigen::Vector< ST, size > &EVoigt, bool isStrain=true)
Converts a vector given in Voigt notation to a matrix.
Definition: tensorutils.hh:256
constexpr Eigen::Index toVoigt(Eigen::Index i, Eigen::Index j) noexcept
Converts 2D indices to Voigt notation index.
Definition: tensorutils.hh:167
Definition: simpleassemblers.hh:21
consteval bool hasCorrectSize()
Template function for checking if the strain size is correct.
Definition: interface.hh:38
Interface classf or materials.
Definition: interface.hh:75
constexpr const MaterialImpl & impl() const
Const accessor to the underlying material (CRTP).
Definition: interface.hh:88
auto tangentModuli(const Eigen::MatrixBase< Derived > &Eraw) const
Get the tangentModuli of the material.
Definition: interface.hh:161
auto storedEnergy(const Eigen::MatrixBase< Derived > &Eraw) const
Return the stored potential energy of the material.
Definition: interface.hh:116
constexpr MaterialImpl & impl()
Accessor to the underlying material (CRTP).
Definition: interface.hh:95
static constexpr bool isReduced
Static constant for determining if the material has vanishing stress components (is reduced).
Definition: interface.hh:81
MaterialImpl MaterialImplType
Type of material implementation.
Definition: interface.hh:76
constexpr std::string name() const
Get the name of the implemented material.
Definition: interface.hh:102
auto stresses(const Eigen::MatrixBase< Derived > &Eraw) const
Get the stresses of the material.
Definition: interface.hh:140
auto rebind() const
Rebind material to a different scalar type.
Definition: interface.hh:180
Template concept for ensuring correct strain size.
Definition: interface.hh:53
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:381