Loading [MathJax]/extensions/tex2jax.js
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
libMesh::TensorValue< T > Class Template Reference

This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space. More...

#include <exact_solution.h>

Inheritance diagram for libMesh::TensorValue< T >:
[legend]

Classes

struct  rebind
 

Public Types

typedef T value_type
 
typedef std::tuple< unsigned int, unsigned intindex_type
 Helper typedef for generic index programming. More...
 

Public Member Functions

 TensorValue ()
 Empty constructor. More...
 
 TensorValue (const T &xx, const T &xy=0, const T &xz=0, const T &yx=0, const T &yy=0, const T &yz=0, const T &zx=0, const T &zy=0, const T &zz=0)
 Constructor-from-T. More...
 
template<typename Scalar >
 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 boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type &zz=0)
 Constructor-from-scalars. More...
 
template<typename T2 >
 TensorValue (const TypeVector< T2 > &vx)
 Constructor. More...
 
template<typename T2 >
 TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy)
 Constructor. More...
 
template<typename T2 >
 TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy, const TypeVector< T2 > &vz)
 Constructor. More...
 
template<typename T2 >
 TensorValue (const TensorValue< T2 > &p)
 Copy-constructor. More...
 
template<typename T2 >
 TensorValue (const TypeTensor< T2 > &p)
 Copy-constructor. More...
 
 TensorValue (const TypeTensor< Real > &p_re, const TypeTensor< Real > &p_im)
 Constructor that takes two TypeTensor<Real> representing the real and imaginary part as arguments. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TensorValue & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
template<typename T2 >
void assign (const TypeTensor< T2 > &)
 Assign to this tensor without creating a temporary. More...
 
const T & operator() (const unsigned int i, const unsigned int j) const
 
T & operator() (const unsigned int i, const unsigned int j)
 
ConstTypeTensorColumn< T > slice (const unsigned int i) const
 
TypeTensorColumn< T > slice (const unsigned int i)
 
TypeVector< T > row (const unsigned int r) const
 
TypeVector< T > column (const unsigned int r) const
 
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > operator+ (const TypeTensor< T2 > &) const
 Add another tensor to this tensor. More...
 
template<typename T2 >
const TypeTensor< T > & operator+= (const TypeTensor< T2 > &)
 Add to this tensor. More...
 
template<typename T2 >
void add (const TypeTensor< T2 > &)
 Add to this tensor without creating a temporary. More...
 
template<typename T2 >
void add_scaled (const TypeTensor< T2 > &, const T &)
 Add a scaled tensor to this tensor without creating a temporary. More...
 
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > operator- (const TypeTensor< T2 > &) const
 Subtract a tensor from this tensor. More...
 
TypeTensor< T > operator- () const
 
template<typename T2 >
const TypeTensor< T > & operator-= (const TypeTensor< T2 > &)
 Subtract from this tensor. More...
 
template<typename T2 >
void subtract (const TypeTensor< T2 > &)
 Subtract from this tensor without creating a temporary. More...
 
template<typename T2 >
void subtract_scaled (const TypeTensor< T2 > &, const T &)
 Subtract a scaled value from this tensor without creating a temporary. More...
 
template<typename Scalar >
auto operator* (const Scalar &scalar) const -> typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)>>::type
 Multiply this tensor by a scalar value. More...
 
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > operator* (const TypeTensor< T2 > &) const
 Multiply 2 tensors together, i.e. More...
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator* (const TypeVector< T2 > &) const
 Right-multiply this tensor by a vector, i.e. More...
 
template<typename Scalar , typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, int >::type = 0>
const TypeTensor< T > & operator*= (const Scalar &factor)
 Multiply this tensor by a scalar value in place. More...
 
template<typename T2 >
const TypeTensor< T > & operator*= (const TypeTensor< T2 > &)
 Multiply this tensor by a tensor value in place. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar &) const
 Divide each entry of this tensor by a scalar value. More...
 
const TypeTensor< T > & operator/= (const T &)
 Divide each entry of this tensor by a scalar value. More...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype contract (const TypeTensor< T2 > &) const
 Multiply 2 tensors together to return a scalar, i.e. More...
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > left_multiply (const TypeVector< T2 > &p) const
 Left-multiply this tensor by a vector, i.e. More...
 
TypeTensor< T > transpose () const
 
TypeTensor< T > inverse () const
 
void solve (const TypeVector< T > &b, TypeVector< T > &x) const
 Solve the 2x2 or 3x3 system of equations A*x = b for x by directly inverting A and multiplying it by b. More...
 
auto norm () const -> decltype(std::norm(T()))
 
auto norm_sq () const -> decltype(std::norm(T()))
 
bool is_zero () const
 
det () const
 
tr () const
 
void zero ()
 Set all entries of the tensor to 0. More...
 
bool operator== (const TypeTensor< T > &rhs) const
 
bool operator< (const TypeTensor< T > &rhs) const
 
template<>
bool operator< (const TypeTensor< Real > &rhs) const
 
template<>
bool operator< (const TypeTensor< Complex > &rhs) const
 
bool operator> (const TypeTensor< T > &rhs) const
 
template<>
bool operator> (const TypeTensor< Real > &rhs) const
 
template<>
bool operator> (const TypeTensor< Complex > &rhs) const
 
void print (std::ostream &os=libMesh::out) const
 Formatted print to a stream which defaults to libMesh::out. More...
 
void write_unformatted (std::ostream &out_stream, const bool newline=true) const
 Unformatted print to the stream out. More...
 

Static Public Member Functions

static TensorValue< Realintrinsic_rotation_matrix (Real phi, Real theta, Real psi)
 Generate the intrinsic rotation matrix associated with the provided Euler angles. More...
 
static TensorValue< Realinverse_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. More...
 
static TensorValue< Realextrinsic_rotation_matrix (Real angle1_deg, Real angle2_deg, Real angle3_deg)
 Generate the extrinsic rotation matrix associated with the provided Euler angles. More...
 
static TensorValue< Realinverse_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. More...
 

Protected Attributes

_coords [LIBMESH_DIM *LIBMESH_DIM]
 The coordinates of the TypeTensor. More...
 

Detailed Description

template<typename T>
class libMesh::TensorValue< T >

This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.

The typedef RealTensorValue always defines a real-valued tensor, and NumberTensorValue defines a real or complex-valued tensor depending on how the library was configured.

Author
Roy H. Stogner
Date
2004

Definition at line 46 of file exact_solution.h.

Member Typedef Documentation

◆ index_type

template<typename T>
typedef std::tuple<unsigned int, unsigned int> libMesh::TypeTensor< T >::index_type
inherited

Helper typedef for generic index programming.

Definition at line 125 of file type_tensor.h.

◆ value_type

template<typename T>
typedef T libMesh::TensorValue< T >::value_type

Definition at line 47 of file tensor_value.h.

Constructor & Destructor Documentation

◆ TensorValue() [1/9]

template<typename T >
libMesh::TensorValue< T >::TensorValue ( )
inline

Empty constructor.

Gives the tensor 0 in LIBMESH_DIM dimensional T space.

Definition at line 215 of file tensor_value.h.

215  :
216  TypeTensor<T> ()
217 {
218 }

◆ TensorValue() [2/9]

template<typename T >
libMesh::TensorValue< T >::TensorValue ( const T &  xx,
const T &  xy = 0,
const T &  xz = 0,
const T &  yx = 0,
const T &  yy = 0,
const T &  yz = 0,
const T &  zx = 0,
const T &  zy = 0,
const T &  zz = 0 
)
inlineexplicit

Constructor-from-T.

By default sets higher dimensional entries to 0.

Definition at line 224 of file tensor_value.h.

232  :
233  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
234 {
235 }

◆ TensorValue() [3/9]

template<typename T >
template<typename Scalar >
libMesh::TensorValue< T >::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 boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type &  zz = 0 
)
inlineexplicit

Constructor-from-scalars.

By default sets higher dimensional entries to 0.

Definition at line 241 of file tensor_value.h.

251  :
252  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
253 {
254 }

◆ TensorValue() [4/9]

template<typename T >
template<typename T2 >
libMesh::TensorValue< T >::TensorValue ( const TypeVector< T2 > &  vx)
inline

Constructor.

Takes 1 row vector for LIBMESH_DIM=1

Definition at line 271 of file tensor_value.h.

271  :
272  TypeTensor<T> (vx)
273 {
274 }

◆ TensorValue() [5/9]

template<typename T >
template<typename T2 >
libMesh::TensorValue< T >::TensorValue ( const TypeVector< T2 > &  vx,
const TypeVector< T2 > &  vy 
)
inline

Constructor.

Takes 2 row vectors for LIBMESH_DIM=2

Definition at line 281 of file tensor_value.h.

282  :
283  TypeTensor<T> (vx, vy)
284 {
285 }

◆ TensorValue() [6/9]

template<typename T >
template<typename T2 >
libMesh::TensorValue< T >::TensorValue ( const TypeVector< T2 > &  vx,
const TypeVector< T2 > &  vy,
const TypeVector< T2 > &  vz 
)
inline

Constructor.

Takes 3 row vectors for LIBMESH_DIM=3

Definition at line 292 of file tensor_value.h.

294  :
295  TypeTensor<T> (vx, vy, vz)
296 {
297 }

◆ TensorValue() [7/9]

template<typename T >
template<typename T2 >
libMesh::TensorValue< T >::TensorValue ( const TensorValue< T2 > &  p)
inline

Copy-constructor.

Definition at line 261 of file tensor_value.h.

261  :
262  TypeTensor<T> (p)
263 {
264 }

◆ TensorValue() [8/9]

template<typename T >
template<typename T2 >
libMesh::TensorValue< T >::TensorValue ( const TypeTensor< T2 > &  p)
inline

Copy-constructor.

Definition at line 304 of file tensor_value.h.

304  :
305  TypeTensor<T> (p)
306 {
307 }

◆ TensorValue() [9/9]

template<typename T >
libMesh::TensorValue< T >::TensorValue ( const TypeTensor< Real > &  p_re,
const TypeTensor< Real > &  p_im 
)
inline

Constructor that takes two TypeTensor<Real> representing the real and imaginary part as arguments.

Definition at line 313 of file tensor_value.h.

314  :
315  TypeTensor<T> (Complex (p_re(0,0), p_im(0,0)),
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)))
324 {
325 }
std::complex< Real > Complex

Member Function Documentation

◆ add()

template<typename T >
template<typename T2 >
void libMesh::TypeTensor< T >::add ( const TypeTensor< T2 > &  p)
inlineinherited

Add to this tensor without creating a temporary.

Definition at line 840 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

841 {
842  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
843  _coords[i] += p._coords[i];
844 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ add_scaled()

template<typename T >
template<typename T2 >
void libMesh::TypeTensor< T >::add_scaled ( const TypeTensor< T2 > &  p,
const T &  factor 
)
inlineinherited

Add a scaled tensor to this tensor without creating a temporary.

Definition at line 851 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

Referenced by libMesh::HPCoarsenTest::add_projection(), LinearElasticityWithContact::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::MeshFunction::hessian(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::System::point_hessian(), and libMesh::HPCoarsenTest::select_refinement().

852 {
853  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
854  _coords[i] += factor*p._coords[i];
855 
856 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ assign()

template<typename T >
template<typename T2 >
void libMesh::TypeTensor< T >::assign ( const TypeTensor< T2 > &  p)
inlineinherited

Assign to this tensor without creating a temporary.

Definition at line 696 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

697 {
698  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
699  _coords[i] = p._coords[i];
700 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ column()

template<typename T >
TypeVector< T > libMesh::TypeTensor< T >::column ( const unsigned int  r) const
inlineinherited
Returns
A copy of one column of the tensor as a TypeVector.

Definition at line 779 of file type_tensor.h.

References libMesh::TypeVector< T >::_coords.

Referenced by TypeTensorTest::testRowCol().

780 {
781  TypeVector<T> return_vector;
782 
783  for (unsigned int i=0; i<LIBMESH_DIM; i++)
784  return_vector._coords[i] = _coords[i*LIBMESH_DIM + r];
785 
786  return return_vector;
787 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ contract()

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeTensor< T >::contract ( const TypeTensor< T2 > &  t) const
inlineinherited

Multiply 2 tensors together to return a scalar, i.e.

Multiply 2 tensors together, i.e.

\( \sum_{ij} A_{ij} B_{ij} \) The tensors may contain different numeric types. Also known as the "double inner product" or "double dot product" of tensors.

Returns
The scalar-valued result, this tensor is unchanged.

sum Aij*Bij. The tensors may be of different types.

Definition at line 1268 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

Referenced by libMesh::HPCoarsenTest::add_projection(), libMesh::TensorTools::inner_product(), and libMesh::HPCoarsenTest::select_refinement().

1269 {
1270  typename CompareTypes<T,T2>::supertype sum = 0.;
1271  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
1272  sum += _coords[i]*t._coords[i];
1273  return sum;
1274 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ det()

template<typename T >
T libMesh::TypeTensor< T >::det ( ) const
inlineinherited
Returns
The determinant of the tensor.

Because these are 3x3 tensors at most, we don't do an LU decomposition like DenseMatrix does.

Definition at line 1298 of file type_tensor.h.

Referenced by LargeDeformationElasticity::compute_stresses(), libMesh::Hex::quality(), and libMesh::Sphere::Sphere().

1299 {
1300 #if LIBMESH_DIM == 1
1301  return _coords[0];
1302 #endif
1303 
1304 #if LIBMESH_DIM == 2
1305  return (_coords[0] * _coords[3]
1306  - _coords[1] * _coords[2]);
1307 #endif
1308 
1309 #if LIBMESH_DIM == 3
1310  return (_coords[0] * _coords[4] * _coords[8]
1311  + _coords[1] * _coords[5] * _coords[6]
1312  + _coords[2] * _coords[3] * _coords[7]
1313  - _coords[0] * _coords[5] * _coords[7]
1314  - _coords[1] * _coords[3] * _coords[8]
1315  - _coords[2] * _coords[4] * _coords[6]);
1316 #endif
1317 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ extrinsic_rotation_matrix()

template<typename T >
TensorValue< Real > libMesh::TensorValue< T >::extrinsic_rotation_matrix ( Real  angle1_deg,
Real  angle2_deg,
Real  angle3_deg 
)
static

Generate the extrinsic rotation matrix associated with the provided Euler angles.

An extrinsic rotation rotates the bodies in the domain and leaves the coordinate axes fixed. We follow the convention described at https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix and we use the matrix described by the 'Proper Euler Angles' column and Z1 X2 Z3 row, which indicates that the rotations are performed sequentially about the z, x, and z axes, in that order. A positive angle yields a counter-clockwise rotation about the axis in question. Note that angles should be provided in degrees

Parameters
angle1_degrotation angle around z-axis
angle2_degrotation angle around x-axis (post angle1)
angle3_degrotation angle around z-axis (post angle1 and angle2)
Returns
The associated rotation matrix

Definition at line 372 of file tensor_value.h.

References libMesh::libmesh_ignore(), and libMesh::pi.

Referenced by libMesh::TensorValue< T >::inverse_extrinsic_rotation_matrix(), and TypeTensorTest::testRotation().

375 {
376 #if LIBMESH_DIM == 3
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);
383 
384  return TensorValue<Real>(c1 * c3 - c2 * s1 * s3,
385  -c1 * s3 - c2 * c3 * s1,
386  s1 * s2,
387  c3 * s1 + c1 * c2 * s3,
388  c1 * c2 * c3 - s1 * s3,
389  -c1 * s2,
390  s2 * s3,
391  c3 * s2,
392  c2);
393 #else
394  libmesh_ignore(angle1_deg, angle2_deg, angle3_deg);
395  libmesh_error_msg("TensorValue<T>::extrinsic_rotation_matrix() requires libMesh to be compiled "
396  "with LIBMESH_DIM==3");
397  // We'll never get here
398  return TensorValue<Real>();
399 #endif
400 }
void libmesh_ignore(const Args &...)
const Real pi
.
Definition: libmesh.h:281

◆ intrinsic_rotation_matrix()

template<typename T >
TensorValue< Real > libMesh::TensorValue< T >::intrinsic_rotation_matrix ( Real  phi,
Real  theta,
Real  psi 
)
static

Generate the intrinsic rotation matrix associated with the provided Euler angles.

An intrinsic rotation leaves bodies in the domain fixed while rotating the coordinate axes. We follow the convention described at http://mathworld.wolfram.com/EulerAngles.html (equations 6-14 give the entries of the composite transformation matrix). The rotations are performed sequentially about the z, x', and z'' axes, in that order. A positive angle for a given step in the rotation sequences gives the appearance of rotating an entity in the domain counter-clockwise around the rotation axis, although in fact it is the coordinate axes themselves that are rotating. In order to give the appearance of a body rotating counter-clockwise, we actually rotate the coordinate axes by the negative of the angle passed into the method. All angles should be provided in degrees

Parameters
phiThe negative of the angle we will rotate the coordinate axes around the original z-axis
thetaThe negative of the angle we will rotate the coordinate axes around the "current" x-axis (post phi), e.g. x'
psiThe negative of the angle we will rotate the coordinate axes around the "current" z-axis (post phi and theta), e.g. z''
Returns
The associated rotation matrix

Definition at line 330 of file tensor_value.h.

References libMesh::libmesh_ignore(), libMesh::pi, and libMesh::Real.

Referenced by libMesh::TensorValue< T >::inverse_intrinsic_rotation_matrix(), and libMesh::MeshTools::Modification::rotate().

331 {
332 #if LIBMESH_DIM == 3
333  // We apply a negative sign here or else we don't get the appearance of
334  // counter-clockwise/right-hand-rule rotation of the bodies with respect to the coordinate axes
335  // (but as explained in the method doxygen we are *actually* rotating the coordinate axes while
336  // leaving the bodies fixed)
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);
343 
344  return TensorValue<Real>(cp * cs - sp * ct * ss,
345  sp * cs + cp * ct * ss,
346  st * ss,
347  -cp * ss - sp * ct * cs,
348  -sp * ss + cp * ct * cs,
349  st * cs,
350  sp * st,
351  -cp * st,
352  ct);
353 #else
354  libmesh_ignore(phi, theta, psi);
355  libmesh_error_msg("TensorValue<T>::intrinsic_rotation_matrix() requires libMesh to be compiled "
356  "with LIBMESH_DIM==3");
357  // We'll never get here
358  return TensorValue<Real>();
359 #endif
360 }
void libmesh_ignore(const Args &...)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real pi
.
Definition: libmesh.h:281

◆ inverse()

template<typename T >
TypeTensor< T > libMesh::TypeTensor< T >::inverse ( ) const
inlineinherited
Returns
The inverse of this tensor as an independent object.

Definition at line 1080 of file type_tensor.h.

Referenced by NonlinearNeoHookeCurrentConfig::calculate_stress(), and TypeTensorTest::testInverse().

1081 {
1082 #if LIBMESH_DIM == 1
1083  if (_coords[0] == static_cast<T>(0.))
1084  libmesh_convergence_failure();
1085  return TypeTensor(1. / _coords[0]);
1086 #endif
1087 
1088 #if LIBMESH_DIM == 2
1089  // Get convenient reference to this.
1090  const TypeTensor<T> & A = *this;
1091 
1092  // Use temporary variables, avoid multiple accesses
1093  T a = A(0,0), b = A(0,1),
1094  c = A(1,0), d = A(1,1);
1095 
1096  // Make sure det = ad - bc is not zero
1097  T my_det = a*d - b*c;
1098 
1099  if (my_det == static_cast<T>(0.))
1100  libmesh_convergence_failure();
1101 
1102  return TypeTensor(d/my_det, -b/my_det, -c/my_det, a/my_det);
1103 #endif
1104 
1105 #if LIBMESH_DIM == 3
1106  // Get convenient reference to this.
1107  const TypeTensor<T> & A = *this;
1108 
1109  T a11 = A(0,0), a12 = A(0,1), a13 = A(0,2),
1110  a21 = A(1,0), a22 = A(1,1), a23 = A(1,2),
1111  a31 = A(2,0), a32 = A(2,1), a33 = A(2,2);
1112 
1113  T my_det = a11*(a33*a22-a32*a23) - a21*(a33*a12-a32*a13) + a31*(a23*a12-a22*a13);
1114 
1115  if (my_det == static_cast<T>(0.))
1116  libmesh_convergence_failure();
1117 
1118  // Inline comment characters are for lining up columns.
1119  return TypeTensor( (a33*a22-a32*a23)/my_det, -(a33*a12-a32*a13)/my_det, (a23*a12-a22*a13)/my_det,
1120  -(a33*a21-a31*a23)/my_det, (a33*a11-a31*a13)/my_det, -(a23*a11-a21*a13)/my_det,
1121  (a32*a21-a31*a22)/my_det, -(a32*a11-a31*a12)/my_det, (a22*a11-a21*a12)/my_det);
1122 #endif
1123 }
TypeTensor()
Empty constructor.
Definition: type_tensor.h:510
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ inverse_extrinsic_rotation_matrix()

template<typename T >
TensorValue< Real > libMesh::TensorValue< T >::inverse_extrinsic_rotation_matrix ( Real  angle1_deg,
Real  angle2_deg,
Real  angle3_deg 
)
static

Invert the rotation that would occur if the same angles were provided to extrinsic_rotation_matrix, e.g.

return to the original starting point

Definition at line 404 of file tensor_value.h.

References libMesh::TensorValue< T >::extrinsic_rotation_matrix().

Referenced by TypeTensorTest::testRotation().

407 {
408  // The inverse of a rotation matrix is just the transpose
409  return TensorValue<T>::extrinsic_rotation_matrix(angle1_deg, angle2_deg, angle3_deg).transpose();
410 }
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. ...
Definition: tensor_value.h:372

◆ inverse_intrinsic_rotation_matrix()

template<typename T >
TensorValue< Real > libMesh::TensorValue< T >::inverse_intrinsic_rotation_matrix ( Real  phi,
Real  theta,
Real  psi 
)
static

Invert the rotation that would occur if the same angles were provided to intrinsic_rotation_matrix, e.g.

return to the original starting point. All angles should be provided in degrees

Definition at line 364 of file tensor_value.h.

References libMesh::TensorValue< T >::intrinsic_rotation_matrix().

365 {
366  // The inverse of a rotation matrix is just the transpose
367  return TensorValue<T>::intrinsic_rotation_matrix(phi, theta, psi).transpose();
368 }
static TensorValue< Real > intrinsic_rotation_matrix(Real phi, Real theta, Real psi)
Generate the intrinsic rotation matrix associated with the provided Euler angles. ...
Definition: tensor_value.h:330

◆ is_zero()

template<typename T >
bool libMesh::TypeTensor< T >::is_zero ( ) const
inlineinherited
Returns
True if all values in the tensor are zero

Definition at line 1288 of file type_tensor.h.

Referenced by TypeTensorTest::testIsZero().

1289 {
1290  for (const auto & val : _coords)
1291  if (val != T(0))
1292  return false;
1293  return true;
1294 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ left_multiply()

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeTensor< T >::left_multiply ( const TypeVector< T2 > &  p) const
inlineinherited

Left-multiply this tensor by a vector, i.e.

matrix-vector product. The tensor and vector may contain different numeric types.

Returns
A copy of the result vector, this tensor is unchanged.

Definition at line 1211 of file type_tensor.h.

Referenced by libMesh::operator*().

1212 {
1213  TypeVector<typename CompareTypes<T,T2>::supertype> returnval;
1214  for (unsigned int i=0; i<LIBMESH_DIM; i++)
1215  for (unsigned int j=0; j<LIBMESH_DIM; j++)
1216  returnval(i) += p(j)*(*this)(j,i);
1217 
1218  return returnval;
1219 }

◆ norm()

template<typename T >
auto libMesh::TypeTensor< T >::norm ( ) const -> decltype(std::norm(T()))
inlineinherited
Returns
The Frobenius norm of the tensor, i.e. the square-root of the sum of the elements squared.

Definition at line 1280 of file type_tensor.h.

References libMesh::TensorTools::norm_sq().

1281 {
1282  return std::sqrt(this->norm_sq());
1283 }
auto norm_sq() const -> decltype(std::norm(T()))
Definition: type_tensor.h:1348

◆ norm_sq()

template<typename T >
auto libMesh::TypeTensor< T >::norm_sq ( ) const -> decltype(std::norm(T()))
inlineinherited
Returns
The Frobenius norm of the tensor squared, i.e. sum of the element magnitudes squared.

Definition at line 1348 of file type_tensor.h.

References libMesh::TensorTools::norm_sq(), and libMesh::Real.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), and libMesh::HPCoarsenTest::select_refinement().

1349 {
1350  Real sum = 0.;
1351  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
1352  sum += TensorTools::norm_sq(_coords[i]);
1353  return sum;
1354 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
auto norm_sq(const T &a) -> decltype(std::norm(a))
Definition: tensor_tools.h:104

◆ operator()() [1/2]

template<typename T >
const T & libMesh::TypeTensor< T >::operator() ( const unsigned int  i,
const unsigned int  j 
) const
inlineinherited
Returns
A const reference to the (i,j) entry of the tensor.

Definition at line 706 of file type_tensor.h.

708 {
709  libmesh_assert_less (i, 3);
710  libmesh_assert_less (j, 3);
711 
712 #if LIBMESH_DIM < 3
713  const static T my_zero = 0;
714  if (i >= LIBMESH_DIM || j >= LIBMESH_DIM)
715  return my_zero;
716 #endif
717 
718  return _coords[i*LIBMESH_DIM+j];
719 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator()() [2/2]

template<typename T >
T & libMesh::TypeTensor< T >::operator() ( const unsigned int  i,
const unsigned int  j 
)
inlineinherited
Returns
A writable reference to the (i,j) entry of the tensor.

Definition at line 725 of file type_tensor.h.

727 {
728 #if LIBMESH_DIM < 3
729 
730  libmesh_error_msg_if(i >= LIBMESH_DIM || j >= LIBMESH_DIM,
731  "ERROR: You are assigning to a tensor component that is out of range for the compiled LIBMESH_DIM!");
732 
733 #endif
734 
735  libmesh_assert_less (i, LIBMESH_DIM);
736  libmesh_assert_less (j, LIBMESH_DIM);
737 
738  return _coords[i*LIBMESH_DIM+j];
739 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator*() [1/3]

template<typename T >
template<typename Scalar >
auto libMesh::TypeTensor< T >::operator* ( const Scalar &  scalar) const -> typename boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TypeTensor<decltype(T() * scalar)>>::type
inlineinherited

Multiply this tensor by a scalar value.

Returns
A copy of the result, this tensor is unchanged.

Definition at line 965 of file type_tensor.h.

968 {
969  typedef decltype((*this)(0, 0) * factor) TS;
970 
971 
972 #if LIBMESH_DIM == 1
973  return TypeTensor<TS>(_coords[0]*factor);
974 #endif
975 
976 #if LIBMESH_DIM == 2
977  return TypeTensor<TS>(_coords[0]*factor,
978  _coords[1]*factor,
979  _coords[2]*factor,
980  _coords[3]*factor);
981 #endif
982 
983 #if LIBMESH_DIM == 3
984  return TypeTensor<TS>(_coords[0]*factor,
985  _coords[1]*factor,
986  _coords[2]*factor,
987  _coords[3]*factor,
988  _coords[4]*factor,
989  _coords[5]*factor,
990  _coords[6]*factor,
991  _coords[7]*factor,
992  _coords[8]*factor);
993 #endif
994 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator*() [2/3]

template<typename T >
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > libMesh::TypeTensor< T >::operator* ( const TypeTensor< T2 > &  p) const
inlineinherited

Multiply 2 tensors together, i.e.

matrix-matrix product. The tensors may contain different numeric types.

Returns
A copy of the result, this tensor is unchanged.

Definition at line 1233 of file type_tensor.h.

1234 {
1235  TypeTensor<typename CompareTypes<T, T2>::supertype> returnval;
1236  for (unsigned int i=0; i<LIBMESH_DIM; i++)
1237  for (unsigned int j=0; j<LIBMESH_DIM; j++)
1238  for (unsigned int k=0; k<LIBMESH_DIM; k++)
1239  returnval(i,j) += (*this)(i,k)*p(k,j);
1240 
1241  return returnval;
1242 }

◆ operator*() [3/3]

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeTensor< T >::operator* ( const TypeVector< T2 > &  p) const
inlineinherited

Right-multiply this tensor by a vector, i.e.

matrix-vector product. The tensor and vector may contain different numeric types.

Returns
A copy of the result vector, this tensor is unchanged.

Definition at line 1197 of file type_tensor.h.

1198 {
1199  TypeVector<typename CompareTypes<T,T2>::supertype> returnval;
1200  for (unsigned int i=0; i<LIBMESH_DIM; i++)
1201  for (unsigned int j=0; j<LIBMESH_DIM; j++)
1202  returnval(i) += (*this)(i,j)*p(j);
1203 
1204  return returnval;
1205 }

◆ operator*=() [1/2]

template<typename T>
template<typename Scalar , typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, int >::type = 0>
const TypeTensor<T>& libMesh::TypeTensor< T >::operator*= ( const Scalar &  factor)
inlineinherited

Multiply this tensor by a scalar value in place.

Returns
A reference to *this.

Definition at line 268 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

269  {
270  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
271  _coords[i] *= factor;
272 
273  return *this;
274  }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator*=() [2/2]

template<typename T >
template<typename T2 >
const TypeTensor< T > & libMesh::TypeTensor< T >::operator*= ( const TypeTensor< T2 > &  p)
inlineinherited

Multiply this tensor by a tensor value in place.

Returns
A reference to *this

Definition at line 1247 of file type_tensor.h.

1248 {
1249  TypeTensor<T> temp;
1250  for (unsigned int i=0; i<LIBMESH_DIM; i++)
1251  for (unsigned int j=0; j<LIBMESH_DIM; j++)
1252  for (unsigned int k=0; k<LIBMESH_DIM; k++)
1253  temp(i,j) += (*this)(i,k)*p(k,j);
1254 
1255  this->assign(temp);
1256  return *this;
1257 }
void assign(const TypeTensor< T2 > &)
Assign to this tensor without creating a temporary.
Definition: type_tensor.h:696

◆ operator+()

template<typename T >
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > libMesh::TypeTensor< T >::operator+ ( const TypeTensor< T2 > &  p) const
inlineinherited

Add another tensor to this tensor.

Returns
A copy of the result, this tensor is unchanged.

Definition at line 794 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

795 {
796 
797 #if LIBMESH_DIM == 1
798  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] + p._coords[0]);
799 #endif
800 
801 #if LIBMESH_DIM == 2
802  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] + p._coords[0],
803  _coords[1] + p._coords[1],
804  0.,
805  _coords[2] + p._coords[2],
806  _coords[3] + p._coords[3]);
807 #endif
808 
809 #if LIBMESH_DIM == 3
810  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] + p._coords[0],
811  _coords[1] + p._coords[1],
812  _coords[2] + p._coords[2],
813  _coords[3] + p._coords[3],
814  _coords[4] + p._coords[4],
815  _coords[5] + p._coords[5],
816  _coords[6] + p._coords[6],
817  _coords[7] + p._coords[7],
818  _coords[8] + p._coords[8]);
819 #endif
820 
821 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator+=()

template<typename T >
template<typename T2 >
const TypeTensor< T > & libMesh::TypeTensor< T >::operator+= ( const TypeTensor< T2 > &  p)
inlineinherited

Add to this tensor.

Returns
A reference to *this.

Definition at line 828 of file type_tensor.h.

829 {
830  this->add (p);
831 
832  return *this;
833 }
void add(const TypeTensor< T2 > &)
Add to this tensor without creating a temporary.
Definition: type_tensor.h:840

◆ operator-() [1/2]

template<typename T >
template<typename T2 >
TypeTensor< typename CompareTypes< T, T2 >::supertype > libMesh::TypeTensor< T >::operator- ( const TypeTensor< T2 > &  p) const
inlineinherited

Subtract a tensor from this tensor.

Returns
A copy of the result, this tensor is unchanged.

Definition at line 864 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

865 {
866 
867 #if LIBMESH_DIM == 1
868  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] - p._coords[0]);
869 #endif
870 
871 #if LIBMESH_DIM == 2
872  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] - p._coords[0],
873  _coords[1] - p._coords[1],
874  0.,
875  _coords[2] - p._coords[2],
876  _coords[3] - p._coords[3]);
877 #endif
878 
879 #if LIBMESH_DIM == 3
880  return TypeTensor<typename CompareTypes<T, T2>::supertype>(_coords[0] - p._coords[0],
881  _coords[1] - p._coords[1],
882  _coords[2] - p._coords[2],
883  _coords[3] - p._coords[3],
884  _coords[4] - p._coords[4],
885  _coords[5] - p._coords[5],
886  _coords[6] - p._coords[6],
887  _coords[7] - p._coords[7],
888  _coords[8] - p._coords[8]);
889 #endif
890 
891 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator-() [2/2]

template<typename T >
TypeTensor< T > libMesh::TypeTensor< T >::operator- ( ) const
inlineinherited
Returns
The negative of this tensor in a separate copy.

Definition at line 931 of file type_tensor.h.

932 {
933 
934 #if LIBMESH_DIM == 1
935  return TypeTensor(-_coords[0]);
936 #endif
937 
938 #if LIBMESH_DIM == 2
939  return TypeTensor(-_coords[0],
940  -_coords[1],
941  -_coords[2],
942  -_coords[3]);
943 #endif
944 
945 #if LIBMESH_DIM == 3
946  return TypeTensor(-_coords[0],
947  -_coords[1],
948  -_coords[2],
949  -_coords[3],
950  -_coords[4],
951  -_coords[5],
952  -_coords[6],
953  -_coords[7],
954  -_coords[8]);
955 #endif
956 
957 }
TypeTensor()
Empty constructor.
Definition: type_tensor.h:510
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator-=()

template<typename T >
template<typename T2 >
const TypeTensor< T > & libMesh::TypeTensor< T >::operator-= ( const TypeTensor< T2 > &  p)
inlineinherited

Subtract from this tensor.

Returns
A reference to *this.

Definition at line 898 of file type_tensor.h.

899 {
900  this->subtract (p);
901 
902  return *this;
903 }
void subtract(const TypeTensor< T2 > &)
Subtract from this tensor without creating a temporary.
Definition: type_tensor.h:910

◆ operator/()

template<typename T >
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type libMesh::TypeTensor< T >::operator/ ( const Scalar &  factor) const
inlineinherited

Divide each entry of this tensor by a scalar value.

Returns
A copy of the result, this tensor is unchanged.

Definition at line 1015 of file type_tensor.h.

1016 {
1017  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
1018 
1019  typedef typename CompareTypes<T, Scalar>::supertype TS;
1020 
1021 #if LIBMESH_DIM == 1
1022  return TypeTensor<TS>(_coords[0]/factor);
1023 #endif
1024 
1025 #if LIBMESH_DIM == 2
1026  return TypeTensor<TS>(_coords[0]/factor,
1027  _coords[1]/factor,
1028  _coords[2]/factor,
1029  _coords[3]/factor);
1030 #endif
1031 
1032 #if LIBMESH_DIM == 3
1033  return TypeTensor<TS>(_coords[0]/factor,
1034  _coords[1]/factor,
1035  _coords[2]/factor,
1036  _coords[3]/factor,
1037  _coords[4]/factor,
1038  _coords[5]/factor,
1039  _coords[6]/factor,
1040  _coords[7]/factor,
1041  _coords[8]/factor);
1042 #endif
1043 
1044 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator/=()

template<typename T >
const TypeTensor< T > & libMesh::TypeTensor< T >::operator/= ( const T &  factor)
inlineinherited

Divide each entry of this tensor by a scalar value.

Returns
A reference to *this.

Definition at line 1180 of file type_tensor.h.

1181 {
1182  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
1183 
1184  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
1185  _coords[i] /= factor;
1186 
1187  return *this;
1188 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator<() [1/3]

template<>
bool libMesh::TypeTensor< Real >::operator< ( const TypeTensor< Real > &  rhs) const
inherited

Definition at line 113 of file type_tensor.C.

114 {
115  for (unsigned int i=0; i<LIBMESH_DIM; i++)
116  for (unsigned int j=0; j<LIBMESH_DIM; j++)
117  {
118  if ((*this)(i,j) < rhs(i,j))
119  return true;
120  if ((*this)(i,j) > rhs(i,j))
121  return false;
122  }
123  return false;
124 }

◆ operator<() [2/3]

template<>
bool libMesh::TypeTensor< Complex >::operator< ( const TypeTensor< Complex > &  rhs) const
inherited

Definition at line 146 of file type_tensor.C.

References std::imag(), and std::real().

147 {
148  for (unsigned int i=0; i<LIBMESH_DIM; i++)
149  for (unsigned int j=0; j<LIBMESH_DIM; j++)
150  {
151  if ((*this)(i,j).real() < rhs(i,j).real())
152  return true;
153  if ((*this)(i,j).real() > rhs(i,j).real())
154  return false;
155  if ((*this)(i,j).imag() < rhs(i,j).imag())
156  return true;
157  if ((*this)(i,j).imag() > rhs(i,j).imag())
158  return false;
159  }
160  return false;
161 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator<() [3/3]

template<typename T>
bool libMesh::TypeTensor< T >::operator< ( const TypeTensor< T > &  rhs) const
inherited
Returns
true if this tensor is "less" than another. Useful for sorting.

◆ operator=()

template<typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TensorValue &>::type libMesh::TensorValue< T >::operator= ( const Scalar &  libmesh_dbg_varp)
inline

Assignment-from-scalar operator.

Used only to zero out tensors.

Definition at line 145 of file tensor_value.h.

References libMesh::TypeTensor< T >::zero().

146  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
void zero()
Set all entries of the tensor to 0.
Definition: type_tensor.h:1338

◆ operator==()

template<typename T >
bool libMesh::TypeTensor< T >::operator== ( const TypeTensor< T > &  rhs) const
inlineinherited
Returns
true if two tensors are equal, false otherwise.

Definition at line 1360 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords, and libMesh::TOLERANCE.

1361 {
1362 #if LIBMESH_DIM == 1
1363  return (std::abs(_coords[0] - rhs._coords[0])
1364  < TOLERANCE);
1365 #endif
1366 
1367 #if LIBMESH_DIM == 2
1368  return ((std::abs(_coords[0] - rhs._coords[0]) +
1369  std::abs(_coords[1] - rhs._coords[1]) +
1370  std::abs(_coords[2] - rhs._coords[2]) +
1371  std::abs(_coords[3] - rhs._coords[3]))
1372  < 4.*TOLERANCE);
1373 #endif
1374 
1375 #if LIBMESH_DIM == 3
1376  return ((std::abs(_coords[0] - rhs._coords[0]) +
1377  std::abs(_coords[1] - rhs._coords[1]) +
1378  std::abs(_coords[2] - rhs._coords[2]) +
1379  std::abs(_coords[3] - rhs._coords[3]) +
1380  std::abs(_coords[4] - rhs._coords[4]) +
1381  std::abs(_coords[5] - rhs._coords[5]) +
1382  std::abs(_coords[6] - rhs._coords[6]) +
1383  std::abs(_coords[7] - rhs._coords[7]) +
1384  std::abs(_coords[8] - rhs._coords[8]))
1385  < 9.*TOLERANCE);
1386 #endif
1387 
1388 }
static constexpr Real TOLERANCE
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ operator>() [1/3]

template<>
bool libMesh::TypeTensor< Real >::operator> ( const TypeTensor< Real > &  rhs) const
inherited

Definition at line 129 of file type_tensor.C.

130 {
131  for (unsigned int i=0; i<LIBMESH_DIM; i++)
132  for (unsigned int j=0; j<LIBMESH_DIM; j++)
133  {
134  if ((*this)(i,j) > rhs(i,j))
135  return true;
136  if ((*this)(i,j) < rhs(i,j))
137  return false;
138  }
139  return false;
140 }

◆ operator>() [2/3]

template<>
bool libMesh::TypeTensor< Complex >::operator> ( const TypeTensor< Complex > &  rhs) const
inherited

Definition at line 166 of file type_tensor.C.

References std::imag(), and std::real().

167 {
168  for (unsigned int i=0; i<LIBMESH_DIM; i++)
169  for (unsigned int j=0; j<LIBMESH_DIM; j++)
170  {
171  if ((*this)(i,j).real() > rhs(i,j).real())
172  return true;
173  if ((*this)(i,j).real() < rhs(i,j).real())
174  return false;
175  if ((*this)(i,j).imag() > rhs(i,j).imag())
176  return true;
177  if ((*this)(i,j).imag() < rhs(i,j).imag())
178  return false;
179  }
180  return false;
181 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator>() [3/3]

template<typename T>
bool libMesh::TypeTensor< T >::operator> ( const TypeTensor< T > &  rhs) const
inherited
Returns
true if this tensor is "greater" than another.

◆ print()

template<typename T >
void libMesh::TypeTensor< T >::print ( std::ostream &  os = libMesh::out) const
inherited

Formatted print to a stream which defaults to libMesh::out.

Definition at line 39 of file type_tensor.C.

40 {
41 #if LIBMESH_DIM == 1
42 
43  os << "x=" << (*this)(0,0) << std::endl;
44 
45 #endif
46 #if LIBMESH_DIM == 2
47 
48  os << "(xx,xy)=("
49  << std::setw(8) << (*this)(0,0) << ", "
50  << std::setw(8) << (*this)(0,1) << ")"
51  << std::endl;
52  os << "(yx,yy)=("
53  << std::setw(8) << (*this)(1,0) << ", "
54  << std::setw(8) << (*this)(1,1) << ")"
55  << std::endl;
56 
57 #endif
58 #if LIBMESH_DIM == 3
59 
60  os << "(xx,xy,xz)=("
61  << std::setw(8) << (*this)(0,0) << ", "
62  << std::setw(8) << (*this)(0,1) << ", "
63  << std::setw(8) << (*this)(0,2) << ")"
64  << std::endl;
65  os << "(yx,yy,yz)=("
66  << std::setw(8) << (*this)(1,0) << ", "
67  << std::setw(8) << (*this)(1,1) << ", "
68  << std::setw(8) << (*this)(1,2) << ")"
69  << std::endl;
70  os << "(zx,zy,zz)=("
71  << std::setw(8) << (*this)(2,0) << ", "
72  << std::setw(8) << (*this)(2,1) << ", "
73  << std::setw(8) << (*this)(2,2) << ")"
74  << std::endl;
75 #endif
76 }

◆ row()

template<typename T >
TypeVector< T > libMesh::TypeTensor< T >::row ( const unsigned int  r) const
inlineinherited
Returns
A copy of one row of the tensor as a TypeVector.

Definition at line 765 of file type_tensor.h.

References libMesh::TypeVector< T >::_coords.

Referenced by TypeTensorTest::testRowCol().

766 {
767  TypeVector<T> return_vector;
768 
769  for (unsigned int j=0; j<LIBMESH_DIM; j++)
770  return_vector._coords[j] = _coords[r*LIBMESH_DIM + j];
771 
772  return return_vector;
773 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ slice() [1/2]

template<typename T >
ConstTypeTensorColumn< T > libMesh::TypeTensor< T >::slice ( const unsigned int  i) const
inlineinherited
Returns
A proxy for the \( i^{th} \) column of the tensor.

Definition at line 745 of file type_tensor.h.

746 {
747  libmesh_assert_less (i, LIBMESH_DIM);
748  return ConstTypeTensorColumn<T>(*this, i);
749 }

◆ slice() [2/2]

template<typename T >
TypeTensorColumn< T > libMesh::TypeTensor< T >::slice ( const unsigned int  i)
inlineinherited
Returns
A writable proxy for the \( i^{th} \) column of the tensor.

Definition at line 755 of file type_tensor.h.

756 {
757  libmesh_assert_less (i, LIBMESH_DIM);
758  return TypeTensorColumn<T>(*this, i);
759 }

◆ solve()

template<typename T >
void libMesh::TypeTensor< T >::solve ( const TypeVector< T > &  b,
TypeVector< T > &  x 
) const
inlineinherited

Solve the 2x2 or 3x3 system of equations A*x = b for x by directly inverting A and multiplying it by b.

Returns
The solution in the x vector.

Definition at line 1129 of file type_tensor.h.

Referenced by InfFERadialTest::base_point(), and libMesh::InfFEMap::inverse_map().

1130 {
1131 #if LIBMESH_DIM == 1
1132  if (_coords[0] == static_cast<T>(0.))
1133  libmesh_convergence_failure();
1134  x(0) = b(0) / _coords[0];
1135 #endif
1136 
1137 #if LIBMESH_DIM == 2
1138  T my_det = _coords[0]*_coords[3] - _coords[1]*_coords[2];
1139 
1140  if (my_det == static_cast<T>(0.))
1141  libmesh_convergence_failure();
1142 
1143  T my_det_inv = 1./my_det;
1144 
1145  x(0) = my_det_inv*( _coords[3]*b(0) - _coords[1]*b(1));
1146  x(1) = my_det_inv*(-_coords[2]*b(0) + _coords[0]*b(1));
1147 #endif
1148 
1149 #if LIBMESH_DIM == 3
1150  T my_det =
1151  // a11*(a33 *a22 - a32 *a23)
1152  _coords[0]*(_coords[8]*_coords[4] - _coords[7]*_coords[5])
1153  // -a21*(a33 *a12 - a32 *a13)
1154  -_coords[3]*(_coords[8]*_coords[1] - _coords[7]*_coords[2]) +
1155  // +a31*(a23 *a12 - a22 *a13)
1156  +_coords[6]*(_coords[5]*_coords[1] - _coords[4]*_coords[2]);
1157 
1158  if (my_det == static_cast<T>(0.))
1159  libmesh_convergence_failure();
1160 
1161  T my_det_inv = 1./my_det;
1162  x(0) = my_det_inv*((_coords[8]*_coords[4] - _coords[7]*_coords[5])*b(0) -
1163  (_coords[8]*_coords[1] - _coords[7]*_coords[2])*b(1) +
1164  (_coords[5]*_coords[1] - _coords[4]*_coords[2])*b(2));
1165 
1166  x(1) = my_det_inv*((_coords[6]*_coords[5] - _coords[8]*_coords[3])*b(0) +
1167  (_coords[8]*_coords[0] - _coords[6]*_coords[2])*b(1) -
1168  (_coords[5]*_coords[0] - _coords[3]*_coords[2])*b(2));
1169 
1170  x(2) = my_det_inv*((_coords[7]*_coords[3] - _coords[6]*_coords[4])*b(0) -
1171  (_coords[7]*_coords[0] - _coords[6]*_coords[1])*b(1) +
1172  (_coords[4]*_coords[0] - _coords[3]*_coords[1])*b(2));
1173 #endif
1174 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ subtract()

template<typename T >
template<typename T2 >
void libMesh::TypeTensor< T >::subtract ( const TypeTensor< T2 > &  p)
inlineinherited

Subtract from this tensor without creating a temporary.

Definition at line 910 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

911 {
912  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
913  _coords[i] -= p._coords[i];
914 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ subtract_scaled()

template<typename T >
template<typename T2 >
void libMesh::TypeTensor< T >::subtract_scaled ( const TypeTensor< T2 > &  p,
const T &  factor 
)
inlineinherited

Subtract a scaled value from this tensor without creating a temporary.

Definition at line 921 of file type_tensor.h.

References libMesh::TypeTensor< T >::_coords.

Referenced by libMesh::HPCoarsenTest::select_refinement().

922 {
923  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
924  _coords[i] -= factor*p._coords[i];
925 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ tr()

template<typename T >
T libMesh::TypeTensor< T >::tr ( ) const
inlineinherited
Returns
The trace of the tensor.

Definition at line 1321 of file type_tensor.h.

1322 {
1323 #if LIBMESH_DIM == 1
1324  return _coords[0];
1325 #endif
1326 
1327 #if LIBMESH_DIM == 2
1328  return _coords[0] + _coords[3];
1329 #endif
1330 
1331 #if LIBMESH_DIM == 3
1332  return _coords[0] + _coords[4] + _coords[8];
1333 #endif
1334 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ transpose()

template<typename T >
TypeTensor< T > libMesh::TypeTensor< T >::transpose ( ) const
inlineinherited
Returns
The transpose of this tensor (with complex numbers not conjugated).

Definition at line 1050 of file type_tensor.h.

Referenced by assemble_shell(), and LargeDeformationElasticity::compute_stresses().

1051 {
1052 #if LIBMESH_DIM == 1
1053  return TypeTensor(_coords[0]);
1054 #endif
1055 
1056 #if LIBMESH_DIM == 2
1057  return TypeTensor(_coords[0],
1058  _coords[2],
1059  _coords[1],
1060  _coords[3]);
1061 #endif
1062 
1063 #if LIBMESH_DIM == 3
1064  return TypeTensor(_coords[0],
1065  _coords[3],
1066  _coords[6],
1067  _coords[1],
1068  _coords[4],
1069  _coords[7],
1070  _coords[2],
1071  _coords[5],
1072  _coords[8]);
1073 #endif
1074 }
TypeTensor()
Empty constructor.
Definition: type_tensor.h:510
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

◆ write_unformatted()

template<typename T >
void libMesh::TypeTensor< T >::write_unformatted ( std::ostream &  out_stream,
const bool  newline = true 
) const
inherited

Unformatted print to the stream out.

Simply prints the elements of the tensor separated by spaces and newlines.

Definition at line 83 of file type_tensor.C.

References libMesh::libmesh_assert().

85 {
86  libmesh_assert (out_stream);
87 
88  out_stream << std::setiosflags(std::ios::showpoint)
89  << (*this)(0,0) << " "
90  << (*this)(0,1) << " "
91  << (*this)(0,2) << " ";
92  if (newline)
93  out_stream << '\n';
94 
95  out_stream << std::setiosflags(std::ios::showpoint)
96  << (*this)(1,0) << " "
97  << (*this)(1,1) << " "
98  << (*this)(1,2) << " ";
99  if (newline)
100  out_stream << '\n';
101 
102  out_stream << std::setiosflags(std::ios::showpoint)
103  << (*this)(2,0) << " "
104  << (*this)(2,1) << " "
105  << (*this)(2,2) << " ";
106  if (newline)
107  out_stream << '\n';
108 }
libmesh_assert(ctx)

◆ zero()

template<typename T >
void libMesh::TypeTensor< T >::zero ( )
inlineinherited

Set all entries of the tensor to 0.

Definition at line 1338 of file type_tensor.h.

Referenced by LinearElasticityWithContact::compute_stresses(), LargeDeformationElasticity::compute_stresses(), NonlinearNeoHookeCurrentConfig::init_for_qp(), libMesh::TensorValue< T >::operator=(), and libMesh::TypeTensor< T >::operator=().

1339 {
1340  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
1341  _coords[i] = 0.;
1342 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
The coordinates of the TypeTensor.
Definition: type_tensor.h:444

Member Data Documentation

◆ _coords

template<typename T>
T libMesh::TypeTensor< T >::_coords[LIBMESH_DIM *LIBMESH_DIM]
protectedinherited

The documentation for this class was generated from the following files: