28template <auto stressIndexPair,
typename MI>
43 static constexpr auto strainTag = Underlying::strainTag;
44 static constexpr auto stressTag = Underlying::stressTag;
62 [[nodiscard]]
constexpr static std::string
nameImpl() noexcept {
63 auto matName = MI::name() +
"_VanishingStress(";
65 matName +=
"(" + std::to_string(p.row) + std::to_string(p.col) +
")";
81 template <
typename Derived>
83 const auto [nonOp, Esol] = reduceStress(E);
84 return matImpl_.storedEnergyImpl(Esol);
94 template <
bool voigt,
typename Derived>
96 const auto [nonOp, Esol] = reduceStress(E);
97 auto stressesRed = matImpl_.template stresses<Underlying::strainTag, true>(Esol);
99 if constexpr (voigt) {
112 template <
bool voigt,
typename Derived>
114 const auto [nonOp, Esol] = reduceStress(E);
115 auto C = matImpl_.template tangentModuli<Underlying::strainTag, true>(Esol);
127 template <
typename ScalarTypeOther>
129 auto reboundMatImpl = matImpl_.template rebind<ScalarTypeOther>();
139 template <
typename Derived>
140 void initUnknownStrains(Eigen::MatrixBase<Derived>& E)
const {
141 for (
size_t i = 0; i <
fixedPairs.size(); ++i) {
159 template <
typename Derived>
160 auto reduceStress(
const Eigen::MatrixBase<Derived>& Eraw)
const {
161 auto E = Impl::maybeFromVoigt(Eraw);
162 initUnknownStrains(E);
164 std::array<size_t, fixedDiagonalVoigtIndicesSize> fixedDiagonalVoigtIndices;
167 if (indexPair[0] == indexPair[1])
168 fixedDiagonalVoigtIndices[ri++] = i;
171 auto f = [&](
auto&) {
172 auto S = matImpl_.template stresses<Underlying::strainTag, true>(E);
173 return S(fixedDiagonalVoigtIndices).eval();
175 auto df = [&](
auto&) {
176 auto moduli = (matImpl_.template tangentModuli<Underlying::strainTag, true>(E)).eval();
177 return (moduli(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices) / Underlying::derivativeFactor).eval();
180 auto Er = E(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices).eval().template cast<ScalarType>();
183 auto linearSolver = [](
auto& r,
auto& A) {
return (A.inverse() * r).eval(); };
184 auto updateFunction = [&](
auto& ,
auto& ecomps) {
185 for (
int ri = 0;
auto i : fixedDiagonalVoigtIndices) {
187 E(indexPair[0], indexPair[1]) += ecomps(ri++);
193 NewtonRaphsonConfig<
decltype(linearSolver),
decltype(updateFunction)> nrs{
194 .parameters = {.tol = tol_, .maxIter = 100, .minIter = minIter},
195 .linearSolver = linearSolver,
196 .updateFunction = updateFunction
200 if (!
static_cast<bool>(nr->solve()))
201 DUNE_THROW(Dune::MathError,
"The stress reduction of material " <<
nameImpl() <<
" was unsuccessful\n"
202 <<
"The strains are\n"
203 << E <<
"\n The stresses are\n"
205 return std::make_pair(nonOp, E);
220template <Impl::MatrixIndexPair... stressIndexPair,
typename MaterialImpl>
222 return VanishingStress<std::to_array({stressIndexPair...}), MaterialImpl>(mat, p_tol);
232template <
typename MaterialImpl>
233auto planeStress(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
234 return makeVanishingStress<Impl::MatrixIndexPair{2, 1}, Impl::MatrixIndexPair{2, 0}, Impl::MatrixIndexPair{2, 2}>(
246template <
typename MaterialImpl>
247auto shellMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
259template <
typename MaterialImpl>
260auto beamMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
261 return makeVanishingStress<Impl::MatrixIndexPair{1, 1}, Impl::MatrixIndexPair{2, 2}>(mat, tol);
Provides a NonLinearOperator class for handling nonlinear operators.
Contains the generic NonlinearSolverFactory class.
Implementation of the Newton-Raphson method for solving nonlinear equations.
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:271
Definition: assemblermanipulatorbuildingblocks.hh:22
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:221
::value auto createNonlinearSolver(NRConfig &&config, NLO &&nonLinearOperator)
Function to create a NewtonRaphson solver instance.
Definition: newtonraphson.hh:65
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:247
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:260
auto functions(Args &&... args)
Creates a Functions object.
Definition: nonlinearoperator.hh:127
NonLinearOperator(const Impl::Functions< DerivativeArgs &&... > &a, const Impl::Parameter< ParameterArgs... > &b) -> NonLinearOperator< Impl::Functions< DerivativeArgs... >, Impl::Parameter< ParameterArgs... > >
auto parameter(Args &&... args)
Creates a Parameter object.
Definition: nonlinearoperator.hh:115
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:233
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:80
VanishingStress material model that enforces stress components to be zero.
Definition: vanishingstress.hh:30
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstress.hh:45
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstress.hh:128
static constexpr double derivativeFactorImpl
Derivative factor.
Definition: vanishingstress.hh:51
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstress.hh:34
static constexpr std::string nameImpl() noexcept
Definition: vanishingstress.hh:62
typename Underlying::MaterialParameters MaterialParameters
Definition: vanishingstress.hh:32
VanishingStress(MI mat, typename MI::ScalarType tol=1e-12)
Constructor for VanishingStress.
Definition: vanishingstress.hh:58
static constexpr auto strainTag
Strain tag.
Definition: vanishingstress.hh:43
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstress.hh:35
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: vanishingstress.hh:73
static constexpr bool isAutoDiff
Definition: vanishingstress.hh:41
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstress.hh:46
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStress material.
Definition: vanishingstress.hh:82
MI Underlying
The underlying material type.
Definition: vanishingstress.hh:31
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStress material.
Definition: vanishingstress.hh:95
typename Underlying::ScalarType ScalarType
Scalar type.
Definition: vanishingstress.hh:40
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstress.hh:49
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstress.hh:47
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStress material.
Definition: vanishingstress.hh:113
static constexpr auto fixedDiagonalVoigtIndicesSize
Number of fixed diagonal indices.
Definition: vanishingstress.hh:37
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstress.hh:39
static constexpr auto stressTag
Stress tag.
Definition: vanishingstress.hh:44
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstress.hh:48
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstress.hh:36
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstress.hh:50
Concept to check if the underlying scalar type is a dual type.
Definition: concepts.hh:608
Contains the Material interface class and related template functions for material properties.