44 static const vec unit_tensor2{1., 1., 1., 0., 0., 0.};
59 static const vec norm_weight{1., 1., 1., 2., 2., 2.};
72 static const vec norm_weight{1., 1., 1., .5, .5, .5};
76 double mean3(
const vec&);
88 double norm(
const vec&);
96 double norm(
const vec&);
104 const vec3 g1, g2, g3;
108 Base3D(
const vec3&,
const vec3&,
const vec3&);
109 [[nodiscard]] std::tuple<vec3, vec3, vec3>
to_inverse()
const;
112 vec3
unit_norm(
const vec3&,
const vec3&);
117 mat
diff_triad(
const vec3&,
const vec3&,
const vec3&);
124 double atan2(
const vec&);
132 template<
typename T> Mat<T>
skew_symm(
const Mat<T>& R) {
133 suanpan_assert([&] {
if(R.n_elem != 3)
throw invalid_argument(
"need 3 element vector"); });
135 Mat<T>
S(3, 3, fill::zeros);
137 S(0, 1) = -(
S(1, 0) = R(2));
138 S(2, 0) = -(
S(0, 2) = R(1));
139 S(1, 2) = -(
S(2, 1) = R(0));
144 template<
typename T>
concept HasEval =
requires(
const T& x) { { x.eval() } -> std::convertible_to<mat>; };
160 const auto tr_r = arma::trace(R);
161 const auto max_r = arma::max(R.diag());
163 const auto q0 = .5 * std::sqrt(tr_r + 1.);
164 const auto q1 = .25 / q0 * (R(2, 1) - R(1, 2));
165 const auto q2 = .25 / q0 * (R(0, 2) - R(2, 0));
166 const auto q3 = .25 / q0 * (R(1, 0) - R(0, 1));
167 return {q0, q1, q2, q3};
170 for(
auto I = 0; I < 3; ++I)
172 const auto J = (I + 1) % 3;
173 const auto K = (J + 1) % 3;
174 vec q(3, fill::none);
175 q(I) = std::sqrt(.5 * max_r + .25 * (1. - tr_r));
176 const double q0 = .25 / q(I) * (R(
K, J) - R(J,
K));
177 q(J) = .25 / q(I) * (R(J, I) + R(I, J));
178 q(
K) = .25 / q(I) * (R(
K, I) + R(I,
K));
180 return {q0, std::move(q)};
184 throw invalid_argument(
"need either rotation vector or matrix");
187 template<
typename T> Col<T>
to_pseudo(
const Mat<T>& R) {
188 const Mat<T>
S = arma::real(arma::logmat(R));
190 return {
S(2, 1),
S(0, 2),
S(1, 0)};
194 double angle(
const vec&);
197 vec
rotate(
const vec&,
double);
200 double angle(
const vec&);
203 vec
rotate(
const vec&,
double);
215 template<
typename T>
T ramp(
const T in) {
return in >
T(0) ? in :
T(0); }
An Quaternion class.
Definition: Quaternion.hpp:34
std::tuple< vec3, vec3, vec3 > to_inverse() const
Definition: tensor.cpp:283
Base3D(const vec3 &, const vec3 &, const vec3 &)
Definition: tensor.cpp:274
Mat< T > stress(T X, T Y, unsigned S)
Definition: shape.h:475
Mat< T > strain(T X, T Y, T V, unsigned S)
Definition: shape.h:523
Col< T > beam(T int_pts, unsigned order, double length)
Definition: shape.h:151
T triangle(const Mat< T > &EC)
Definition: shape.h:107
Definition: MatrixModifier.hpp:36
T ramp(const T in)
Definition: tensor.h:215
std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > approx_equal(T x, T y, int ulp=2)
Definition: utility.h:60
vec3 unit_norm(const vec3 &, const vec3 &)
Definition: tensor.cpp:289
mat to_green(mat &&)
Definition: tensor.cpp:292
mat to_tensor(const vec &)
Definition: tensor.cpp:316
double invariant3(const vec &)
compute the third invariant of the given 3D strain tensor, could be either normal or deviatoric strai...
Definition: tensor.cpp:112
double norm(const vec &)
Definition: tensor.cpp:370
double invariant2(const vec &)
compute the second invariant of the given 3D strain tensor, could be either normal or deviatoric stra...
Definition: tensor.cpp:100
double invariant1(const vec &)
compute the first invariant of the given 3D strain tensor, could be either normal or deviatoric strai...
Definition: tensor.cpp:89
double double_contraction(const vec &, const vec &)
Definition: tensor.cpp:382
vec to_voigt(const mat &)
Definition: tensor.cpp:341
double lode(vec)
Definition: tensor.cpp:154
vec to_voigt(const mat &)
Definition: tensor.cpp:411
double invariant2(const vec &)
compute the second invariant of the given 3D stress tensor, could be either normal or deviatoric stre...
Definition: tensor.cpp:135
double double_contraction(const vec &, const vec &)
Definition: tensor.cpp:452
vec lode_der(vec)
Definition: tensor.cpp:172
double lode(vec)
Definition: tensor.cpp:163
double invariant3(const vec &)
compute the third invariant of the given 3D stress tensor, could be either normal or deviatoric stres...
Definition: tensor.cpp:147
double invariant1(const vec &)
compute the first invariant of the given 3D stress tensor, could be either normal or deviatoric stres...
Definition: tensor.cpp:124
double norm(const vec &)
Definition: tensor.cpp:440
mat to_tensor(const vec &)
Definition: tensor.cpp:386
double norm(vec &&)
Definition: tensor.cpp:446
double trace3(const vec &)
Only accepts 3D tensor!
Definition: tensor.cpp:196
mat diff_unit(const vec &)
Definition: tensor.cpp:231
mat unit_deviatoric_tensor4v2()
Definition: tensor.cpp:67
mat unit_deviatoric_tensor4()
Definition: tensor.cpp:57
double mean3(const vec &)
Definition: tensor.cpp:202
mat diff_triad(const vec3 &, const vec3 &, const vec3 &)
Definition: tensor.cpp:236
vec dev(const vec &)
Definition: tensor.cpp:204
mat unit_symmetric_tensor4()
Definition: tensor.cpp:75
mat isotropic_stiffness(double, double)
Definition: tensor.cpp:20
mat orthotropic_stiffness(const vec &, const vec &)
Definition: tensor.cpp:34
double trace2(const vec &)
Only accepts 2D tensor!
Definition: tensor.cpp:185
void suanpan_assert(const std::function< void()> &F)
Definition: suanPan.h:296