25    struct StressIndexPair {
 
   36    template <
size_t size>
 
   37    consteval auto createfreeVoigtIndices(
const std::array<StressIndexPair, size>& fixed) {
 
   38      std::array<size_t, 6 - size> res{};
 
   39      std::array<size_t, size> voigtFixedIndices;
 
   40      std::ranges::transform(fixed, voigtFixedIndices.begin(), [](
auto pair) { return toVoigt(pair.row, pair.col); });
 
   41      std::ranges::sort(voigtFixedIndices);
 
   42      std::ranges::set_difference(std::ranges::iota_view(
size_t(0), 
size_t(6)), voigtFixedIndices, res.begin());
 
   43      std::ranges::sort(res);
 
   53    template <
size_t size>
 
   54    consteval auto createFixedVoigtIndices(
const std::array<StressIndexPair, size>& fixed) {
 
   55      std::array<size_t, size> fixedIndices;
 
   56      std::ranges::transform(fixed, fixedIndices.begin(), [](
auto pair) { return toVoigt(pair.row, pair.col); });
 
   57      std::ranges::sort(fixedIndices);
 
   67    template <
size_t size>
 
   68    constexpr size_t countDiagonalIndices(
const std::array<StressIndexPair, size>& fixed) {
 
   70      for (
auto v : fixed) {
 
   71        if (v.col == v.row) ++count;
 
   84  template <auto stressIndexPair, 
typename MaterialImpl>
 
   91    explicit VanishingStress(MaterialImpl mat, 
typename MaterialImpl::ScalarType p_tol = 1e-12)
 
   92        : matImpl{mat}, tol{p_tol} {}
 
  104    [[nodiscard]] 
constexpr std::string 
nameImpl() const noexcept {
 
  105      auto matName = matImpl.name() + 
"_Vanishing(";
 
  107        matName += 
"(" + std::to_string(p.row) + std::to_string(p.col) + 
")";
 
  112    static constexpr auto strainTag          = MaterialImpl::strainTag;           
 
  113    static constexpr auto stressTag          = MaterialImpl::stressTag;           
 
  128    template <
typename Derived>
 
  130      const auto [nonOp, Esol] = reduceStress(E);
 
  131      return matImpl.storedEnergyImpl(Esol);
 
  141    template <
bool voigt, 
typename Derived>
 
  143      const auto [nonOp, Esol] = reduceStress(E);
 
  144      auto stressesRed         = matImpl.template stresses<MaterialImpl::strainTag, true>(Esol);
 
  146      if constexpr (voigt) {
 
  159    template <
bool voigt, 
typename Derived>
 
  161      const auto [nonOp, Esol] = reduceStress(E);
 
  162      auto C                   = matImpl.template tangentModuli<MaterialImpl::strainTag, true>(Esol);
 
  174    template <
typename ScalarTypeOther>
 
  176      auto reboundMatImpl = matImpl.template rebind<ScalarTypeOther>();
 
  187    template <
typename Derived>
 
  188    decltype(
auto) maybeFromVoigt(
const Eigen::MatrixBase<Derived>& E) 
const {
 
  200    template <
typename Derived>
 
  201    void initUnknownStrains(Eigen::MatrixBase<Derived>& E)
 const {
 
  202      for (
size_t i = 0; i < 
fixedPairs.size(); ++i) {
 
  219    template <
typename Derived>
 
  220    auto reduceStress(
const Eigen::MatrixBase<Derived>& p_Eraw)
 const {
 
  221      auto E = maybeFromVoigt(p_Eraw);
 
  222      initUnknownStrains(E);
 
  224      std::array<size_t, fixedDiagonalVoigtIndicesSize> fixedDiagonalVoigtIndices;
 
  227        if (indexPair[0] == indexPair[1]) fixedDiagonalVoigtIndices[ri++] = i;
 
  230      auto f = [&](
auto&) {
 
  231        auto S = matImpl.template stresses<MaterialImpl::strainTag, true>(E);
 
  232        return S(fixedDiagonalVoigtIndices).eval();
 
  234      auto df = [&](
auto&) {
 
  235        auto moduli = (matImpl.template tangentModuli<MaterialImpl::strainTag, true>(E)).eval();
 
  236        return (moduli(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices) / MaterialImpl::derivativeFactor).eval();
 
  239      auto Er    = E(fixedDiagonalVoigtIndices, fixedDiagonalVoigtIndices).eval().template cast<ScalarType>();
 
  242             nonOp, [&](
auto& r, 
auto& A) { 
return (A.inverse() * r).eval(); },
 
  243             [&](
auto& , 
auto& Ecomps) {
 
  244            for (
int ri = 0; 
auto i : fixedDiagonalVoigtIndices) {
 
  246              E(indexPair[0], indexPair[1]) += Ecomps(ri++);
 
  249      nr->setup({.tol = tol, .maxIter = 100});
 
  250      if (!
static_cast<bool>(nr->solve()))
 
  251        DUNE_THROW(Dune::MathError, 
"The stress reduction of material " << 
nameImpl() << 
" was unsuccessful\n" 
  252                                                                        << 
"The strains are\n" 
  253                                                                        << E << 
"\n The stresses are\n" 
  255      return std::make_pair(nonOp, E);
 
  258    MaterialImpl matImpl;  
 
  270  template <Impl::StressIndexPair... stressIndexPair, 
typename MaterialImpl>
 
  272    return VanishingStress<std::to_array({stressIndexPair...}), MaterialImpl>(mat, p_tol);
 
  282  template <
typename MaterialImpl>
 
  283  auto planeStress(
const MaterialImpl& mat, 
typename MaterialImpl::ScalarType p_tol = 1e-8) {
 
  284    return makeVanishingStress<Impl::StressIndexPair{2, 1}, Impl::StressIndexPair{2, 0}, Impl::StressIndexPair{2, 2}>(
 
  296  template <
typename MaterialImpl>
 
  297  auto shellMaterial(
const MaterialImpl& mat, 
typename MaterialImpl::ScalarType p_tol = 1e-8) {
 
  309  template <
typename MaterialImpl>
 
  310  auto beamMaterial(
const MaterialImpl& mat, 
typename MaterialImpl::ScalarType p_tol = 1e-8) {
 
  311    return makeVanishingStress<Impl::StressIndexPair{1, 1}, Impl::StressIndexPair{2, 2}>(mat, p_tol);
 
Provides a NonLinearOperator class for handling nonlinear operators.
 
Contains the Material interface class and related template functions for material properties.
 
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:495
 
auto removeCol(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfRemovedCols > &indices)
Removes specified columns from a matrix.
Definition: linearalgebrahelper.hh:523
 
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:21
 
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:271
 
auto makeNewtonRaphson(const NonLinearOperatorImpl &p_nonLinearOperator, LinearSolver &&p_linearSolver={}, UpdateFunctionType &&p_updateFunction={})
Function to create a NewtonRaphson solver instance.
Definition: newtonraphson.hh:156
 
auto shellMaterial(const MaterialImpl &mat, typename MaterialImpl::ScalarType p_tol=1e-8)
Factory function to create a VanishingStress material for a shell material with zero normal stress co...
Definition: vanishingstress.hh:297
 
auto planeStress(const MaterialImpl &mat, typename MaterialImpl::ScalarType p_tol=1e-8)
Factory function to create a VanishingStress material for plane stress conditions.
Definition: vanishingstress.hh:283
 
auto beamMaterial(const MaterialImpl &mat, typename MaterialImpl::ScalarType p_tol=1e-8)
Factory function to create a VanishingStress material for a beam material with two zero normal stress...
Definition: vanishingstress.hh:310
 
auto functions(Args &&... args)
Creates a Functions object.
Definition: nonlinearoperator.hh:126
 
auto parameter(Args &&... args)
Creates a Parameter object.
Definition: nonlinearoperator.hh:114
 
Interface classf or materials.
Definition: interface.hh:75
 
VanishingStress material model that enforces stress components to be zero.
Definition: vanishingstress.hh:85
 
typename MaterialImpl::ScalarType ScalarType
Scalar type.
Definition: vanishingstress.hh:102
 
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStress material.
Definition: vanishingstress.hh:142
 
static constexpr auto strainTag
Strain tag.
Definition: vanishingstress.hh:112
 
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstress.hh:98
 
static constexpr auto stressTag
Stress tag.
Definition: vanishingstress.hh:113
 
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstress.hh:116
 
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstress.hh:97
 
constexpr std::string nameImpl() const noexcept
Definition: vanishingstress.hh:104
 
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstress.hh:101
 
static constexpr auto fixedDiagonalVoigtIndicesSize
Number of fixed diagonal indices.
Definition: vanishingstress.hh:100
 
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStress material.
Definition: vanishingstress.hh:160
 
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstress.hh:119
 
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstress.hh:115
 
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstress.hh:96
 
static constexpr double derivativeFactor
Derivative factor.
Definition: vanishingstress.hh:120
 
VanishingStress(MaterialImpl mat, typename MaterialImpl::ScalarType p_tol=1e-12)
Constructor for VanishingStress.
Definition: vanishingstress.hh:91
 
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStress material.
Definition: vanishingstress.hh:129
 
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstress.hh:118
 
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstress.hh:175
 
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstress.hh:114
 
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstress.hh:117
 
MaterialImpl Underlying
The underlying material type.
Definition: vanishingstress.hh:94
 
Represents a NonLinearOperator class for handling nonlinear operators.
Definition: nonlinearoperator.hh:154
 
Concept defining the requirements for Eigen vectors.
Definition: concepts.hh:381