Poster of Linux kernelThe best gift for a Linux geek
TensorValue

TensorValue

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

TensorValue -  

SYNOPSIS


#include <tensor_value.h>

Inherits TypeTensor< T >.  

Public Member Functions


TensorValue (const T xx=0., 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.)

template<typename T2 > TensorValue (const TypeVector< T2 > &vx)

template<typename T2 > TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy)

template<typename T2 > TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy, const TypeVector< T2 > &vz)

template<typename T2 > TensorValue (const TensorValue< T2 > &p)

template<typename T2 > TensorValue (const TypeTensor< T2 > &p)

TensorValue (const TypeTensor< Real > &p_re, const TypeTensor< Real > &p_im)

template<typename T2 > void assign (const TypeTensor< T2 > &)

T operator() (const unsigned int i, const unsigned int j) const

T & operator() (const unsigned int i, const unsigned int j)

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

template<typename T2 > const TypeTensor< T > & operator+= (const TypeTensor< T2 > &)

template<typename T2 > void add (const TypeTensor< T2 > &)

template<typename T2 > void add_scaled (const TypeTensor< T2 > &, const T)

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

TypeTensor< T > operator- () const

template<typename T2 > const TypeTensor< T > & operator-= (const TypeTensor< T2 > &)

template<typename T2 > void subtract (const TypeTensor< T2 > &)

template<typename T2 > void subtract_scaled (const TypeTensor< T2 > &, const T)

template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type operator* (const Scalar) const

template<typename T2 > TypeTensor< T > operator* (const TypeTensor< T2 > &) const

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

template<typename Scalar > const TypeTensor< T > & operator*= (const Scalar)

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

const TypeTensor< T > & operator/= (const T)

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

TypeTensor< T > transpose () const

Real size () const

Real size_sq () const

T det () const

T tr () const

void zero ()

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) const

void write_unformatted (std::ostream &out, const bool newline=true) const
 

Public Attributes


T _coords [LIBMESH_DIM *LIBMESH_DIM]
 

Friends


std::ostream & operator<< (std::ostream &os, const TypeTensor< T > &t)
 

Detailed Description

 

template<typename T> class 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 2004

Definition at line 42 of file tensor_value.h.  

Constructor & Destructor Documentation

 

template<typename T > TensorValue< T >::TensorValue (const Txx = 0., const Txy = 0., const Txz = 0., const Tyx = 0., const Tyy = 0., const Tyz = 0., const Tzx = 0., const Tzy = 0., const Tzz = 0.) [inline]Constructor. By default sets all entries to 0.

Definition at line 124 of file tensor_value.h.

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

template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeVector< T2 > &vx) [inline]Constructor. Takes 1 row vector for LIBMESH_DIM=1

Definition at line 152 of file tensor_value.h.

                                                     :
  TypeTensor<T> (vx)
{
}
 

template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy) [inline]Constructor. Takes 2 row vectors for LIBMESH_DIM=2

Definition at line 162 of file tensor_value.h.

                                                       :
  TypeTensor<T> (vx, vy)
{
}
 

template<typename T > template<typename T2 > 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 173 of file tensor_value.h.

                                                       :
  TypeTensor<T> (vx, vy, vz)
{
}
 

template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TensorValue< T2 > &p) [inline]Copy-constructor.

Definition at line 142 of file tensor_value.h.

                                                     :
  TypeTensor<T> (p)
{
}
 

template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeTensor< T2 > &p) [inline]Copy-constructor.

Definition at line 185 of file tensor_value.h.

                                                    :
  TypeTensor<T> (p)
{
}
 

template<typename T > 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 194 of file tensor_value.h.

                                                           :
  TypeTensor<T> (Complex (p_re(0,0), p_im(0,0)),
                 Complex (p_re(0,1), p_im(0,1)),
                 Complex (p_re(0,2), p_im(0,2)),
                 Complex (p_re(1,0), p_im(1,0)),
                 Complex (p_re(1,1), p_im(1,1)),
                 Complex (p_re(1,2), p_im(1,2)),
                 Complex (p_re(2,0), p_im(2,0)),
                 Complex (p_re(2,1), p_im(2,1)),
                 Complex (p_re(2,2), p_im(2,2)))
{
}
 

Member Function Documentation

 

template<typename T > template<typename T2 > void TypeTensor< T >::add (const TypeTensor< T2 > &p) [inline, inherited]Add to this tensor without creating a temporary.

Definition at line 502 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by TypeVector< T >::operator+=(), and TypeTensor< T >::operator+=().

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] += p._coords[i];
}
 

template<typename T > template<typename T2 > void TypeTensor< T >::add_scaled (const TypeTensor< T2 > &p, const Tfactor) [inline, inherited]Add a scaled tensor to this tensor without creating a temporary.

Definition at line 513 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by HPCoarsenTest::add_projection(), System::calculate_norm(), FEMContext::fixed_interior_hessian(), FEMContext::fixed_side_hessian(), MeshFunction::hessian(), FEMContext::interior_hessian(), PatchRecoveryErrorEstimator::EstimateError::operator()(), HPCoarsenTest::select_refinement(), and FEMContext::side_hessian().

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] += factor*p._coords[i];

}
 

template<typename T > template<typename T2 > void TypeTensor< T >::assign (const TypeTensor< T2 > &p) [inline, inherited]Assign to a tensor without creating a temporary.

Definition at line 401 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] = p._coords[i];
}
 

template<typename T > template<typename T2 > CompareTypes< T, T2 >::supertype TypeTensor< T >::contract (const TypeTensor< T2 > &t) const [inline, inherited]Multiply 2 tensors together, i.e. sum Aij*Bij. The tensors may be of different types.

Definition at line 811 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by HPCoarsenTest::add_projection(), and HPCoarsenTest::select_refinement().

{
  typename CompareTypes<T,T2>::supertype sum = 0.;
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    sum += _coords[i]*t._coords[i];
  return sum;
}
 

template<typename T > T TypeTensor< T >::det () const [inline, inherited]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 832 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by Sphere::Sphere().

{
#if LIBMESH_DIM == 1
  return _coords[0];
#endif

#if LIBMESH_DIM == 2
  return (_coords[0] * _coords[3]
          - _coords[1] * _coords[2]);
#endif

#if LIBMESH_DIM == 3
  return (_coords[0] * _coords[4] * _coords[8]
          + _coords[1] * _coords[5] * _coords[6]
          + _coords[2] * _coords[3] * _coords[7]
          - _coords[0] * _coords[5] * _coords[7]
          - _coords[1] * _coords[3] * _coords[8]
          - _coords[2] * _coords[4] * _coords[6]);
#endif
}
 

template<typename T > T TypeTensor< T >::operator() (const unsigned inti, const unsigned intj) const [inline, inherited]Return the $ i,j^{th} $ element of the tensor.

Definition at line 411 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  libmesh_assert (i<3);
  libmesh_assert (j<3);

#if LIBMESH_DIM < 3
  if (i >= LIBMESH_DIM || j >= LIBMESH_DIM)
    return 0.;
#endif
  
  return _coords[i*LIBMESH_DIM+j];
}
 

template<typename T > T & TypeTensor< T >::operator() (const unsigned inti, const unsigned intj) [inline, inherited]Return a writeable reference to the $ i^{th} $ element of the tensor.

Definition at line 429 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
#if LIBMESH_DIM < 3

  if (i >= LIBMESH_DIM || j >= LIBMESH_DIM)
    {
//       std::cerr << 'ERROR:  You are assigning to a tensor component' << std::endl
//              << 'that is out of range for the compiled LIBMESH_DIM!'      << std::endl
//              << ' LIBMESH_DIM=' << LIBMESH_DIM << ' , i=' << i << ' , j=' << j << std::endl;
      libmesh_error();
    }
  
#endif
  
  libmesh_assert (i<LIBMESH_DIM);
  libmesh_assert (j<LIBMESH_DIM);
  
  return _coords[i*LIBMESH_DIM+j];
}
 

template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type TypeTensor< T >::operator* (const Scalarfactor) const [inline, inherited]Multiply a tensor by a number, i.e. scale.

Definition at line 629 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  typedef typename CompareTypes<T, Scalar>::supertype TS;


#if LIBMESH_DIM == 1
  return TypeTensor<TS>(_coords[0]*factor);
#endif
  
#if LIBMESH_DIM == 2 
  return TypeTensor<TS>(_coords[0]*factor,
                        _coords[1]*factor,
                        _coords[2]*factor,
                        _coords[3]*factor);
#endif
  
#if LIBMESH_DIM == 3
  return TypeTensor<TS>(_coords[0]*factor,
                        _coords[1]*factor, 
                        _coords[2]*factor, 
                        _coords[3]*factor, 
                        _coords[4]*factor, 
                        _coords[5]*factor, 
                        _coords[6]*factor, 
                        _coords[7]*factor, 
                        _coords[8]*factor);
#endif  
}
 

template<typename T > template<typename T2 > TypeTensor< T > TypeTensor< T >::operator* (const TypeTensor< T2 > &p) const [inline, inherited]Multiply 2 tensors together, i.e. matrix product. The tensors may be of different types.

Definition at line 790 of file type_tensor.h.

{
  TypeTensor<T> returnval;
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      for (unsigned int k=0; k<LIBMESH_DIM; k++)
        returnval(i,j) += (*this)(i,k)*p(k,j);

  return returnval;
}
 

template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator* (const TypeVector< T2 > &p) const [inline, inherited]Multiply a tensor and vector together, i.e. matrix-vector product. The tensor and vector may be of different types.

Definition at line 775 of file type_tensor.h.

{
  TypeVector<typename CompareTypes<T,T2>::supertype> returnval;
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      returnval(i) += (*this)(i,j)*p(j);

  return returnval;
}
 

template<typename T > template<typename Scalar > const TypeTensor< T > & TypeTensor< T >::operator*= (const Scalarfactor) [inline, inherited]Multiply this tensor by a number, i.e. scale.

Definition at line 676 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] *= factor;

  return *this;
}
 

template<typename T > template<typename T2 > TypeTensor< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator+ (const TypeTensor< T2 > &p) const [inline, inherited]Add two tensors.

Definition at line 456 of file type_tensor.h.

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

{
 
#if LIBMESH_DIM == 1
  return TypeTensor(_coords[0] + p._coords[0]);
#endif

#if LIBMESH_DIM == 2 
  return TypeTensor(_coords[0] + p._coords[0],
                    _coords[1] + p._coords[1],
                    0.,
                    _coords[2] + p._coords[2],
                    _coords[3] + p._coords[3]);
#endif

#if LIBMESH_DIM == 3
  return TypeTensor(_coords[0] + p._coords[0],
                    _coords[1] + p._coords[1],
                    _coords[2] + p._coords[2],
                    _coords[3] + p._coords[3],
                    _coords[4] + p._coords[4],
                    _coords[5] + p._coords[5],
                    _coords[6] + p._coords[6],
                    _coords[7] + p._coords[7],
                    _coords[8] + p._coords[8]);
#endif
               
}
 

template<typename T > template<typename T2 > const TypeTensor< T > & TypeTensor< T >::operator+= (const TypeTensor< T2 > &p) [inline, inherited]Add to this tensor.

Definition at line 490 of file type_tensor.h.

References TypeTensor< T >::add().

{
  this->add (p);

  return *this;
}
 

template<typename T > template<typename T2 > TypeTensor< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator- (const TypeTensor< T2 > &p) const [inline, inherited]Subtract two tensors.

Definition at line 526 of file type_tensor.h.

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

{

#if LIBMESH_DIM == 1
  return TypeTensor(_coords[0] - p._coords[0]);
#endif

#if LIBMESH_DIM == 2 
  return TypeTensor(_coords[0] - p._coords[0],
                    _coords[1] - p._coords[1],
                    0.,
                    _coords[2] - p._coords[2],
                    _coords[3] - p._coords[3]);
#endif

#if LIBMESH_DIM == 3
  return TypeTensor(_coords[0] - p._coords[0],
                    _coords[1] - p._coords[1],
                    _coords[2] - p._coords[2],
                    _coords[3] - p._coords[3],
                    _coords[4] - p._coords[4],
                    _coords[5] - p._coords[5],
                    _coords[6] - p._coords[6],
                    _coords[7] - p._coords[7],
                    _coords[8] - p._coords[8]);
#endif

}
 

template<typename T > TypeTensor< T > TypeTensor< T >::operator- () const [inline, inherited]Return the opposite of a tensor

Definition at line 593 of file type_tensor.h.

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

{
  
#if LIBMESH_DIM == 1
  return TypeTensor(-_coords[0]);
#endif

#if LIBMESH_DIM == 2 
  return TypeTensor(-_coords[0],
                    -_coords[1],
                    -_coords[2],
                    -_coords[3]);
#endif

#if LIBMESH_DIM == 3
  return TypeTensor(-_coords[0],
                    -_coords[1], 
                    -_coords[2], 
                    -_coords[3], 
                    -_coords[4], 
                    -_coords[5], 
                    -_coords[6], 
                    -_coords[7], 
                    -_coords[8]);
#endif
  
}
 

template<typename T > template<typename T2 > const TypeTensor< T > & TypeTensor< T >::operator-= (const TypeTensor< T2 > &p) [inline, inherited]Subtract from this tensor.

Definition at line 560 of file type_tensor.h.

References TypeTensor< T >::subtract().

{
  this->subtract (p);

  return *this;
}
 

template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type TypeTensor< T >::operator/ (const Scalarfactor) const [inline, inherited]Divide a tensor by a number, i.e. scale.

Definition at line 693 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  libmesh_assert (factor != static_cast<T>(0.));

  typedef typename CompareTypes<T, Scalar>::supertype TS;
  
#if LIBMESH_DIM == 1
  return TypeTensor<TS>(_coords[0]/factor);
#endif
  
#if LIBMESH_DIM == 2 
  return TypeTensor<TS>(_coords[0]/factor,
                        _coords[1]/factor,
                        _coords[2]/factor,
                        _coords[3]/factor);
#endif
  
#if LIBMESH_DIM == 3
  return TypeTensor<TS>(_coords[0]/factor,
                        _coords[1]/factor, 
                        _coords[2]/factor, 
                        _coords[3]/factor, 
                        _coords[4]/factor, 
                        _coords[5]/factor, 
                        _coords[6]/factor, 
                        _coords[7]/factor, 
                        _coords[8]/factor);
#endif
  
}
 

template<typename T > const TypeTensor< T > & TypeTensor< T >::operator/= (const Tfactor) [inline, inherited]Divide this tensor by a number, i.e. scale.

Definition at line 758 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  libmesh_assert (factor != static_cast<T>(0.));
  
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] /= factor;

  return *this;
}
 

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

Definition at line 145 of file type_tensor.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      {
        if ((*this)(i,j).real() < rhs(i,j).real())
          return true;
        if ((*this)(i,j).real() > rhs(i,j).real())
          return false;
        if ((*this)(i,j).imag() < rhs(i,j).imag())
          return true;
        if ((*this)(i,j).imag() > rhs(i,j).imag())
          return false;
      }
  return false;
}
 

template<typename T> bool TypeTensor< T >::operator< (const TypeTensor< T > &rhs) const [inherited]Returns:

true if this tensor is 'less' than another. Useful for sorting.

 

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

Definition at line 112 of file type_tensor.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      {
        if ((*this)(i,j) < rhs(i,j))
          return true;
        if ((*this)(i,j) > rhs(i,j))
          return false;
      }
  return false;
}
 

template<typename T > bool TypeTensor< T >::operator== (const TypeTensor< T > &rhs) const [inline, inherited]Returns:

true if two tensors are equal valued.

Definition at line 894 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
#if LIBMESH_DIM == 1
  return (std::abs(_coords[0] - rhs._coords[0])
          < TOLERANCE);
#endif
  
#if LIBMESH_DIM == 2
  return ((std::abs(_coords[0] - rhs._coords[0]) +
           std::abs(_coords[1] - rhs._coords[1]) +
           std::abs(_coords[2] - rhs._coords[2]) +
           std::abs(_coords[3] - rhs._coords[3]))
          < 4.*TOLERANCE);
#endif
  
#if LIBMESH_DIM == 3
  return ((std::abs(_coords[0] - rhs._coords[0]) +
           std::abs(_coords[1] - rhs._coords[1]) +
           std::abs(_coords[2] - rhs._coords[2]) +
           std::abs(_coords[3] - rhs._coords[3]) +
           std::abs(_coords[4] - rhs._coords[4]) +
           std::abs(_coords[5] - rhs._coords[5]) +
           std::abs(_coords[6] - rhs._coords[6]) +
           std::abs(_coords[7] - rhs._coords[7]) +
           std::abs(_coords[8] - rhs._coords[8]))
          < 9.*TOLERANCE);
#endif
  
}
 

template<typename T> bool TypeTensor< T >::operator> (const TypeTensor< T > &rhs) const [inherited]Returns:

true if this tensor is 'greater' than another.

 

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

Definition at line 128 of file type_tensor.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      {
        if ((*this)(i,j) > rhs(i,j))
          return true;
        if ((*this)(i,j) < rhs(i,j))
          return false;
      }
  return false;
}
 

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

Definition at line 165 of file type_tensor.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    for (unsigned int j=0; j<LIBMESH_DIM; j++)
      {
        if ((*this)(i,j).real() > rhs(i,j).real())
          return true;
        if ((*this)(i,j).real() < rhs(i,j).real())
          return false;
        if ((*this)(i,j).imag() > rhs(i,j).imag())
          return true;
        if ((*this)(i,j).imag() < rhs(i,j).imag())
          return false;
      }
  return false;
}
 

template<typename T > void TypeTensor< T >::print (std::ostream &os) const [inherited]Formatted print to std::cout.

Definition at line 38 of file type_tensor.C.

{
#if LIBMESH_DIM == 1
  
  os << 'x=' << (*this)(0) << std::endl;
  
#endif
#if LIBMESH_DIM == 2
  
  os << '(xx,xy)=('
     << std::setw(8) << (*this)(0,0) << ', '
     << std::setw(8) << (*this)(0,1) << ')'
     << std::endl;
  os << '(yx,yy)=('
     << std::setw(8) << (*this)(1,0) << ', '
     << std::setw(8) << (*this)(1,1) << ')'
     << std::endl;

#endif
#if LIBMESH_DIM == 3
  
  os <<  '(xx,xy,xz)=('
     << std::setw(8) << (*this)(0,0) << ', '
     << std::setw(8) << (*this)(0,1) << ', '
     << std::setw(8) << (*this)(0,2) << ')'
     << std::endl;
  os <<  '(yx,yy,yz)=('
     << std::setw(8) << (*this)(1,0) << ', '
     << std::setw(8) << (*this)(1,1) << ', '
     << std::setw(8) << (*this)(1,2) << ')'
     << std::endl;
  os <<  '(zx,zy,zz)=('
     << std::setw(8) << (*this)(2,0) << ', '
     << std::setw(8) << (*this)(2,1) << ', '
     << std::setw(8) << (*this)(2,2) << ')'
     << std::endl;
#endif
}
 

template<typename T > Real TypeTensor< T >::size () const [inline, inherited]Returns the Frobenius norm of the tensor, i.e. the square-root of the sum of the elements squared.

Definition at line 823 of file type_tensor.h.

References TypeTensor< T >::size_sq().

Referenced by TypeVector< T >::unit().

{
  return std::sqrt(this->size_sq());  
}
 

template<typename T > Real TypeTensor< T >::size_sq () const [inline, inherited]Returns the Frobenius norm of the tensor squared, i.e. sum of the element magnitudes squared.

Definition at line 882 of file type_tensor.h.

References TypeTensor< T >::_coords, and libmesh_norm().

Referenced by ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), System::calculate_norm(), ExactErrorEstimator::find_squared_element_error(), HPCoarsenTest::select_refinement(), TypeVector< T >::size(), and TypeTensor< T >::size().

{
  Real sum = 0.;
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    sum += libmesh_norm(_coords[i]);
  return sum;
}
 

template<typename T > template<typename T2 > void TypeTensor< T >::subtract (const TypeTensor< T2 > &p) [inline, inherited]Subtract from this tensor without creating a temporary.

Definition at line 572 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by TypeVector< T >::operator-=(), and TypeTensor< T >::operator-=().

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] -= p._coords[i];
}
 

template<typename T > template<typename T2 > void TypeTensor< T >::subtract_scaled (const TypeTensor< T2 > &p, const Tfactor) [inline, inherited]Subtract a scaled value from this tensor without creating a temporary.

Definition at line 583 of file type_tensor.h.

References TypeTensor< T >::_coords.

Referenced by HPCoarsenTest::select_refinement().

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] -= factor*p._coords[i];
}
 

template<typename T > T TypeTensor< T >::tr () const [inline, inherited]Returns the trace of the tensor.

Definition at line 855 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
#if LIBMESH_DIM == 1
  return _coords[0];
#endif

#if LIBMESH_DIM == 2
  return _coords[0] + _coords[3];
#endif

#if LIBMESH_DIM == 3
  return _coords[0] + _coords[4] + _coords[8];
#endif
}
 

template<typename T > TypeTensor< T > TypeTensor< T >::transpose () const [inline, inherited]The transpose (with complex numbers not conjugated) of the tensor.

Definition at line 728 of file type_tensor.h.

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

{
#if LIBMESH_DIM == 1
  return TypeTensor(_coords[0]);
#endif
  
#if LIBMESH_DIM == 2 
  return TypeTensor(_coords[0],
                    _coords[2],
                    _coords[1],
                    _coords[3]);
#endif
  
#if LIBMESH_DIM == 3
  return TypeTensor(_coords[0],
                    _coords[3], 
                    _coords[6], 
                    _coords[1], 
                    _coords[4], 
                    _coords[7], 
                    _coords[2], 
                    _coords[5], 
                    _coords[8]);
#endif
}
 

template<typename T > void TypeTensor< T >::write_unformatted (std::ostream &out, const boolnewline = true) const [inherited]Unformatted print to the stream out. Simply prints the elements of the tensor separated by spaces and newlines.

Definition at line 82 of file type_tensor.C.

{
  libmesh_assert (out);

  out << std::setiosflags(std::ios::showpoint)
      << (*this)(0,0) << ' '
      << (*this)(0,1) << ' '
      << (*this)(0,2) << ' ';
  if (newline)
    out << ';      

  out << std::setiosflags(std::ios::showpoint)
      << (*this)(1,0) << ' '
      << (*this)(1,1) << ' '
      << (*this)(1,2) << ' ';
  if (newline)
    out << ';      

  out << std::setiosflags(std::ios::showpoint)
      << (*this)(2,0) << ' '
      << (*this)(2,1) << ' '
      << (*this)(2,2) << ' ';
  if (newline)
    out << ';      
}
 

template<typename T > void TypeTensor< T >::zero () [inline, inherited]Zero the tensor in any dimension.

Definition at line 872 of file type_tensor.h.

References TypeTensor< T >::_coords.

{
  for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)
    _coords[i] = 0.;
}
 

Friends And Related Function Documentation

 

template<typename T> std::ostream& operator<< (std::ostream &os, const TypeTensor< T > &t) [friend, inherited]Formatted print as above but allows you to do std::cout << t << std::endl;

Definition at line 281 of file type_tensor.h.

  {
    t.print(os);
    return os;
  }
 

Member Data Documentation

 

template<typename T> T TypeTensor< T >::_coords[LIBMESH_DIM *LIBMESH_DIM] [inherited]The coordinates of the TypeTensor

Definition at line 298 of file type_tensor.h.

Referenced by TypeVector< T >::absolute_fuzzy_equals(), TypeVector< T >::add(), TypeTensor< T >::add(), TypeVector< T >::add_scaled(), TypeTensor< T >::add_scaled(), TypeVector< T >::assign(), TypeTensor< T >::assign(), TypeTensor< T >::contract(), TypeVector< T >::cross(), TypeTensor< T >::det(), TypeVector< T >::operator()(), TypeTensor< T >::operator()(), TypeVector< T >::operator*(), TypeTensor< T >::operator*(), TypeVector< T >::operator*=(), TypeTensor< T >::operator*=(), TypeVector< T >::operator+(), TypeTensor< T >::operator+(), TypeVector< T >::operator-(), TypeTensor< T >::operator-(), TypeVector< T >::operator/(), TypeTensor< T >::operator/(), TypeVector< T >::operator/=(), TypeTensor< T >::operator/=(), TypeVector< T >::operator==(), TypeTensor< T >::operator==(), TypeVector< T >::relative_fuzzy_equals(), TypeVector< T >::size_sq(), TypeTensor< T >::size_sq(), TypeVector< T >::subtract(), TypeTensor< T >::subtract(), TypeVector< T >::subtract_scaled(), TypeTensor< T >::subtract_scaled(), TypeTensor< T >::tr(), TypeTensor< T >::transpose(), TypeTensor< T >::TypeTensor(), TypeVector< T >::TypeVector(), TypeVector< T >::unit(), TypeVector< T >::zero(), and TypeTensor< T >::zero().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Public Attributes
Friends
Detailed Description
template<typename T> class TensorValue< T >
Constructor & Destructor Documentation
template<typename T > TensorValue< T >::TensorValue (const Txx = 0., const Txy = 0., const Txz = 0., const Tyx = 0., const Tyy = 0., const Tyz = 0., const Tzx = 0., const Tzy = 0., const Tzz = 0.) [inline]Constructor. By default sets all entries to 0.
template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeVector< T2 > &vx) [inline]Constructor. Takes 1 row vector for LIBMESH_DIM=1
template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeVector< T2 > &vx, const TypeVector< T2 > &vy) [inline]Constructor. Takes 2 row vectors for LIBMESH_DIM=2
template<typename T > template<typename T2 > 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
template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TensorValue< T2 > &p) [inline]Copy-constructor.
template<typename T > template<typename T2 > TensorValue< T >::TensorValue (const TypeTensor< T2 > &p) [inline]Copy-constructor.
template<typename T > 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.
Member Function Documentation
template<typename T > template<typename T2 > void TypeTensor< T >::add (const TypeTensor< T2 > &p) [inline, inherited]Add to this tensor without creating a temporary.
template<typename T > template<typename T2 > void TypeTensor< T >::add_scaled (const TypeTensor< T2 > &p, const Tfactor) [inline, inherited]Add a scaled tensor to this tensor without creating a temporary.
template<typename T > template<typename T2 > void TypeTensor< T >::assign (const TypeTensor< T2 > &p) [inline, inherited]Assign to a tensor without creating a temporary.
template<typename T > template<typename T2 > CompareTypes< T, T2 >::supertype TypeTensor< T >::contract (const TypeTensor< T2 > &t) const [inline, inherited]Multiply 2 tensors together, i.e. sum Aij*Bij. The tensors may be of different types.
template<typename T > T TypeTensor< T >::det () const [inline, inherited]Returns the determinant of the tensor. Because these are 3x3 tensors at most, we don't do an LU decomposition like DenseMatrix does.
template<typename T > T TypeTensor< T >::operator() (const unsigned inti, const unsigned intj) const [inline, inherited]Return the $ i,j^{th} $ element of the tensor.
template<typename T > T & TypeTensor< T >::operator() (const unsigned inti, const unsigned intj) [inline, inherited]Return a writeable reference to the $ i^{th} $ element of the tensor.
template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type TypeTensor< T >::operator* (const Scalarfactor) const [inline, inherited]Multiply a tensor by a number, i.e. scale.
template<typename T > template<typename T2 > TypeTensor< T > TypeTensor< T >::operator* (const TypeTensor< T2 > &p) const [inline, inherited]Multiply 2 tensors together, i.e. matrix product. The tensors may be of different types.
template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator* (const TypeVector< T2 > &p) const [inline, inherited]Multiply a tensor and vector together, i.e. matrix-vector product. The tensor and vector may be of different types.
template<typename T > template<typename Scalar > const TypeTensor< T > & TypeTensor< T >::operator*= (const Scalarfactor) [inline, inherited]Multiply this tensor by a number, i.e. scale.
template<typename T > template<typename T2 > TypeTensor< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator+ (const TypeTensor< T2 > &p) const [inline, inherited]Add two tensors.
template<typename T > template<typename T2 > const TypeTensor< T > & TypeTensor< T >::operator+= (const TypeTensor< T2 > &p) [inline, inherited]Add to this tensor.
template<typename T > template<typename T2 > TypeTensor< typename CompareTypes< T, T2 >::supertype > TypeTensor< T >::operator- (const TypeTensor< T2 > &p) const [inline, inherited]Subtract two tensors.
template<typename T > TypeTensor< T > TypeTensor< T >::operator- () const [inline, inherited]Return the opposite of a tensor
template<typename T > template<typename T2 > const TypeTensor< T > & TypeTensor< T >::operator-= (const TypeTensor< T2 > &p) [inline, inherited]Subtract from this tensor.
template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type TypeTensor< T >::operator/ (const Scalarfactor) const [inline, inherited]Divide a tensor by a number, i.e. scale.
template<typename T > const TypeTensor< T > & TypeTensor< T >::operator/= (const Tfactor) [inline, inherited]Divide this tensor by a number, i.e. scale.
template<> bool TypeTensor< Complex >::operator< (const TypeTensor< Complex > &rhs) const [inherited]
template<typename T> bool TypeTensor< T >::operator< (const TypeTensor< T > &rhs) const [inherited]Returns:
template<> bool TypeTensor< Real >::operator< (const TypeTensor< Real > &rhs) const [inherited]
template<typename T > bool TypeTensor< T >::operator== (const TypeTensor< T > &rhs) const [inline, inherited]Returns:
template<typename T> bool TypeTensor< T >::operator> (const TypeTensor< T > &rhs) const [inherited]Returns:
template<> bool TypeTensor< Real >::operator> (const TypeTensor< Real > &rhs) const [inherited]
template<> bool TypeTensor< Complex >::operator> (const TypeTensor< Complex > &rhs) const [inherited]
template<typename T > void TypeTensor< T >::print (std::ostream &os) const [inherited]Formatted print to std::cout.
template<typename T > Real TypeTensor< T >::size () const [inline, inherited]Returns the Frobenius norm of the tensor, i.e. the square-root of the sum of the elements squared.
template<typename T > Real TypeTensor< T >::size_sq () const [inline, inherited]Returns the Frobenius norm of the tensor squared, i.e. sum of the element magnitudes squared.
template<typename T > template<typename T2 > void TypeTensor< T >::subtract (const TypeTensor< T2 > &p) [inline, inherited]Subtract from this tensor without creating a temporary.
template<typename T > template<typename T2 > void TypeTensor< T >::subtract_scaled (const TypeTensor< T2 > &p, const Tfactor) [inline, inherited]Subtract a scaled value from this tensor without creating a temporary.
template<typename T > T TypeTensor< T >::tr () const [inline, inherited]Returns the trace of the tensor.
template<typename T > TypeTensor< T > TypeTensor< T >::transpose () const [inline, inherited]The transpose (with complex numbers not conjugated) of the tensor.
template<typename T > void TypeTensor< T >::write_unformatted (std::ostream &out, const boolnewline = true) const [inherited]Unformatted print to the stream out. Simply prints the elements of the tensor separated by spaces and newlines.
template<typename T > void TypeTensor< T >::zero () [inline, inherited]Zero the tensor in any dimension.
Friends And Related Function Documentation
template<typename T> std::ostream& operator<< (std::ostream &os, const TypeTensor< T > &t) [friend, inherited]Formatted print as above but allows you to do std::cout << t << std::endl;
Member Data Documentation
template<typename T> T TypeTensor< T >::_coords[LIBMESH_DIM *LIBMESH_DIM] [inherited]The coordinates of the TypeTensor
Author

This document was created by man2html, using the manual pages.
Time: 21:57:09 GMT, April 16, 2011