29template <auto stressIndexPair,
typename MI>
37 static constexpr int dim = Underlying::dim;
48 static constexpr auto strainTag = Underlying::strainTag;
49 static constexpr auto stressTag = Underlying::stressTag;
67 [[nodiscard]]
constexpr static std::string
nameImpl() noexcept {
68 auto matName = MI::name() +
"_VanishingStress(";
70 matName +=
"(" + std::to_string(p.row) + std::to_string(p.col) +
")";
86 template <
typename Derived>
88 const auto [nonOp, Esol] = reduceStress(E);
89 return matImpl_.storedEnergyImpl(Esol);
99 template <
bool voigt,
typename Derived>
101 const auto [nonOp, Esol] = reduceStress(E);
102 auto stressesRed = matImpl_.template stresses<Underlying::strainTag, true>(Esol);
104 if constexpr (voigt) {
117 template <
bool voigt,
typename Derived>
119 const auto [nonOp, Esol] = reduceStress(E);
120 auto C = matImpl_.template tangentModuli<Underlying::strainTag, true>(Esol);
132 template <
typename ScalarTypeOther>
134 auto reboundMatImpl = matImpl_.template rebind<ScalarTypeOther>();
143 template <
typename Derived>
145 static_assert(Concepts::EigenMatrix22<
decltype(Sraw)>);
147 auto S = Eigen::Matrix<typename Derived::Scalar, 3, 3>::Zero().eval();
148 S.template block<2, 2>(0, 0) = Sraw;
150 auto [D, E] = matImpl_.template materialInversion<Underlying::strainTag, true>(S);
156 return std::make_pair(Dred, Ered);
165 template <
typename Derived>
166 void initUnknownStrains(Eigen::MatrixBase<Derived>& E)
const {
167 for (
size_t i = 0; i <
fixedPairs.size(); ++i) {
185 template <
typename Derived>
186 auto reduceStress(
const Eigen::MatrixBase<Derived>& Eraw)
const {
187 auto E = Impl::maybeFromVoigt(Eraw);
188 initUnknownStrains(E);
190 std::array<size_t, fixedDiagonalVoigtIndicesSize> fixedDiagonalVoigtIndices;
193 if (indexPair[0] == indexPair[1])
194 fixedDiagonalVoigtIndices[ri++] = i;
197 auto f = [&](
const auto&) {
198 auto S = matImpl_.template stresses<Underlying::strainTag, true>(E);
199 return S(fixedDiagonalVoigtIndices).eval();
201 auto df = [&](
const auto&) {
202 auto moduli = (matImpl_.template tangentModuli<Underlying::strainTag, true>(E)).eval();
203 return (moduli(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices) / Underlying::derivativeFactor).eval();
206 auto Er = E(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices).eval().template cast<ScalarType>();
211 auto linearSolver = [](
auto& r,
auto& A) {
return (A.inverse() * r).eval(); };
212 auto updateFunction = [&](
auto&,
const auto& ecomps) {
213 for (
int ri = 0;
auto i : fixedDiagonalVoigtIndices) {
215 E(indexPair[0], indexPair[1]) += ecomps(ri++);
220 NewtonRaphsonConfig nrs({.tol = tol_, .maxIter = 100, .minIter = minIter}, linearSolver, updateFunction);
223 if (!
static_cast<bool>(nr->solve(Er)))
224 DUNE_THROW(Dune::MathError,
"The stress reduction of material " <<
nameImpl() <<
" was unsuccessful\n"
225 <<
"The strains are\n"
226 << E <<
"\n The stresses are\n"
228 return std::make_pair(diffFunction, E);
243template <MatrixIndexPair... stressIndexPair,
typename MaterialImpl>
245 return VanishingStress<std::to_array({stressIndexPair...}), MaterialImpl>(mat, p_tol);
255template <
typename MaterialImpl>
256auto planeStress(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
268template <
typename MaterialImpl>
269auto shellMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
281template <
typename MaterialImpl>
282auto beamMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
Provides a DifferentiableFunction class for handling differentiable Functions.
Helper for the Eigen::Tensor types.
Contains the generic NonlinearSolverFactory class.
Implementation of the Newton-Raphson method for solving nonlinear equations.
helper functions used by material model implementations.
auto staticCondensation(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfCondensedIndices > &indices)
Performs static condensation on a square matrix.
Definition: linearalgebrahelper.hh:498
auto removeCol(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfRemovedCols > &indices)
Removes specified columns from a matrix.
Definition: linearalgebrahelper.hh:539
auto fromVoigt(const Eigen::Matrix< ST, size, 1, Options, maxSize, 1 > &EVoigt, bool isStrain=true)
Converts a vector given in Voigt notation to a matrix.
Definition: tensorutils.hh:296
::value auto createNonlinearSolver(NRConfig &&config, F &&f)
Function to create a NewtonRaphson solver instance.
Definition: newtonraphson.hh:82
auto makeDifferentiableFunction(const Impl::Functions< F... > &derivativesFunctions, const Arg ¶meter)
Factory method for DifferentiableFunction It is a function taking several callables and the argument ...
Definition: differentiablefunction.hh:99
auto functions(Args &&... args)
Creates a Functions object.
Definition: differentiablefunction.hh:44
auto reduceMatrix(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfCondensedIndices > &indices)
Definition: linearalgebrahelper.hh:514
Definition: arrudaboyce.hh:27
auto makeVanishingStress(MaterialImpl mat, typename MaterialImpl::ScalarType p_tol=1e-12)
Factory function to create a VanishingStress material with specified stress indices.
Definition: vanishingstress.hh:244
auto shellMaterial(const MaterialImpl &mat, typename MaterialImpl::ScalarType tol=1e-8)
Factory function to create a VanishingStress material for a shell material with zero normal stress co...
Definition: vanishingstress.hh:269
auto planeStress(const MaterialImpl &mat, typename MaterialImpl::ScalarType tol=1e-8)
Factory function to create a VanishingStress material for plane stress conditions.
Definition: vanishingstress.hh:256
auto beamMaterial(const MaterialImpl &mat, typename MaterialImpl::ScalarType tol=1e-8)
Factory function to create a VanishingStress material for a beam material with two zero normal stress...
Definition: vanishingstress.hh:282
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:82
Represents a pair of stress or strain matrix indices (row and column).
Definition: materialhelpers.hh:26
VanishingStress material model that enforces stress components to be zero.
Definition: vanishingstress.hh:31
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStress material.
Definition: vanishingstress.hh:118
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstress.hh:44
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstress.hh:40
static constexpr int dim
Definition: vanishingstress.hh:37
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstress.hh:54
typename Underlying::ScalarType ScalarType
Scalar type.
Definition: vanishingstress.hh:45
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstress.hh:41
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstress.hh:55
typename Underlying::MaterialTensor MaterialTensor
Definition: vanishingstress.hh:36
static constexpr auto strainTag
Strain tag.
Definition: vanishingstress.hh:48
static constexpr auto stressTag
Stress tag.
Definition: vanishingstress.hh:49
MI Underlying
The underlying material type.
Definition: vanishingstress.hh:32
static constexpr bool isAutoDiff
Definition: vanishingstress.hh:46
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStress material.
Definition: vanishingstress.hh:100
static constexpr std::string nameImpl() noexcept
Definition: vanishingstress.hh:67
typename Underlying::MaterialParameters MaterialParameters
Definition: vanishingstress.hh:33
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstress.hh:133
static constexpr double derivativeFactorImpl
Derivative factor.
Definition: vanishingstress.hh:56
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStress material.
Definition: vanishingstress.hh:87
auto & underlying() const
Returns a const reference to the underlying material.
Definition: vanishingstress.hh:141
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstress.hh:51
typename Underlying::StressMatrix StressMatrix
Definition: vanishingstress.hh:35
VanishingStress(MI mat, typename MI::ScalarType tol=1e-12)
Constructor for VanishingStress.
Definition: vanishingstress.hh:63
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: vanishingstress.hh:78
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstress.hh:39
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstress.hh:52
auto materialInversionImpl(const Eigen::MatrixBase< Derived > &Sraw) const
Definition: vanishingstress.hh:144
static constexpr auto fixedDiagonalVoigtIndicesSize
Number of fixed diagonal indices.
Definition: vanishingstress.hh:42
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstress.hh:53
typename Underlying::StrainMatrix StrainMatrix
Definition: vanishingstress.hh:34
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstress.hh:50
Concept to check if the underlying scalar type is a dual type.
Definition: utils/concepts.hh:625
Contains the Material interface class and related template functions for material properties.