25template <auto stressIndexPair,
typename MImpl>
26struct VanishingStress;
37template <
typename MAT,
typename S>
39 if constexpr (Concepts::EigenVector6<S> or Concepts::EigenMatrix33<S>)
42 return S::RowsAtCompileTime == MAT::freeStrains;
53template <
typename MAT,
typename S>
83 static constexpr bool isReduced = traits::isSpecializationNonTypeAndTypes<VanishingStress, MaterialImpl>::value;
104 [[nodiscard]]
constexpr std::string
name()
const {
return impl().nameImpl(); }
116 template <StrainTags tag,
typename Derived>
118 [[nodiscard]]
auto storedEnergy(
const Eigen::MatrixBase<Derived>& Eraw)
const {
119 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
120 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
123 if constexpr (MaterialImpl::energyAcceptsVoigt)
126 return impl().storedEnergyImpl(E);
128 return impl().storedEnergyImpl(E);
140 template <StrainTags tag,
bool voigt = true,
typename Derived>
142 [[nodiscard]]
auto stresses(
const Eigen::MatrixBase<Derived>& Eraw)
const {
143 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
144 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
145 if constexpr (voigt and MaterialImpl::stressToVoigt ==
false)
147 return toVoigt(stressesMaybeTransformInputToVoigt<false>(E),
false);
149 return stressesMaybeTransformInputToVoigt<voigt>(E);
161 template <StrainTags tag,
bool voigt = true,
typename Derived>
163 [[nodiscard]]
auto tangentModuli(
const Eigen::MatrixBase<Derived>& Eraw)
const {
164 decltype(
auto) Ev = enlargeIfReduced<Material>(Eraw);
165 decltype(
auto) E = transformStrain<tag, MaterialImpl::strainTag>(Ev);
166 if constexpr (voigt and MaterialImpl::moduliToVoigt ==
false)
168 return toVoigt(tangentModuliMaybeTransformInputToVoigt<false>(E));
170 return tangentModuliMaybeTransformInputToVoigt<voigt>(E);
181 template <
typename STO>
183 return impl().template rebind<STO>();
187 template <
bool voigt = true,
typename Derived>
188 auto stressesMaybeTransformInputToVoigt(
const Eigen::MatrixBase<Derived>& E)
const {
190 if constexpr (MaterialImpl::stressAcceptsVoigt)
191 return impl().template stressesImpl<voigt>(E);
193 return impl().template stressesImpl<voigt>(
fromVoigt(E.derived()));
195 return impl().template stressesImpl<voigt>(E.derived());
198 template <
bool voigt = true,
typename Derived>
199 auto tangentModuliMaybeTransformInputToVoigt(
const Eigen::MatrixBase<Derived>& E)
const {
200 if constexpr (Concepts::EigenVector<Derived>) {
201 if constexpr (MaterialImpl::moduliAcceptsVoigt)
202 return impl().template tangentModuliImpl<voigt>(E);
204 return impl().template tangentModuliImpl<voigt>(
fromVoigt(E.derived()));
206 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:166
Definition: simpleassemblers.hh:22
consteval bool hasCorrectSize()
Template function for checking if the strain size is correct.
Definition: interface.hh:38
Interface classf or materials.
Definition: interface.hh:77
constexpr const MaterialImpl & impl() const
Const accessor to the underlying material (CRTP).
Definition: interface.hh:90
auto tangentModuli(const Eigen::MatrixBase< Derived > &Eraw) const
Get the tangentModuli of the material.
Definition: interface.hh:163
auto rebind() const
Rebind material to a different scalar type.
Definition: interface.hh:182
MI MaterialImpl
Type of material implementation.
Definition: interface.hh:78
static constexpr bool isReduced
Static constant for determining if the material has vanishing stress components (is reduced).
Definition: interface.hh:83
constexpr std::string name() const
Get the name of the implemented material.
Definition: interface.hh:104
auto storedEnergy(const Eigen::MatrixBase< Derived > &Eraw) const
Return the stored potential energy of the material.
Definition: interface.hh:118
constexpr MaterialImpl & impl()
Accessor to the underlying material (CRTP).
Definition: interface.hh:97
auto stresses(const Eigen::MatrixBase< Derived > &Eraw) const
Get the stresses of the material.
Definition: interface.hh:142
Template concept for ensuring correct strain size.
Definition: interface.hh:54
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:353