20#ifndef LIBMESH_TENSOR_VALUE_H
21#define LIBMESH_TENSOR_VALUE_H
24#include "libmesh/type_tensor.h"
25#include "libmesh/libmesh_device.h"
26#include "libmesh/libmesh.h"
28#ifdef LIBMESH_HAVE_METAPHYSICL
29#include "metaphysicl/raw_type.h"
50 template <
typename T2>
80 template <
typename Scalar>
91 const Scalar>::type & zz=0);
96 template <
typename T2>
103 template <
typename T2>
104 LIBMESH_DEVICE_INLINE
111 template <
typename T2>
112 LIBMESH_DEVICE_INLINE
121 template <
typename T2>
127 template <
typename T2>
131#ifdef LIBMESH_USE_COMPLEX_NUMBERS
144 template <
typename Scalar>
145 LIBMESH_DEVICE_INLINE
146 typename std::enable_if<
150 { libmesh_assert_equal_to (p, Scalar(0)); this->
zero();
return *
this; }
243template <
typename Scalar>
255 const Scalar>::type & zz) :
263template <
typename T2>
273template <
typename T2>
283template <
typename T2>
294template <
typename T2>
306template <
typename T2>
314#ifdef LIBMESH_USE_COMPLEX_NUMBERS
320 Complex (p_re(0,1), p_im(0,1)),
321 Complex (p_re(0,2), p_im(0,2)),
322 Complex (p_re(1,0), p_im(1,0)),
323 Complex (p_re(1,1), p_im(1,1)),
324 Complex (p_re(1,2), p_im(1,2)),
325 Complex (p_re(2,0), p_im(2,0)),
326 Complex (p_re(2,1), p_im(2,1)),
327 Complex (p_re(2,2), p_im(2,2)))
341 const Real p = -phi / 180. *
pi;
342 const Real t = -theta / 180. *
pi;
343 const Real s = -psi / 180. *
pi;
344 const Real sp = std::sin(p), cp = std::cos(p);
345 const Real st = std::sin(t), ct = std::cos(t);
346 const Real ss = std::sin(s), cs = std::cos(s);
349 sp * cs + cp * ct * ss,
351 -cp * ss - sp * ct * cs,
352 -sp * ss + cp * ct * cs,
359 libmesh_error_msg(
"TensorValue<T>::intrinsic_rotation_matrix() requires libMesh to be compiled "
360 "with LIBMESH_DIM==3");
377 const Real angle2_deg,
378 const Real angle3_deg)
381 const auto angle1 = angle1_deg / 180. *
pi;
382 const auto angle2 = angle2_deg / 180. *
pi;
383 const auto angle3 = angle3_deg / 180. *
pi;
384 const auto s1 = std::sin(angle1), c1 = std::cos(angle1);
385 const auto s2 = std::sin(angle2), c2 = std::cos(angle2);
386 const auto s3 = std::sin(angle3), c3 = std::cos(angle3);
389 -c1 * s3 - c2 * c3 * s1,
391 c3 * s1 + c1 * c2 * s3,
392 c1 * c2 * c3 - s1 * s3,
399 libmesh_error_msg(
"TensorValue<T>::extrinsic_rotation_matrix() requires libMesh to be compiled "
400 "with LIBMESH_DIM==3");
409 const Real angle2_deg,
410 const Real angle3_deg)
418#ifdef LIBMESH_HAVE_METAPHYSICL
429 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
430 for (
unsigned int j = 0; j < LIBMESH_DIM; ++j)
431 ret(i,j) = raw_value(in(i,j));
437template <
typename T,
typename U>
438struct ReplaceAlgebraicType<
libMesh::TensorValue<T>, U>
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
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.
TensorValue(const Scalar &xx, const Scalar &xy=0, const Scalar &xz=0, const Scalar &yx=0, const Scalar &yy=0, const Scalar &yz=0, const Scalar &zx=0, const Scalar &zy=0, typename std::enable_if< ScalarTraits< Scalar >::value, const Scalar >::type &zz=0)
Constructor-from-scalars.
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,...
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,...
TensorValue(const TypeTensor< T2 > &p)
Copy-constructor.
TensorValue(const TensorValue< T2 > &p)
Copy-constructor.
TensorValue()
Empty constructor.
LIBMESH_DEVICE_INLINE std::enable_if< ScalarTraits< Scalar >::value, TensorValue & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
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 tensor in LIBMESH_DIM dimensional space of type T.
TypeTensor< T > transpose() const
LIBMESH_DEVICE_INLINE void zero()
Set all entries of the tensor to 0.
This class defines a vector in LIBMESH_DIM dimensional space of type T.
The libMesh namespace provides an interface to certain functionality in the library.
TensorValue< Number > NumberTensorValue
std::complex< Real > Complex
void libmesh_ignore(const Args &...)
TensorValue< Real > RealTensorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
RealTensorValue RealTensor
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real