libMesh
Public Member Functions | Public Attributes | Static Private Member Functions | Friends | List of all members
libMesh::TypeNTensor< N, T > Class Template Reference

This class will eventually define a rank-N tensor in LIBMESH_DIM dimensional space of type T. More...

#include <tensor_tools.h>

Public Member Functions

 TypeNTensor ()
 
 TypeNTensor (const T &)
 
 TypeNTensor (const TypeVector< T > &)
 
 TypeNTensor (const TypeTensor< T > &)
 
 operator TypeVector< T > () const
 
 operator VectorValue< T > () const
 
 operator TypeTensor< T > () const
 
 operator TensorValue< T > () const
 
 ~TypeNTensor ()
 Destructor. More...
 
const TypeNTensor< N-1, T > slice (const unsigned int) const
 
TypeNTensor< N-1, T > slice (const unsigned int)
 
template<typename T2 >
TypeNTensor< N, typename CompareTypes< T, T2 >::supertype > operator+ (const TypeNTensor< N, T2 > &) const
 Add two tensors. More...
 
template<typename T2 >
const TypeNTensor< N, T > & operator+= (const TypeNTensor< N, T2 > &)
 Add to this tensor. More...
 
template<typename T2 >
TypeNTensor< N, typename CompareTypes< T, T2 >::supertype > operator- (const TypeNTensor< N, T2 > &) const
 Subtract two tensors. More...
 
template<typename T2 >
const TypeNTensor< N, T > & operator-= (const TypeNTensor< N, T2 > &)
 Subtract from this tensor. More...
 
TypeNTensor< N, T > operator- () const
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator* (const Scalar) const
 Multiply every entry of a tensor by a number. More...
 
template<typename Scalar >
const TypeNTensor< N, T > & operator*= (const Scalar)
 Multiply every entry of this tensor by a number. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar) const
 Divide every entry of a tensor by a number. More...
 
const TypeNTensor< N, T > & operator/= (const T)
 Divide every entry of this tensor by a number. More...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype contract (const TypeNTensor< N, T2 > &) const
 Multiply 2 tensors together, i.e. More...
 
Real size_sq () const
 
Real norm_sq () const
 
bool operator== (const TypeNTensor< N, T > &) const
 
bool operator< (const TypeNTensor< N, T > &) const
 
bool operator> (const TypeNTensor< N, T > &) const
 
void print (std::ostream &) const
 Do a formatted print of this tensor to a stream which defaults to libMesh::out. More...
 
template<typename T2 >
void add_scaled (const TypeNTensor< N, T2 > &, const T &)
 Add a scaled type N tensor to this type N tensor without creating a temporary. More...
 

Public Attributes

std::vector< T > _coords
 The coordinates of the TypeNTensor. More...
 

Static Private Member Functions

static constexpr int int_pow (int b, int e)
 

Friends

std::ostream & operator<< (std::ostream &os, const TypeNTensor< N, T > &t)
 Does a formatted print (as above) but supports the syntax: More...
 

Detailed Description

template<unsigned int N, typename T>
class libMesh::TypeNTensor< N, T >

This class will eventually define a rank-N tensor in LIBMESH_DIM dimensional space of type T.

Right now it defines a shim to allow for rank-independent code to compile (but not give correct results) in the case of vector-valued elements and second derivatives.

Author
Roy Stogner
Date
2012

Definition at line 34 of file tensor_tools.h.

Constructor & Destructor Documentation

template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::TypeNTensor ( )

Definition at line 50 of file type_n_tensor.h.

50 : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N))) {}
static constexpr int int_pow(int b, int e)
std::vector< T > _coords
The coordinates of the TypeNTensor.
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::TypeNTensor ( const T &  )

Definition at line 52 of file type_n_tensor.h.

52 : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N))) {}
static constexpr int int_pow(int b, int e)
std::vector< T > _coords
The coordinates of the TypeNTensor.
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::TypeNTensor ( const TypeVector< T > &  )

Definition at line 54 of file type_n_tensor.h.

54 : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N))) {}
static constexpr int int_pow(int b, int e)
std::vector< T > _coords
The coordinates of the TypeNTensor.
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::TypeNTensor ( const TypeTensor< T > &  )

Definition at line 56 of file type_n_tensor.h.

56 : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N))) {}
static constexpr int int_pow(int b, int e)
std::vector< T > _coords
The coordinates of the TypeNTensor.
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::~TypeNTensor ( )

Destructor.

Definition at line 67 of file type_n_tensor.h.

67 {}

Member Function Documentation

template<unsigned int N, typename T >
template<typename T2 >
void libMesh::TypeNTensor< N, T >::add_scaled ( const TypeNTensor< N, T2 > &  p,
const T &  factor 
)

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

Definition at line 232 of file type_n_tensor.h.

References libMesh::TypeNTensor< N, T >::_coords, and libMesh::TypeNTensor< N, T >::int_pow().

233 {
234  unsigned int size = int_pow(LIBMESH_DIM, N);
235  for (unsigned int i = 0; i < size ; i++)
236  _coords[i] += factor*p._coords[i];
237 }
static constexpr int int_pow(int b, int e)
std::vector< T > _coords
The coordinates of the TypeNTensor.
template<unsigned int N, typename T>
template<typename T2 >
CompareTypes<T,T2>::supertype libMesh::TypeNTensor< N, T >::contract ( const TypeNTensor< N, T2 > &  ) const

Multiply 2 tensors together, i.e.

dyadic product sum_ij Aij*Bij. The tensors may be of different types.

Definition at line 153 of file type_n_tensor.h.

Referenced by libMesh::TensorTools::inner_product().

153 { return 0; }
template<unsigned int N, typename T>
static constexpr int libMesh::TypeNTensor< N, T >::int_pow ( int  b,
int  e 
)
staticprivate

Definition at line 222 of file type_n_tensor.h.

Referenced by libMesh::TypeNTensor< N, T >::add_scaled().

223  {
224  return (e == 0) ? 1 : b * int_pow(b, e - 1);
225  }
static constexpr int int_pow(int b, int e)
template<unsigned int N, typename T>
Real libMesh::TypeNTensor< N, T >::norm_sq ( ) const
Returns
The Frobenius norm of the tensor squared, i.e. the sum of the entry magnitudes squared.

Definition at line 169 of file type_n_tensor.h.

169 { return 0.;}
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::operator TensorValue< T > ( ) const

Definition at line 62 of file type_n_tensor.h.

62 { libmesh_not_implemented(); return 0; }
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::operator TypeTensor< T > ( ) const

Definition at line 61 of file type_n_tensor.h.

61 { libmesh_not_implemented(); return 0; }
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::operator TypeVector< T > ( ) const

Definition at line 58 of file type_n_tensor.h.

58 { libmesh_not_implemented(); return 0; }
template<unsigned int N, typename T>
libMesh::TypeNTensor< N, T >::operator VectorValue< T > ( ) const

Definition at line 59 of file type_n_tensor.h.

59 { libmesh_not_implemented(); return 0; }
template<unsigned int N, typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype> >::type libMesh::TypeNTensor< N, T >::operator* ( const Scalar  ) const

Multiply every entry of a tensor by a number.

Definition at line 124 of file type_n_tensor.h.

125  { return TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype>(); }
template<unsigned int N, typename T>
template<typename Scalar >
const TypeNTensor<N,T>& libMesh::TypeNTensor< N, T >::operator*= ( const Scalar  )

Multiply every entry of this tensor by a number.

Definition at line 131 of file type_n_tensor.h.

131 { return *this; }
template<unsigned int N, typename T>
template<typename T2 >
TypeNTensor<N,typename CompareTypes<T, T2>::supertype> libMesh::TypeNTensor< N, T >::operator+ ( const TypeNTensor< N, T2 > &  ) const

Add two tensors.

Definition at line 86 of file type_n_tensor.h.

87  { return TypeNTensor<N,typename CompareTypes<T,T2>::supertype>(); }
template<unsigned int N, typename T>
template<typename T2 >
const TypeNTensor<N,T>& libMesh::TypeNTensor< N, T >::operator+= ( const TypeNTensor< N, T2 > &  )

Add to this tensor.

Definition at line 93 of file type_n_tensor.h.

94  { return *this; }
template<unsigned int N, typename T>
template<typename T2 >
TypeNTensor<N,typename CompareTypes<T, T2>::supertype> libMesh::TypeNTensor< N, T >::operator- ( const TypeNTensor< N, T2 > &  ) const

Subtract two tensors.

Definition at line 101 of file type_n_tensor.h.

102  { return TypeNTensor<N,typename CompareTypes<T,T2>::supertype>(); }
template<unsigned int N, typename T>
TypeNTensor<N,T> libMesh::TypeNTensor< N, T >::operator- ( ) const
Returns
The negative of a tensor.

Definition at line 114 of file type_n_tensor.h.

115  { return *this; }
template<unsigned int N, typename T>
template<typename T2 >
const TypeNTensor<N,T>& libMesh::TypeNTensor< N, T >::operator-= ( const TypeNTensor< N, T2 > &  )

Subtract from this tensor.

Definition at line 108 of file type_n_tensor.h.

109  { return *this; }
template<unsigned int N, typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype> >::type libMesh::TypeNTensor< N, T >::operator/ ( const Scalar  ) const

Divide every entry of a tensor by a number.

Definition at line 140 of file type_n_tensor.h.

140 { return *this; }
template<unsigned int N, typename T>
const TypeNTensor<N,T>& libMesh::TypeNTensor< N, T >::operator/= ( const T  )

Divide every entry of this tensor by a number.

Definition at line 145 of file type_n_tensor.h.

145 { return *this; }
template<unsigned int N, typename T>
bool libMesh::TypeNTensor< N, T >::operator< ( const TypeNTensor< N, T > &  ) const
Returns
true if this tensor is "less" than another.

Useful for sorting.

Definition at line 182 of file type_n_tensor.h.

183  { return false; }
template<unsigned int N, typename T>
bool libMesh::TypeNTensor< N, T >::operator== ( const TypeNTensor< N, T > &  ) const
Returns
true if two tensors are equal, false otherwise.

Definition at line 174 of file type_n_tensor.h.

175  { return true; }
template<unsigned int N, typename T>
bool libMesh::TypeNTensor< N, T >::operator> ( const TypeNTensor< N, T > &  ) const
Returns
true if this tensor is "greater" than another.

Definition at line 188 of file type_n_tensor.h.

189  { return false; }
template<unsigned int N, typename T>
void libMesh::TypeNTensor< N, T >::print ( std::ostream &  ) const

Do a formatted print of this tensor to a stream which defaults to libMesh::out.

Definition at line 195 of file type_n_tensor.h.

195 {}
template<unsigned int N, typename T>
Real libMesh::TypeNTensor< N, T >::size_sq ( ) const
Returns
The Frobenius norm of the tensor squared, i.e. the sum of the entry magnitudes squared.
Deprecated:
Use the norm_sq() function instead.

Definition at line 162 of file type_n_tensor.h.

162 { libmesh_deprecated(); return 0.;}
template<unsigned int N, typename T>
const TypeNTensor<N-1,T> libMesh::TypeNTensor< N, T >::slice ( const unsigned  int) const
Returns
A proxy for the $ i^{th} $ slice of the tensor.

Definition at line 72 of file type_n_tensor.h.

73  { return TypeNTensor<N-1,T>(); }
template<unsigned int N, typename T>
TypeNTensor<N-1,T> libMesh::TypeNTensor< N, T >::slice ( const unsigned  int)
Returns
A writable proxy for the $ i^{th} $ slice of the tensor.

Definition at line 78 of file type_n_tensor.h.

79  { return TypeNTensor<N-1,T>(); }

Friends And Related Function Documentation

template<unsigned int N, typename T>
std::ostream& operator<< ( std::ostream &  os,
const TypeNTensor< N, T > &  t 
)
friend

Does a formatted print (as above) but supports the syntax:

std::cout << t << std::endl;

Definition at line 203 of file type_n_tensor.h.

205  {
206  t.print(os);
207  return os;
208  }

Member Data Documentation

template<unsigned int N, typename T>
std::vector<T> libMesh::TypeNTensor< N, T >::_coords

The coordinates of the TypeNTensor.

Definition at line 219 of file type_n_tensor.h.

Referenced by libMesh::TypeNTensor< N, T >::add_scaled().


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