version 0.4.2
numericalmaterialinversion.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2025 The Ikarus Developers ikarus@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11
16
17namespace Ikarus::Materials {
18
33template <Concepts::Material Material, typename Derived>
34auto numericalMaterialInversion(const Material& mat, const Eigen::MatrixBase<Derived>& S,
35 const Eigen::MatrixBase<Derived>& Estart = Derived::Zero().eval(),
36 const double tol = 1e-12, const int maxIter = 20) {
37 static_assert(Concepts::EigenMatrix33<decltype(S)> or Concepts::EigenMatrix22<decltype(S)>);
40
41 constexpr int dim = Derived::CompileTimeTraits::RowsAtCompileTime;
42 constexpr int dimVoigt = (dim * (dim + 1)) / 2;
43 constexpr auto strainTag =
45
46 using ST = Derived::Scalar;
47 using VoigtVec = Eigen::Vector<ST, dimVoigt>;
48
49 VoigtVec Es = toVoigt(Estart.derived()); // starting value
50 VoigtVec Svoigt = toVoigt(S.derived(), false);
51
52 auto r = VoigtVec::Zero().eval();
53 auto D = Eigen::Matrix<ST, dimVoigt, dimVoigt>::Zero().eval();
54
55 for (auto i : Dune::range(maxIter)) {
56 r = (Svoigt - mat.template stresses<strainTag, true>(Es)).eval();
57
58 if (r.norm() < tol and i > 0)
59 break;
60 else if (i == maxIter)
61 DUNE_THROW(
62 Dune::MathError,
63 "Numerical material inversion failed to converge within the maximum number of iterations for the material: " +
64 mat.name());
65
66 D = mat.template tangentModuli<strainTag, true>(Es).inverse().eval(); // voigt
67 Es += (D * r).eval();
68 }
69 return std::make_pair(D, transformStrain<strainTag, Material::strainTag>(Es).eval());
70}
71
72} // namespace Ikarus::Materials
Helper for the Eigen::Tensor types.
Implementation of transformations for different strain measures.
helper functions used by material model implementations.
constexpr Eigen::Index toVoigt(Eigen::Index i, Eigen::Index j) noexcept
Converts 2D indices to Voigt notation index.
Definition: tensorutils.hh:182
Definition: arrudaboyce.hh:27
auto numericalMaterialInversion(const Material &mat, const Eigen::MatrixBase< Derived > &S, const Eigen::MatrixBase< Derived > &Estart=Derived::Zero().eval(), const double tol=1e-12, const int maxIter=20)
Computes numerically an approximation of the complementary strain energy function and returns the mat...
Definition: numericalmaterialinversion.hh:34
Interface classf or materials.
Definition: finiteelements/mechanics/materials/interface.hh:82
static constexpr std::string name()
Get the name of the implemented material.
Definition: finiteelements/mechanics/materials/interface.hh:112
Returns true if a given straintag is related only to the reference configuration.
Definition: utils/concepts.hh:677
Returns true if a given stresstag is related only to the reference configuration.
Definition: utils/concepts.hh:684
Contains the Material interface class and related template functions for material properties.