v0.14.0
EshelbianAux.hpp
Go to the documentation of this file.
1 /**
2  * @file EshelbianAux.hpp
3  * @brief Auxilary functions for Eshelbian plasticity
4  * @date 2024-08-30
5  *
6  * @copyright Copyright (c) 2024
7  *
8  */
9 
10 #include <Lie.hpp>
11 
12 namespace EshelbianPlasticity {
13 
14 inline auto diff_deviator(FTensor::Ddg<double, 3, 3> &&t_diff_stress) {
19 
20  FTensor::Ddg<double, 3, 3> t_diff_deviator;
21  t_diff_deviator(i, j, k, l) = t_diff_stress(i, j, k, l);
22 
23  constexpr double third = boost::math::constants::third<double>();
24 
25  t_diff_deviator(0, 0, 0, 0) -= third;
26  t_diff_deviator(0, 0, 1, 1) -= third;
27 
28  t_diff_deviator(1, 1, 0, 0) -= third;
29  t_diff_deviator(1, 1, 1, 1) -= third;
30 
31  t_diff_deviator(2, 2, 0, 0) -= third;
32  t_diff_deviator(2, 2, 1, 1) -= third;
33 
34  t_diff_deviator(0, 0, 2, 2) -= third;
35  t_diff_deviator(1, 1, 2, 2) -= third;
36  t_diff_deviator(2, 2, 2, 2) -= third;
37 
38  return t_diff_deviator;
39 }
40 
41 constexpr static auto size_symm = (3 * (3 + 1)) / 2;
42 
43 inline auto diff_tensor() {
50  t_diff(i, j, k, l) = (t_kd(i, k) ^ t_kd(j, l)) / 4.;
51  return t_diff;
52 };
53 
54 inline auto symm_L_tensor() {
59  t_L(i, j, L) = 0;
60  t_L(0, 0, 0) = 1;
61  t_L(1, 1, 3) = 1;
62  t_L(2, 2, 5) = 1;
63  t_L(1, 0, 1) = 1;
64  t_L(2, 0, 2) = 1;
65  t_L(2, 1, 4) = 1;
66  return t_L;
67 }
68 
69 inline auto diff_symmetrize() {
70 
75 
77 
78  t_diff(i, j, k, l) = 0;
79  t_diff(0, 0, 0, 0) = 1;
80  t_diff(1, 1, 1, 1) = 1;
81 
82  t_diff(1, 0, 1, 0) = 0.5;
83  t_diff(1, 0, 0, 1) = 0.5;
84 
85  t_diff(0, 1, 0, 1) = 0.5;
86  t_diff(0, 1, 1, 0) = 0.5;
87 
88  if constexpr (SPACE_DIM == 3) {
89  t_diff(2, 2, 2, 2) = 1;
90 
91  t_diff(2, 0, 2, 0) = 0.5;
92  t_diff(2, 0, 0, 2) = 0.5;
93  t_diff(0, 2, 0, 2) = 0.5;
94  t_diff(0, 2, 2, 0) = 0.5;
95 
96  t_diff(2, 1, 2, 1) = 0.5;
97  t_diff(2, 1, 1, 2) = 0.5;
98  t_diff(1, 2, 1, 2) = 0.5;
99  t_diff(1, 2, 2, 1) = 0.5;
100  }
101 
102  return t_diff;
103 }
104 
105 template <class T> struct TensorTypeExtractor {
107 };
108 template <class T, int I> struct TensorTypeExtractor<FTensor::PackPtr<T, I>> {
110 };
111 
112 struct isEq {
113  static inline auto check(const double &a, const double &b) {
114  constexpr double eps = std::numeric_limits<double>::epsilon();
115  return std::abs(a - b) / absMax < eps;
116  }
117  static inline double absMax = 1.;
118 };
119 
120 inline auto is_eq(const double &a, const double &b) {
121  return isEq::check(a, b);
122 };
123 
124 template <int DIM> inline auto get_uniq_nb(double *ptr) {
125  std::array<double, DIM> tmp;
126  std::copy(ptr, &ptr[DIM], tmp.begin());
127  std::sort(tmp.begin(), tmp.end());
128  isEq::absMax = std::max(std::abs(tmp[0]), std::abs(tmp[DIM - 1]));
129  constexpr double eps = std::numeric_limits<double>::epsilon();
130  isEq::absMax = std::max(isEq::absMax, static_cast<double>(eps));
131  return std::distance(tmp.begin(), std::unique(tmp.begin(), tmp.end(), is_eq));
132 }
133 
134 template <typename A, typename B>
135 inline auto sort_eigen_vals(A &eig, B &eigen_vec) {
136 
137  constexpr int dim = 3;
138 
139  isEq::absMax =
140  std::max(std::max(std::abs(eig(0)), std::abs(eig(1))), std::abs(eig(2)));
141  constexpr double eps = std::numeric_limits<double>::epsilon();
142  isEq::absMax = std::max(isEq::absMax, static_cast<double>(eps));
143 
144  int i = 0, j = 1, k = 2;
145 
146  if (is_eq(eig(0), eig(1))) {
147  i = 0;
148  j = 2;
149  k = 1;
150  } else if (is_eq(eig(0), eig(2))) {
151  i = 0;
152  j = 1;
153  k = 2;
154  } else if (is_eq(eig(1), eig(2))) {
155  i = 1;
156  j = 0;
157  k = 2;
158  }
159 
160  FTensor::Tensor2<double, 3, 3> eigen_vec_c{
161  eigen_vec(i, 0), eigen_vec(i, 1), eigen_vec(i, 2),
162 
163  eigen_vec(j, 0), eigen_vec(j, 1), eigen_vec(j, 2),
164 
165  eigen_vec(k, 0), eigen_vec(k, 1), eigen_vec(k, 2)};
166 
167  FTensor::Tensor1<double, 3> eig_c{eig(i), eig(j), eig(k)};
168 
169  {
170  FTENSOR_INDEX(dim, i);
171  FTENSOR_INDEX(dim, j);
172  eig(i) = eig_c(i);
173  eigen_vec(i, j) = eigen_vec_c(i, j);
174  }
175 }
176 }
EshelbianPlasticity::is_eq
auto is_eq(const double &a, const double &b)
Definition: EshelbianAux.hpp:120
EshelbianPlasticity::sort_eigen_vals
auto sort_eigen_vals(A &eig, B &eigen_vec)
Definition: EshelbianAux.hpp:135
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
EshelbianPlasticity::size_symm
constexpr static auto size_symm
Definition: EshelbianAux.hpp:41
FTensor::Tensor1< double, 3 >
EshelbianPlasticity::isEq
Definition: EshelbianAux.hpp:112
EshelbianPlasticity
Definition: CGGTonsorialBubbleBase.hpp:11
EshelbianPlasticity::diff_tensor
auto diff_tensor()
Definition: EshelbianAux.hpp:43
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTENSOR_INDEX
#define FTENSOR_INDEX(DIM, I)
Definition: Templates.hpp:2013
EshelbianPlasticity::diff_symmetrize
auto diff_symmetrize()
Definition: EshelbianAux.hpp:69
FTensor::Tensor2< double, 3, 3 >
EshelbianPlasticity::isEq::absMax
static double absMax
Definition: EshelbianAux.hpp:117
EshelbianPlasticity::get_uniq_nb
auto get_uniq_nb(double *ptr)
Definition: EshelbianAux.hpp:124
SPACE_DIM
constexpr int SPACE_DIM
Definition: child_and_parent.cpp:16
a
constexpr double a
Definition: approx_sphere.cpp:30
convert.type
type
Definition: convert.py:64
Lie.hpp
MoFEM::L
VectorDouble L
Definition: Projection10NodeCoordsOnField.cpp:124
EshelbianPlasticity::TensorTypeExtractor
Definition: EshelbianAux.hpp:105
EshelbianPlasticity::diff_deviator
auto diff_deviator(FTensor::Ddg< double, 3, 3 > &&t_diff_stress)
Definition: EshelbianAux.hpp:14
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
t_kd
constexpr auto t_kd
Definition: free_surface.cpp:139
EshelbianPlasticity::symm_L_tensor
auto symm_L_tensor()
Definition: EshelbianAux.hpp:54
FTensor::Index< 'i', 3 >
FTensor::Dg
Definition: Dg_value.hpp:9
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
eps
static const double eps
Definition: check_base_functions_derivatives_on_tet.cpp:11
FTensor::Ddg< double, 3, 3 >
FTensor::Kronecker_Delta_symmetric
Kronecker Delta class symmetric.
Definition: Kronecker_Delta.hpp:49
third
constexpr double third
Definition: EshelbianADOL-C.cpp:17
EshelbianPlasticity::isEq::check
static auto check(const double &a, const double &b)
Definition: EshelbianAux.hpp:113
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
EshelbianPlasticity::TensorTypeExtractor::Type
std::remove_pointer< T >::type Type
Definition: EshelbianAux.hpp:106
EshelbianPlasticity::TensorTypeExtractor< FTensor::PackPtr< T, I > >::Type
std::remove_pointer< T >::type Type
Definition: EshelbianAux.hpp:109
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21