25 struct StressIndexPair
37 template <
size_t size>
38 consteval auto createfreeVoigtIndices(
const std::array<StressIndexPair, size>& fixed) {
39 std::array<size_t, 6 - size> res{};
40 std::array<size_t, size> voigtFixedIndices;
41 std::ranges::transform(fixed, voigtFixedIndices.begin(), [](
auto pair) { return toVoigt(pair.row, pair.col); });
42 std::ranges::sort(voigtFixedIndices);
43 std::ranges::set_difference(std::ranges::iota_view(
size_t(0),
size_t(6)), voigtFixedIndices, res.begin());
44 std::ranges::sort(res);
54 template <
size_t size>
55 consteval auto createFixedVoigtIndices(
const std::array<StressIndexPair, size>& fixed) {
56 std::array<size_t, size> fixedIndices;
57 std::ranges::transform(fixed, fixedIndices.begin(), [](
auto pair) { return toVoigt(pair.row, pair.col); });
58 std::ranges::sort(fixedIndices);
68 template <
size_t size>
69 constexpr size_t countDiagonalIndices(
const std::array<StressIndexPair, size>& fixed) {
71 for (
auto v : fixed) {
86template <auto stressIndexPair,
typename MI>
108 [[nodiscard]]
constexpr std::string
nameImpl() const noexcept {
109 auto matName = matImpl_.name() +
"_Vanishing(";
111 matName +=
"(" + std::to_string(p.row) + std::to_string(p.col) +
")";
116 static constexpr auto strainTag = Underlying::strainTag;
117 static constexpr auto stressTag = Underlying::stressTag;
132 template <
typename Derived>
134 const auto [nonOp, Esol] = reduceStress(E);
135 return matImpl_.storedEnergyImpl(Esol);
145 template <
bool voigt,
typename Derived>
147 const auto [nonOp, Esol] = reduceStress(E);
148 auto stressesRed = matImpl_.template stresses<Underlying::strainTag, true>(Esol);
150 if constexpr (voigt) {
163 template <
bool voigt,
typename Derived>
165 const auto [nonOp, Esol] = reduceStress(E);
166 auto C = matImpl_.template tangentModuli<Underlying::strainTag, true>(Esol);
178 template <
typename ScalarTypeOther>
180 auto reboundMatImpl = matImpl_.template rebind<ScalarTypeOther>();
191 template <
typename Derived>
192 decltype(
auto) maybeFromVoigt(
const Eigen::MatrixBase<Derived>& E)
const {
204 template <
typename Derived>
205 void initUnknownStrains(Eigen::MatrixBase<Derived>& E)
const {
206 for (
size_t i = 0; i <
fixedPairs.size(); ++i) {
224 template <
typename Derived>
225 auto reduceStress(
const Eigen::MatrixBase<Derived>& Eraw)
const {
226 auto E = maybeFromVoigt(Eraw);
227 initUnknownStrains(E);
229 std::array<size_t, fixedDiagonalVoigtIndicesSize> fixedDiagonalVoigtIndices;
232 if (indexPair[0] == indexPair[1])
233 fixedDiagonalVoigtIndices[ri++] = i;
236 auto f = [&](
auto&) {
237 auto S = matImpl_.template stresses<Underlying::strainTag, true>(E);
238 return S(fixedDiagonalVoigtIndices).eval();
240 auto df = [&](
auto&) {
241 auto moduli = (matImpl_.template tangentModuli<Underlying::strainTag, true>(E)).eval();
242 return (moduli(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices) / Underlying::derivativeFactor).eval();
245 auto Er = E(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices).eval().template cast<ScalarType>();
248 nonOp, [&](
auto& r,
auto& A) {
return (A.inverse() * r).eval(); },
249 [&](
auto& ,
auto& ecomps) {
250 for (
int ri = 0;
auto i : fixedDiagonalVoigtIndices) {
252 E(indexPair[0], indexPair[1]) += ecomps(ri++);
255 nr->setup({.tol = tol_, .maxIter = 100});
256 if (!
static_cast<bool>(nr->solve()))
257 DUNE_THROW(Dune::MathError,
"The stress reduction of material " <<
nameImpl() <<
" was unsuccessful\n"
258 <<
"The strains are\n"
259 << E <<
"\n The stresses are\n"
261 return std::make_pair(nonOp, E);
276template <Impl::StressIndexPair... stressIndexPair,
typename MaterialImpl>
278 return VanishingStress<std::to_array({stressIndexPair...}), MaterialImpl>(mat, p_tol);
288template <
typename MaterialImpl>
289auto planeStress(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
290 return makeVanishingStress<Impl::StressIndexPair{2, 1}, Impl::StressIndexPair{2, 0}, Impl::StressIndexPair{2, 2}>(
302template <
typename MaterialImpl>
303auto shellMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
315template <
typename MaterialImpl>
316auto beamMaterial(
const MaterialImpl& mat,
typename MaterialImpl::ScalarType tol = 1e-8) {
317 return makeVanishingStress<Impl::StressIndexPair{1, 1}, Impl::StressIndexPair{2, 2}>(mat, tol);
Provides a NonLinearOperator class for handling nonlinear operators.
Implementation of the Newton-Raphson method for solving nonlinear equations.
Contains the Material interface class and related template functions for material properties.
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:526
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
Definition: simpleassemblers.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:277
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:303
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:316
auto functions(Args &&... args)
Creates a Functions object.
Definition: nonlinearoperator.hh:127
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:289
auto makeNewtonRaphson(const NLO &nonLinearOperator, LS &&linearSolver={}, UF &&updateFunction={})
Function to create a NewtonRaphson solver instance.
Definition: newtonraphson.hh:161
Interface classf or materials.
Definition: interface.hh:77
VanishingStress material model that enforces stress components to be zero.
Definition: vanishingstress.hh:88
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstress.hh:118
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstress.hh:179
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstress.hh:100
static constexpr double derivativeFactor
Derivative factor.
Definition: vanishingstress.hh:124
VanishingStress(MI mat, typename MI::ScalarType tol=1e-12)
Constructor for VanishingStress.
Definition: vanishingstress.hh:94
static constexpr auto strainTag
Strain tag.
Definition: vanishingstress.hh:116
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstress.hh:101
constexpr std::string nameImpl() const noexcept
Definition: vanishingstress.hh:108
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstress.hh:119
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStress material.
Definition: vanishingstress.hh:133
MI Underlying
The underlying material type.
Definition: vanishingstress.hh:98
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStress material.
Definition: vanishingstress.hh:146
typename Underlying::ScalarType ScalarType
Scalar type.
Definition: vanishingstress.hh:106
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstress.hh:122
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstress.hh:120
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStress material.
Definition: vanishingstress.hh:164
static constexpr auto fixedDiagonalVoigtIndicesSize
Number of fixed diagonal indices.
Definition: vanishingstress.hh:103
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstress.hh:105
static constexpr auto stressTag
Stress tag.
Definition: vanishingstress.hh:117
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstress.hh:121
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstress.hh:102
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstress.hh:123
Represents a NonLinearOperator class for handling nonlinear operators.
Definition: nonlinearoperator.hh:156
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:353