OGS
KelvinVector-impl.h
Go to the documentation of this file.
1
11#include <cmath>
12
13namespace MathLib
14{
15namespace KelvinVector
16{
17template <int KelvinVectorSize>
19 Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
20{
21 assert(std::abs(trace(deviatoric_v)) <=
22 2e-12 * diagonal(deviatoric_v).norm());
23 return std::sqrt(3 * J2(deviatoric_v));
24}
25
26template <int KelvinVectorSize>
28 Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
29{
30 return std::sqrt(deviatoric_v.transpose() * deviatoric_v);
31}
32
33template <int KelvinVectorSize>
35 Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
36{
37 assert(std::abs(trace(deviatoric_v)) <=
38 2e-12 * diagonal(deviatoric_v).norm());
39 return 0.5 * deviatoric_v.transpose() * deviatoric_v;
40}
41
44template <int KelvinVectorSize>
46 Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
47{
48 assert(std::abs(trace(deviatoric_v)) <=
49 2e-12 * diagonal(deviatoric_v).norm());
50 return determinant(deviatoric_v);
51}
52
53template <int KelvinVectorSize>
55 Eigen::Matrix<double, KelvinVectorSize, 1> const& v)
56{
57 return v.template topLeftCorner<3, 1>();
58}
59
61template <int KelvinVectorSize>
63 Eigen::Matrix<double, KelvinVectorSize, 1> const& v)
64{
65 return diagonal(v).sum();
66}
67
68//
69// Initialization of static Invariant variables.
70//
71
72namespace KelvinVector_detail
73{
74template <int KelvinVectorSize>
75Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize>
77{
78 Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> P_dev =
79 Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize>::Identity();
80
81 P_dev.template topLeftCorner<3, 3>() -=
82 1. / 3. * Eigen::Matrix<double, 3, 3>::Ones();
83 return P_dev;
84}
85
86template <int KelvinVectorSize>
87Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize>
89{
90 Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> P_sph =
91 Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize>::Zero();
92
93 P_sph.template topLeftCorner<3, 3>().setConstant(1. / 3.);
94 return P_sph;
95}
96
97template <int KelvinVectorSize>
98Eigen::Matrix<double, KelvinVectorSize, 1> initIdentity2()
99{
100 Eigen::Matrix<double, KelvinVectorSize, 1> ivec =
101 Eigen::Matrix<double, KelvinVectorSize, 1>::Zero();
102
103 ivec.template topLeftCorner<3, 1>().setConstant(1.);
104 return ivec;
105}
106} // namespace detail
107
108template <int KelvinVectorSize>
109const Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize>
111 KelvinVector_detail::initDeviatoricProjection<KelvinVectorSize>();
112
113template <int KelvinVectorSize>
114Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> const
116 KelvinVector_detail::initSphericalProjection<KelvinVectorSize>();
117
118template <int KelvinVectorSize>
119const Eigen::Matrix<double, KelvinVectorSize, 1>
121 KelvinVector_detail::initIdentity2<KelvinVectorSize>();
122
123} // namespace KelvinVector
124} // namespace MathLib
Eigen::Matrix< double, KelvinVectorSize, KelvinVectorSize > initSphericalProjection()
Eigen::Matrix< double, KelvinVectorSize, KelvinVectorSize > initDeviatoricProjection()
Eigen::Matrix< double, KelvinVectorSize, 1 > initIdentity2()
double norm(MatrixOrVector const &x, MathLib::VecNormType type)
Definition: LinAlg.h:93
static const double v
static double FrobeniusNorm(Eigen::Matrix< double, KelvinVectorSize, 1 > const &deviatoric_v)
Get the norm of the deviatoric stress.
static Eigen::Matrix< double, KelvinVectorSize, 1 > const identity2
Kelvin mapping of 2nd order identity tensor.
Definition: KelvinVector.h:76
static Eigen::Vector3d diagonal(Eigen::Matrix< double, KelvinVectorSize, 1 > const &v)
static double trace(Eigen::Matrix< double, KelvinVectorSize, 1 > const &v)
Trace of the corresponding tensor.
static Eigen::Matrix< double, KelvinVectorSize, KelvinVectorSize > const spherical_projection
Definition: KelvinVector.h:74
static double J2(Eigen::Matrix< double, KelvinVectorSize, 1 > const &deviatoric_v)
static Eigen::Matrix< double, KelvinVectorSize, KelvinVectorSize > const deviatoric_projection
Definition: KelvinVector.h:66
static double equivalentStress(Eigen::Matrix< double, KelvinVectorSize, 1 > const &deviatoric_v)
static double J3(Eigen::Matrix< double, KelvinVectorSize, 1 > const &deviatoric_v)