version 0.4.1
vanishingstrain.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11
12#include "materialhelpers.hh"
13
18
19namespace Ikarus::Materials {
20
27template <auto strainIndexPair, typename MI>
28struct VanishingStrain : public Material<VanishingStrain<strainIndexPair, MI>>
29{
30 using Underlying = MI;
31 using ScalarType = typename Underlying::ScalarType;
32 using MaterialParameters = typename Underlying::MaterialParameters;
33 using StrainMatrix = typename Underlying::StrainMatrix;
34 using StressMatrix = typename Underlying::StressMatrix;
35 using MaterialTensor = typename Underlying::MaterialTensor;
36 static constexpr int dim = Underlying::dim;
37
38 static constexpr auto fixedPairs = strainIndexPair;
39 static constexpr auto freeVoigtIndices = Impl::createfreeVoigtIndices(fixedPairs);
40 static constexpr auto fixedVoigtIndices = Impl::createFixedVoigtIndices(fixedPairs);
41 static constexpr auto freeStrains = freeVoigtIndices.size();
42
43 static constexpr auto strainTag = Underlying::strainTag;
44 static constexpr auto stressTag = Underlying::stressTag;
45 static constexpr auto tangentModuliTag = Underlying::tangentModuliTag;
46 static constexpr bool energyAcceptsVoigt = Underlying::energyAcceptsVoigt;
47 static constexpr bool stressToVoigt = true;
48 static constexpr bool stressAcceptsVoigt = true;
49 static constexpr bool moduliToVoigt = true;
50 static constexpr bool moduliAcceptsVoigt = true;
51 static constexpr double derivativeFactorImpl = Underlying::derivativeFactorImpl;
52
57 explicit VanishingStrain(MI mat)
58 : matImpl_{mat} {}
59
60 [[nodiscard]] constexpr static std::string nameImpl() noexcept {
61 auto matName = MI::name() + "_VanishingStrain(";
62 for (auto p : fixedPairs)
63 matName += "(" + std::to_string(p.row) + std::to_string(p.col) + ")";
64 matName += ")";
65 return matName;
66 }
67
71 MaterialParameters materialParametersImpl() const { return matImpl_.materialParametersImpl(); }
72
79 template <typename Derived>
80 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
81 const auto Esol = reduceStrain(E);
82 return matImpl_.storedEnergyImpl(Esol);
83 }
84
92 template <bool voigt, typename Derived>
93 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
94 const auto Esol = reduceStrain(E);
95 auto stressesRed = matImpl_.template stresses<Underlying::strainTag, true>(Esol);
96
97 if constexpr (voigt) {
98 return removeCol(stressesRed, fixedVoigtIndices);
99 } else {
100 stressesRed(fixedVoigtIndices).setZero();
101 return fromVoigt(stressesRed, false);
102 }
103 }
104
112 template <bool voigt, typename Derived>
113 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& E) const {
114 const auto Esol = reduceStrain(E);
115 auto C = matImpl_.template tangentModuli<Underlying::strainTag, true>(Esol);
116 if constexpr (voigt)
118 else
119 return fromVoigt(C);
120 }
121
127 template <typename ScalarTypeOther>
128 auto rebind() const {
129 auto reboundMatImpl = matImpl_.template rebind<ScalarTypeOther>();
131 }
132
136 auto& underlying() const { return matImpl_; }
137
138private:
139 Underlying matImpl_;
140
147 template <typename Derived>
148 auto reduceStrain(const Eigen::MatrixBase<Derived>& Eraw) const {
150 Eigen::Matrix3<ScalarType> E = Impl::maybeFromVoigt(Eraw);
151 setStrainsToZero(E);
152 return E;
153 } else {
154 decltype(auto) E = Impl::maybeFromVoigt(Eraw);
155 Eigen::Matrix3<ScalarType> Egl = transformStrain<strainTag, StrainTags::greenLagrangian>(E);
156 setStrainsToZero(Egl);
157 return transformStrain<StrainTags::greenLagrangian, strainTag>(Egl).derived();
158 }
159 }
163 inline void setStrainsToZero(auto& E) const {
164 for (auto [i, j] : fixedPairs) {
165 E(i, j) = 0;
166 E(j, i) = 0;
167 }
168 }
169};
170
179template <MatrixIndexPair... stressIndexPair, typename MaterialImpl>
180auto makeVanishingStrain(MaterialImpl mat) {
181 return VanishingStrain<std::to_array({stressIndexPair...}), MaterialImpl>(mat);
182}
183
196template <typename MaterialImpl>
197auto planeStrain(const MaterialImpl& mat) {
199}
200} // namespace Ikarus::Materials
Provides a NonLinearOperator class for handling nonlinear operators.
Implementation of the Newton-Raphson method for solving nonlinear equations.
Implementation of strain-related functions.
helper functions used by material model implementations.
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:284
auto reduceMatrix(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfCondensedIndices > &indices)
Definition: linearalgebrahelper.hh:514
Definition: arrudaboyce.hh:27
auto makeVanishingStrain(MaterialImpl mat)
Factory function to create a VanishingStrain material with specified strain indices.
Definition: vanishingstrain.hh:180
auto planeStrain(const MaterialImpl &mat)
Factory function to create a VanishingStrain material for plane strain conditions.
Definition: vanishingstrain.hh:197
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:80
Represents a pair of stress or strain matrix indices (row and column).
Definition: materialhelpers.hh:26
VanishingStrain material model that enforces strain components to be zero.
Definition: vanishingstrain.hh:29
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: vanishingstrain.hh:71
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstrain.hh:47
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStrain material.
Definition: vanishingstrain.hh:80
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstrain.hh:41
static constexpr std::string nameImpl() noexcept
Definition: vanishingstrain.hh:60
static constexpr auto strainTag
Strain tag.
Definition: vanishingstrain.hh:43
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstrain.hh:46
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstrain.hh:45
VanishingStrain(MI mat)
Constructor for VanishingStrain.
Definition: vanishingstrain.hh:57
typename Underlying::StressMatrix StressMatrix
Definition: vanishingstrain.hh:34
static constexpr int dim
Definition: vanishingstrain.hh:36
auto & underlying() const
Returns a const reference to the underlying material.
Definition: vanishingstrain.hh:136
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstrain.hh:40
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStrain material.
Definition: vanishingstrain.hh:93
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStrain material.
Definition: vanishingstrain.hh:113
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstrain.hh:49
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstrain.hh:48
typename Underlying::StrainMatrix StrainMatrix
Definition: vanishingstrain.hh:33
static constexpr double derivativeFactorImpl
Derivative factor.
Definition: vanishingstrain.hh:51
typename Underlying::MaterialTensor MaterialTensor
Definition: vanishingstrain.hh:35
static constexpr auto stressTag
Stress tag.
Definition: vanishingstrain.hh:44
MI Underlying
The underlying material type.
Definition: vanishingstrain.hh:30
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstrain.hh:128
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstrain.hh:39
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstrain.hh:38
typename Underlying::ScalarType ScalarType
Scalar type.
Definition: vanishingstrain.hh:31
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstrain.hh:50
typename Underlying::MaterialParameters MaterialParameters
Definition: vanishingstrain.hh:32
Contains the Material interface class and related template functions for material properties.