20 #ifndef LIBMESH_TENSOR_VALUE_H 21 #define LIBMESH_TENSOR_VALUE_H 24 #include "libmesh/type_tensor.h" 25 #include "libmesh/libmesh.h" 27 #ifdef LIBMESH_HAVE_METAPHYSICL 28 #include "metaphysicl/raw_type.h" 44 class TensorValue :
public TypeTensor<T>
49 template <
typename T2>
79 template <
typename Scalar>
90 const Scalar>::type & zz=0);
95 template <
typename T2>
101 template <
typename T2>
108 template <
typename T2>
117 template <
typename T2>
123 template <
typename T2>
127 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 141 template <
typename Scalar>
146 { libmesh_assert_equal_to (p, Scalar(0)); this->
zero();
return *
this; }
213 template <
typename T>
222 template <
typename T>
238 template <
typename T>
239 template <
typename Scalar>
251 const Scalar>::type & zz) :
258 template <
typename T>
259 template <
typename T2>
268 template <
typename T>
269 template <
typename T2>
278 template <
typename T>
279 template <
typename T2>
289 template <
typename T>
290 template <
typename T2>
301 template <
typename T>
302 template <
typename T2>
310 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 311 template <
typename T>
316 Complex (p_re(0,1), p_im(0,1)),
317 Complex (p_re(0,2), p_im(0,2)),
318 Complex (p_re(1,0), p_im(1,0)),
319 Complex (p_re(1,1), p_im(1,1)),
320 Complex (p_re(1,2), p_im(1,2)),
321 Complex (p_re(2,0), p_im(2,0)),
322 Complex (p_re(2,1), p_im(2,1)),
323 Complex (p_re(2,2), p_im(2,2)))
328 template <
typename T>
337 const Real p = -phi / 180. *
pi;
338 const Real t = -theta / 180. *
pi;
339 const Real s = -psi / 180. *
pi;
340 const Real sp = std::sin(p), cp = std::cos(p);
341 const Real st = std::sin(t), ct = std::cos(t);
342 const Real ss = std::sin(s), cs = std::cos(s);
345 sp * cs + cp * ct * ss,
347 -cp * ss - sp * ct * cs,
348 -sp * ss + cp * ct * cs,
355 libmesh_error_msg(
"TensorValue<T>::intrinsic_rotation_matrix() requires libMesh to be compiled " 356 "with LIBMESH_DIM==3");
362 template <
typename T>
370 template <
typename T>
373 const Real angle2_deg,
374 const Real angle3_deg)
377 const auto angle1 = angle1_deg / 180. *
pi;
378 const auto angle2 = angle2_deg / 180. *
pi;
379 const auto angle3 = angle3_deg / 180. *
pi;
380 const auto s1 = std::sin(angle1), c1 = std::cos(angle1);
381 const auto s2 = std::sin(angle2), c2 = std::cos(angle2);
382 const auto s3 = std::sin(angle3), c3 = std::cos(angle3);
385 -c1 * s3 - c2 * c3 * s1,
387 c3 * s1 + c1 * c2 * s3,
388 c1 * c2 * c3 - s1 * s3,
395 libmesh_error_msg(
"TensorValue<T>::extrinsic_rotation_matrix() requires libMesh to be compiled " 396 "with LIBMESH_DIM==3");
402 template <
typename T>
405 const Real angle2_deg,
406 const Real angle3_deg)
414 #ifdef LIBMESH_HAVE_METAPHYSICL 417 template <
typename T>
425 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
426 for (
unsigned int j = 0; j < LIBMESH_DIM; ++j)
427 ret(i,j) = raw_value(in(i,j));
433 template <
typename T,
typename U>
434 struct ReplaceAlgebraicType<
libMesh::TensorValue<T>, U>
441 #endif // LIBMESH_TENSOR_VALUE_H
static TensorValue< Real > extrinsic_rotation_matrix(Real angle1_deg, Real angle2_deg, Real angle3_deg)
Generate the extrinsic rotation matrix associated with the provided Euler angles. ...
static TensorValue< Real > inverse_extrinsic_rotation_matrix(Real angle1_deg, Real angle2_deg, Real angle3_deg)
Invert the rotation that would occur if the same angles were provided to extrinsic_rotation_matrix, e.g.
void zero()
Set all entries of the tensor to 0.
static TensorValue< Real > inverse_intrinsic_rotation_matrix(Real phi, Real theta, Real psi)
Invert the rotation that would occur if the same angles were provided to intrinsic_rotation_matrix, e.g.
RealTensorValue RealTensor
The libMesh namespace provides an interface to certain functionality in the library.
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TensorValue & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
TensorValue()
Empty constructor.
TensorValue< Real > RealTensorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
void libmesh_ignore(const Args &...)
TensorValue< Number > NumberTensorValue
static TensorValue< Real > intrinsic_rotation_matrix(Real phi, Real theta, Real psi)
Generate the intrinsic rotation matrix associated with the provided Euler angles. ...
This class defines a vector in LIBMESH_DIM dimensional space of type T.
std::complex< Real > Complex
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.