version 0.4.2
strainconversions.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
11#pragma once
12#include "tags.hh"
13
14#include <unsupported/Eigen/MatrixFunctions>
15
16#include <Eigen/Core>
17
20
21namespace Ikarus {
22
33template <StrainTags tag, typename Derived>
34Derived createGreenLagrangianStrains(const Eigen::MatrixBase<Derived>& eMB) {
35 const auto& e = eMB.derived();
36
37 static_assert(Concepts::EigenMatrix33<Derived> or Concepts::EigenMatrix22<Derived>);
38 if constexpr (tag == StrainTags::greenLagrangian)
39 return e;
40 else if constexpr (tag == StrainTags::deformationGradient)
41 return 0.5 * (e.transpose() * e - Derived::Identity());
42 else if constexpr (tag == StrainTags::displacementGradient)
43 return 0.5 * (e + e.transpose() + e.transpose() * e);
44 else if constexpr (tag == StrainTags::rightCauchyGreenTensor)
45 return 0.5 * (e - Derived::Identity());
46}
47
58template <StrainTags tag, typename Derived>
59Derived createDeformationGradient(const Eigen::MatrixBase<Derived>& eMB) {
60 const auto& e = eMB.derived();
61
62 static_assert(Concepts::EigenMatrix33<Derived> or Concepts::EigenMatrix22<Derived>);
63 if constexpr (tag == StrainTags::greenLagrangian) {
64 // E = 0.5 * (F ^ 2 - I);
65 // 2*E = F ^ 2 - I;
66 // 2*E+I = F ^ 2;
67 // sqrt(2*E+I) = F;
68 return (2 * e + Derived::Identity()).sqrt();
69 } else if constexpr (tag == StrainTags::deformationGradient)
70 return e;
71 else if constexpr (tag == StrainTags::displacementGradient)
72 return e + Derived::Identity();
73 else if constexpr (tag == StrainTags::rightCauchyGreenTensor) {
74 return e.sqrt(); // this looses information, since the rotation information from the original F is lost!
75 }
76}
77
88template <StrainTags tag, typename Derived>
89Derived createRightCauchyGreen(const Eigen::MatrixBase<Derived>& eMB) {
90 const auto& e = eMB.derived();
91
92 static_assert(Concepts::EigenMatrix33<Derived> or Concepts::EigenMatrix22<Derived>);
93 if constexpr (tag == StrainTags::greenLagrangian) {
94 // E = 0.5 * (C - I);
95 // 2*E = C - I;
96 // 2*E+I = C;
97 return 2 * e + Derived::Identity();
98 } else if constexpr (tag == StrainTags::deformationGradient)
99 return e.transpose() * e;
100 else if constexpr (tag == StrainTags::displacementGradient) {
101 const auto F = e + Derived::Identity();
102 return F.transpose() * F;
103 } else if constexpr (tag == StrainTags::rightCauchyGreenTensor) {
104 return e;
105 }
106}
107
118template <StrainTags from, StrainTags to, typename Derived>
119auto transformStrain(const Eigen::MatrixBase<Derived>& eRaw) {
120 static_assert((from == to) or (from != StrainTags::linear and to != StrainTags::linear),
121 "No useful transformation available for linear strains.");
122 const auto e = Impl::maybeFromVoigt(eRaw.derived(), true);
123 if constexpr (from == to)
124 return e;
125 else if constexpr (to == StrainTags::greenLagrangian)
126 return createGreenLagrangianStrains<from>(e);
127 else if constexpr (to == StrainTags::deformationGradient)
128 return createDeformationGradient<from>(e);
129 else if constexpr (to == StrainTags::rightCauchyGreenTensor) {
130 return createRightCauchyGreen<from>(e);
131 } else
134}
135} // namespace Ikarus
Helper for the Eigen::Tensor types.
Definition of several material related enums.
helper functions used by material model implementations.
Definition: assemblermanipulatorbuildingblocks.hh:22
Derived createDeformationGradient(const Eigen::MatrixBase< Derived > &eMB)
Create the deformation gradient based on the input.
Definition: strainconversions.hh:59
Derived createRightCauchyGreen(const Eigen::MatrixBase< Derived > &eMB)
Create right Cauchy-Green tensor based on the input.
Definition: strainconversions.hh:89
Derived createGreenLagrangianStrains(const Eigen::MatrixBase< Derived > &eMB)
Create Green-Lagrangian strain based on the input.
Definition: strainconversions.hh:34
auto transformStrain(const Eigen::MatrixBase< Derived > &eRaw)
Transform strain from one type to another.
Definition: strainconversions.hh:119