version 0.4.1
vanishingstrain.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11
12#include "vanishinghelpers.hh"
13
18
19namespace Ikarus {
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
34 static constexpr auto fixedPairs = strainIndexPair;
35 static constexpr auto freeVoigtIndices = createfreeVoigtIndices(fixedPairs);
36 static constexpr auto fixedVoigtIndices = createFixedVoigtIndices(fixedPairs);
37 static constexpr auto freeStrains = freeVoigtIndices.size();
38
39 static constexpr auto strainTag = Underlying::strainTag;
40 static constexpr auto stressTag = Underlying::stressTag;
41 static constexpr auto tangentModuliTag = Underlying::tangentModuliTag;
42 static constexpr bool energyAcceptsVoigt = Underlying::energyAcceptsVoigt;
43 static constexpr bool stressToVoigt = true;
44 static constexpr bool stressAcceptsVoigt = true;
45 static constexpr bool moduliToVoigt = true;
46 static constexpr bool moduliAcceptsVoigt = true;
47 static constexpr double derivativeFactorImpl = Underlying::derivativeFactorImpl;
48
53 explicit VanishingStrain(MI mat)
54 : matImpl_{mat} {}
55
56 [[nodiscard]] constexpr static std::string nameImpl() noexcept {
57 auto matName = MI::name() + "_VanishingStrain(";
58 for (auto p : fixedPairs)
59 matName += "(" + std::to_string(p.row) + std::to_string(p.col) + ")";
60 matName += ")";
61 return matName;
62 }
63
67 MaterialParameters materialParametersImpl() const { return matImpl_.materialParametersImpl(); }
68
75 template <typename Derived>
76 ScalarType storedEnergyImpl(const Eigen::MatrixBase<Derived>& E) const {
77 const auto Esol = reduceStrain(E);
78 return matImpl_.storedEnergyImpl(Esol);
79 }
80
88 template <bool voigt, typename Derived>
89 auto stressesImpl(const Eigen::MatrixBase<Derived>& E) const {
90 const auto Esol = reduceStrain(E);
91 auto stressesRed = matImpl_.template stresses<Underlying::strainTag, true>(Esol);
92
93 if constexpr (voigt) {
94 return removeCol(stressesRed, fixedVoigtIndices);
95 } else {
96 stressesRed(fixedVoigtIndices).setZero();
97 return fromVoigt(stressesRed, false);
98 }
99 }
100
108 template <bool voigt, typename Derived>
109 auto tangentModuliImpl(const Eigen::MatrixBase<Derived>& E) const {
110 const auto Esol = reduceStrain(E);
111 auto C = matImpl_.template tangentModuli<Underlying::strainTag, true>(Esol);
112 if constexpr (voigt)
114 else
115 return fromVoigt(C);
116 }
117
123 template <typename ScalarTypeOther>
124 auto rebind() const {
125 auto reboundMatImpl = matImpl_.template rebind<ScalarTypeOther>();
127 }
128
129private:
130 Underlying matImpl_;
131
138 template <typename Derived>
139 auto reduceStrain(const Eigen::MatrixBase<Derived>& Eraw) const {
141 Eigen::Matrix3<ScalarType> E = Impl::maybeFromVoigt(Eraw);
142 setStrainsToZero(E);
143 return E;
144 } else {
145 decltype(auto) E = Impl::maybeFromVoigt(Eraw);
146 Eigen::Matrix3<ScalarType> Egl = transformStrain<strainTag, StrainTags::greenLagrangian>(E);
147 setStrainsToZero(Egl);
148 return transformStrain<StrainTags::greenLagrangian, strainTag>(Egl).derived();
149 }
150 }
154 inline void setStrainsToZero(auto& E) const {
155 for (auto [i, j] : fixedPairs) {
156 E(i, j) = 0;
157 E(j, i) = 0;
158 }
159 }
160};
161
170template <Impl::MatrixIndexPair... stressIndexPair, typename MaterialImpl>
171auto makeVanishingStrain(MaterialImpl mat) {
172 return VanishingStrain<std::to_array({stressIndexPair...}), MaterialImpl>(mat);
173}
174
187template <typename MaterialImpl>
188auto planeStrain(const MaterialImpl& mat) {
189 return makeVanishingStrain<Impl::MatrixIndexPair{2, 1}, Impl::MatrixIndexPair{2, 0}, Impl::MatrixIndexPair{2, 2}>(
190 mat);
191}
192} // namespace Ikarus
Provides a NonLinearOperator class for handling nonlinear operators.
Implementation of the Newton-Raphson method for solving nonlinear equations.
Implementation of strain-related functions.
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 planeStrain(const MaterialImpl &mat)
Factory function to create a VanishingStrain material for plane strain conditions.
Definition: vanishingstrain.hh:188
auto makeVanishingStrain(MaterialImpl mat)
Factory function to create a VanishingStrain material with specified strain indices.
Definition: vanishingstrain.hh:171
auto reduceMatrix(const Eigen::MatrixBase< Derived > &E, const std::array< size_t, sizeOfCondensedIndices > &indices)
Definition: linearalgebrahelper.hh:514
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:80
VanishingStrain material model that enforces strain components to be zero.
Definition: vanishingstrain.hh:29
typename Underlying::MaterialParameters MaterialParameters
Definition: vanishingstrain.hh:32
static constexpr bool stressAcceptsVoigt
Stress accepts Voigt notation.
Definition: vanishingstrain.hh:44
static constexpr double derivativeFactorImpl
Derivative factor.
Definition: vanishingstrain.hh:47
static constexpr bool moduliToVoigt
Moduli to Voigt notation.
Definition: vanishingstrain.hh:45
MI Underlying
The underlying material type.
Definition: vanishingstrain.hh:30
static constexpr auto fixedVoigtIndices
Fixed Voigt indices.
Definition: vanishingstrain.hh:36
static constexpr auto stressTag
Stress tag.
Definition: vanishingstrain.hh:40
static constexpr std::string nameImpl() noexcept
Definition: vanishingstrain.hh:56
VanishingStrain(MI mat)
Constructor for VanishingStrain.
Definition: vanishingstrain.hh:53
static constexpr auto freeStrains
Number of free strains.
Definition: vanishingstrain.hh:37
static constexpr auto strainTag
Strain tag.
Definition: vanishingstrain.hh:39
static constexpr bool energyAcceptsVoigt
Energy accepts Voigt notation.
Definition: vanishingstrain.hh:42
typename Underlying::ScalarType ScalarType
Scalar type.
Definition: vanishingstrain.hh:31
static constexpr auto fixedPairs
Array of fixed stress components.
Definition: vanishingstrain.hh:34
auto tangentModuliImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the tangent moduli for the VanishingStrain material.
Definition: vanishingstrain.hh:109
static constexpr auto freeVoigtIndices
Free Voigt indices.
Definition: vanishingstrain.hh:35
static constexpr bool moduliAcceptsVoigt
Moduli accepts Voigt notation.
Definition: vanishingstrain.hh:46
MaterialParameters materialParametersImpl() const
Returns the material parameters stored in the material.
Definition: vanishingstrain.hh:67
auto rebind() const
Rebinds the material to a different scalar type.
Definition: vanishingstrain.hh:124
ScalarType storedEnergyImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stored energy for the VanishingStrain material.
Definition: vanishingstrain.hh:76
static constexpr auto tangentModuliTag
Tangent moduli tag.
Definition: vanishingstrain.hh:41
static constexpr bool stressToVoigt
Stress to Voigt notation.
Definition: vanishingstrain.hh:43
auto stressesImpl(const Eigen::MatrixBase< Derived > &E) const
Computes the stresses for the VanishingStrain material.
Definition: vanishingstrain.hh:89
Contains the Material interface class and related template functions for material properties.