Poster of Linux kernelThe best gift for a Linux geek
TypeVector

TypeVector

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

NAME

TypeVector -  

SYNOPSIS


#include <type_vector.h>

Inherited by VectorValue< T >.  

Public Member Functions


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

virtual ~TypeVector ()

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

T operator() (const unsigned int i) const

T & operator() (const unsigned int i)

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

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

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

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

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

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

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

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

TypeVector< T > operator- () const

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

const TypeVector< T > & operator*= (const T)

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

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

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

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

TypeVector< T > unit () const

Real size () const

Real size_sq () const

void zero ()

bool relative_fuzzy_equals (const TypeVector< T > &rhs, Real tol=TOLERANCE) const

bool absolute_fuzzy_equals (const TypeVector< T > &rhs, Real tol=TOLERANCE) const

bool operator== (const TypeVector< T > &rhs) const

bool operator!= (const TypeVector< T > &rhs) const

bool operator< (const TypeVector< T > &rhs) const

bool operator> (const TypeVector< T > &rhs) const

void print (std::ostream &os) const

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

template<> bool operator< (const TypeVector< Complex > &rhs) const

template<> bool operator> (const TypeVector< Complex > &rhs) const
 

Protected Member Functions


TypeVector (const T x=0., const T y=0., const T z=0.)
 

Protected Attributes


T _coords [LIBMESH_DIM]
 

Friends


class TypeVector

class TypeTensor< T >

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

Detailed Description

 

template<typename T> class TypeVector< T >

This class defines a vector in LIBMESH_DIM dimensional space of type T. T may either be Real or Complex. The default constructor for this class is protected, suggesting that you should not instantiate one of these directly. Instead use one of the derived types: Point for a real-valued point in LIBMESH_DIM-space, or SpaceVector for a real or complex-valued vector in LIBMESH_DIM-space.

Author:

Benjamin S. Kirk, 2003.

Definition at line 49 of file type_vector.h.  

Constructor & Destructor Documentation

 

template<typename T> TypeVector< T >::TypeVector (const Tx = 0., const Ty = 0., const Tz = 0.) [inline, protected]Constructor. By default sets all entries to 0. Gives the vector 0 in LIBMESH_DIM dimensions.

Definition at line 295 of file type_vector.h.

References TypeTensor< T >::_coords.

{
  _coords[0] = x;

  if (LIBMESH_DIM > 1)
    {
      _coords[1] = y;

      if (LIBMESH_DIM == 3)
        _coords[2] = z;
    }
}
 

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

Definition at line 315 of file type_vector.h.

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

{
  // copy the nodes from vector p to me
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] = p._coords[i];
}
 

template<typename T > TypeVector< T >::~TypeVector () [inline, virtual]Destructor.

Definition at line 326 of file type_vector.h.

{
}
 

Member Function Documentation

 

template<typename T> bool TypeVector< T >::absolute_fuzzy_equals (const TypeVector< T > &rhs, Realtol = TOLERANCE) const [inline]Returns:

true iff two vectors occupy approximately the same physical location in space, to within an absolute tolerance of tol.

Definition at line 755 of file type_vector.h.

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

Referenced by LocationMap< T >::find().

{
#if LIBMESH_DIM == 1
  return (std::abs(_coords[0] - rhs._coords[0])
          <= tol);
#endif

#if LIBMESH_DIM == 2
  return (std::abs(_coords[0] - rhs._coords[0]) +
          std::abs(_coords[1] - rhs._coords[1])
          <= tol);
#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])
          <= tol);
#endif
}
 

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

Definition at line 426 of file type_vector.h.

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

Referenced by Elem::centroid(), InfFE< Dim, T_radial, T_map >::inverse_map(), FE< Dim, T >::inverse_map(), LaplaceMeshSmoother::smooth(), and MeshTools::Modification::smooth().

{
#if LIBMESH_DIM == 1
  _coords[0] += p._coords[0];
#endif
  
#if LIBMESH_DIM == 2
  _coords[0] += p._coords[0];
  _coords[1] += p._coords[1];
#endif
  
#if LIBMESH_DIM == 3
  _coords[0] += p._coords[0];
  _coords[1] += p._coords[1];
  _coords[2] += p._coords[2];
#endif

}
 

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

Definition at line 450 of file type_vector.h.

References TypeTensor< T >::_coords.

Referenced by HPCoarsenTest::add_projection(), KellyErrorEstimator::boundary_side_integration(), System::calculate_norm(), Elem::coarsen(), FEBase::coarsened_dof_values(), FEXYZ< Dim >::compute_face_values(), FEMContext::fixed_interior_gradient(), FEMContext::fixed_side_gradient(), MeshFunction::gradient(), FEMContext::interior_gradient(), KellyErrorEstimator::internal_side_integration(), InfFE< Dim, T_radial, T_map >::inverse_map(), InfFE< Dim, T_radial, T_map >::map(), FE< Dim, T >::map(), FE< Dim, T >::map_eta(), FE< Dim, T >::map_xi(), FE< Dim, T >::map_zeta(), PatchRecoveryErrorEstimator::EstimateError::operator()(), HPCoarsenTest::select_refinement(), FEMContext::side_gradient(), and MeshTools::Modification::smooth().

{
#if LIBMESH_DIM == 1
  _coords[0] += factor*p(0);
#endif
  
#if LIBMESH_DIM == 2
  _coords[0] += factor*p(0);
  _coords[1] += factor*p(1);
#endif
  
#if LIBMESH_DIM == 3
  _coords[0] += factor*p(0);
  _coords[1] += factor*p(1);
  _coords[2] += factor*p(2);
#endif

}
 

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

Definition at line 335 of file type_vector.h.

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

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

template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeVector< T >::cross (const TypeVector< T2 > &p) constCross 2 vectors together, i.e. cross-product.

Definition at line 696 of file type_vector.h.

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

Referenced by FEBase::compute_face_map(), FEXYZ< Dim >::compute_face_values(), Plane::create_from_three_points(), Tri3::volume(), Quad4::volume(), Tet4::volume(), Pyramid5::volume(), Prism6::volume(), and Hex8::volume().

{
  typedef typename CompareTypes<T, T2>::supertype TS;
  libmesh_assert (LIBMESH_DIM == 3);

  // |     i          j          k    |
  // |(*this)(0) (*this)(1) (*this)(2)|
  // |   p(0)       p(1)       p(2)   |

  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
                        -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
                         _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
}
 

template<typename T> bool TypeVector< T >::operator!= (const TypeVector< T > &rhs) constReturns:

true iff two vectors do not occupy approximately the same physical location in space.

 

template<typename T > T TypeVector< T >::operator() (const unsigned inti) const [inline]Return the $ i^{th} $ element of the vector.

Definition at line 345 of file type_vector.h.

References TypeTensor< T >::_coords.

{
  libmesh_assert (i<3);

#if LIBMESH_DIM < 3
  
  if (i > (LIBMESH_DIM-1))
    return 0.;
  
#endif
  
  return _coords[i];
}
 

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

Definition at line 363 of file type_vector.h.

References TypeTensor< T >::_coords.

{
#if LIBMESH_DIM < 3

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

template<typename T > template<typename T2 > CompareTypes< T, T2 >::supertype TypeVector< T >::operator* (const TypeVector< T2 > &p) const [inline]Multiply 2 vectors together, i.e. dot-product. The vectors may be of different types.

Definition at line 673 of file type_vector.h.

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

{
#if LIBMESH_DIM == 1
  return _coords[0]*p._coords[0];
#endif
  
#if LIBMESH_DIM == 2
  return (_coords[0]*p._coords[0] +
          _coords[1]*p._coords[1]);
#endif
  
#if LIBMESH_DIM == 3
  return (_coords[0]*p(0) +
          _coords[1]*p(1) +
          _coords[2]*p(2));
#endif
}
 

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

Definition at line 562 of file type_vector.h.

References TypeTensor< T >::_coords.

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

#if LIBMESH_DIM == 1
  return TypeVector<TS>(_coords[0]*factor);
#endif
  
#if LIBMESH_DIM == 2 
  return TypeVector<TS>(_coords[0]*factor,
                        _coords[1]*factor);
#endif
  
#if LIBMESH_DIM == 3
  return TypeVector<TS>(_coords[0]*factor,
                        _coords[1]*factor, 
                        _coords[2]*factor);
#endif  
}
 

template<typename T> const TypeVector< T > & TypeVector< T >::operator*= (const Tfactor) [inline]Multiply this vector by a number, i.e. scale.

Definition at line 599 of file type_vector.h.

References TypeTensor< T >::_coords.

{
#if LIBMESH_DIM == 1
  _coords[0] *= factor;
#endif
  
#if LIBMESH_DIM == 2
  _coords[0] *= factor;
  _coords[1] *= factor;
#endif
  
#if LIBMESH_DIM == 3
  _coords[0] *= factor;
  _coords[1] *= factor;
  _coords[2] *= factor;
#endif

  return *this;
}
 

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

Definition at line 389 of file type_vector.h.

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

{
  typedef typename CompareTypes<T, T2>::supertype TS;
#if LIBMESH_DIM == 1
  return TypeVector<TS> (_coords[0] + p._coords[0]);
#endif

#if LIBMESH_DIM == 2 
  return TypeVector<TS> (_coords[0] + p._coords[0],
                         _coords[1] + p._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<TS> (_coords[0] + p._coords[0],
                         _coords[1] + p._coords[1],
                         _coords[2] + p._coords[2]);
#endif
               
}
 

template<typename T > template<typename T2 > const TypeVector< T > & TypeVector< T >::operator+= (const TypeVector< T2 > &p) [inline]Add to this vector.

Definition at line 414 of file type_vector.h.

References TypeTensor< T >::add().

{
  this->add (p);

  return *this;
}
 

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

Definition at line 475 of file type_vector.h.

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

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

#if LIBMESH_DIM == 1
  return TypeVector<TS>(_coords[0] - p._coords[0]);
#endif

#if LIBMESH_DIM == 2 
  return TypeVector<TS>(_coords[0] - p._coords[0],
                        _coords[1] - p._coords[1]);
#endif

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

}
 

template<typename T > TypeVector< T > TypeVector< T >::operator- () const [inline]Return the opposite of a vector

Definition at line 534 of file type_vector.h.

References TypeTensor< T >::_coords.

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

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

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

template<typename T > template<typename T2 > const TypeVector< T > & TypeVector< T >::operator-= (const TypeVector< T2 > &p) [inline]Subtract from this vector.

Definition at line 501 of file type_vector.h.

References TypeTensor< T >::subtract().

{
  this->subtract (p);

  return *this;
}
 

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

Definition at line 627 of file type_vector.h.

References TypeTensor< T >::_coords.

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

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

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

Definition at line 656 of file type_vector.h.

References TypeTensor< T >::_coords.

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

  return *this;
}
 

template<typename T> bool TypeVector< T >::operator< (const TypeVector< T > &rhs) constReturns:

true if this vector is 'less' than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 110 of file type_vector.C.

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

template<> bool TypeVector< Complex >::operator< (const TypeVector< Complex > &rhs) const

Definition at line 141 of file type_vector.C.

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

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

true iff two vectors occupy approximately the same physical location in space, to within an absolute tolerance of TOLERANCE.

Definition at line 805 of file type_vector.h.

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

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

#if LIBMESH_DIM == 2
  return (_coords[0] == rhs._coords[0] &&
          _coords[1] == rhs._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return (_coords[0] == rhs._coords[0] &&
          _coords[1] == rhs._coords[1] &&
          _coords[2] == rhs._coords[2]);
#endif
}
 

template<> bool TypeVector< Complex >::operator> (const TypeVector< Complex > &rhs) const

Definition at line 160 of file type_vector.C.

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

template<typename T> bool TypeVector< T >::operator> (const TypeVector< T > &rhs) constReturns:

true if this vector is 'greater' than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 125 of file type_vector.C.

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

template<typename T > void TypeVector< T >::print (std::ostream &os) constFormatted print to std::cout.

Definition at line 63 of file type_vector.C.

{
#if LIBMESH_DIM == 1
  
  os << 'x=' << (*this)(0) << ';
  
#endif
#if LIBMESH_DIM == 2
  
  os << '(x,y)=('
     << std::setw(8) << (*this)(0) << ', '
     << std::setw(8) << (*this)(1) << ')'
     << ';

#endif
#if LIBMESH_DIM == 3
  
  os <<  '(x,y,z)=('
     << std::setw(8) << (*this)(0) << ', '
     << std::setw(8) << (*this)(1) << ', '
     << std::setw(8) << (*this)(2) << ')'
     << ';
#endif
}
 

template<typename T> bool TypeVector< T >::relative_fuzzy_equals (const TypeVector< T > &rhs, Realtol = TOLERANCE) const [inline]Returns:

true iff two vectors occupy approximately the same physical location in space, to within a relative tolerance of tol.

Definition at line 780 of file type_vector.h.

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

Referenced by Quad9::has_affine_map(), Quad8::has_affine_map(), Quad4::has_affine_map(), Prism6::has_affine_map(), Prism18::has_affine_map(), Prism15::has_affine_map(), Hex8::has_affine_map(), Hex27::has_affine_map(), and Hex20::has_affine_map().

{
#if LIBMESH_DIM == 1
  return this->absolute_fuzzy_equals(rhs, tol *
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
#endif

#if LIBMESH_DIM == 2
  return this->absolute_fuzzy_equals(rhs, tol * 
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
                                      std::abs(_coords[1]) + std::abs(rhs._coords[1])));
#endif

#if LIBMESH_DIM == 3
  return this->absolute_fuzzy_equals(rhs, tol *
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
                                      std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
                                      std::abs(_coords[2]) + std::abs(rhs._coords[2])));
#endif
}
 

template<typename T > Real TypeVector< T >::size () const [inline]Returns the magnitude of the vector, i.e. the square-root of the sum of the elements squared.

Definition at line 714 of file type_vector.h.

References TypeTensor< T >::size_sq().

Referenced by Sphere::above_surface(), InfElemBuilder::build_inf_elem(), Elem::hmax(), Elem::hmin(), InfFE< Dim, T_radial, T_map >::inverse_map(), FE< Dim, T >::inverse_map(), FEInterface::inverse_map(), Tri3::min_and_max_angle(), Tet4::min_and_max_angle(), Sphere::on_surface(), Tri::quality(), MeshTools::Modification::smooth(), and Sphere::surface_coords().

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

template<typename T > Real TypeVector< T >::size_sq () const [inline]Returns the magnitude of the vector squared, i.e. the sum of the element magnitudes squared.

Definition at line 733 of file type_vector.h.

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

Referenced by ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), System::calculate_norm(), InfQuad4::contains_point(), InfPrism6::contains_point(), InfHex8::contains_point(), ExactErrorEstimator::find_squared_element_error(), PointLocatorList::operator()(), HPCoarsenTest::select_refinement(), Sphere::Sphere(), and Edge3::volume().

{
#if LIBMESH_DIM == 1
  return (libmesh_norm(_coords[0]));
#endif
  
#if LIBMESH_DIM == 2
  return (libmesh_norm(_coords[0]) +
          libmesh_norm(_coords[1]));
#endif
  
#if LIBMESH_DIM == 3
  return (libmesh_norm(_coords[0]) +
          libmesh_norm(_coords[1]) + 
          libmesh_norm(_coords[2]));
#endif
}
 

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

Definition at line 513 of file type_vector.h.

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

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

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

Definition at line 524 of file type_vector.h.

References TypeTensor< T >::_coords.

Referenced by HPCoarsenTest::select_refinement().

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

template<typename T > TypeVector< T > TypeVector< T >::unit () constThink of a vector as a dim dimensional vector. This will return a unit vector aligned in that direction.

Definition at line 36 of file type_vector.C.

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

Referenced by FEBase::compute_face_map(), FEXYZ< Dim >::compute_face_values(), Plane::create_from_point_normal(), Plane::create_from_three_points(), MeshTools::Modification::distort(), and Sphere::unit_normal().

{

  const Real length = size();
  
  libmesh_assert (length != static_cast<Real>(0.));
  
#if LIBMESH_DIM == 1
  return TypeVector<T>(_coords[0]/length);
#endif
  
#if LIBMESH_DIM == 2 
  return TypeVector<T>(_coords[0]/length,
                       _coords[1]/length);
#endif
  
#if LIBMESH_DIM == 3
  return TypeVector<T>(_coords[0]/length,
                       _coords[1]/length, 
                       _coords[2]/length);
#endif
  
}
 

template<typename T > void TypeVector< T >::write_unformatted (std::ostream &out, const boolnewline = true) constUnformatted print to the stream out. Simply prints the elements of the vector separated by spaces. Optionally prints a newline, which it does by default.

Definition at line 93 of file type_vector.C.

Referenced by InfElemBuilder::build_inf_elem(), TecplotIO::write_ascii(), and DivaIO::write_stream().

{
  libmesh_assert (out);

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

  if (newline)
    out << ';      
}
 

template<typename T > void TypeVector< T >::zero () [inline]Zero the vector in any dimension.

Definition at line 723 of file type_vector.h.

References TypeTensor< T >::_coords.

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

Friends And Related Function Documentation

 

template<typename T> std::ostream& operator<< (std::ostream &os, const TypeVector< T > &t) [friend]Formatted print as above but allows you to do Point p(1,2,3); std::cout << p << std::endl;

Definition at line 268 of file type_vector.h.

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

template<typename T> friend class TypeTensor< T > [friend]

Definition at line 54 of file type_vector.h.  

template<typename T> friend class TypeVector [friend]

Definition at line 52 of file type_vector.h.  

Member Data Documentation

 

template<typename T> T TypeVector< T >::_coords[LIBMESH_DIM] [protected]The coordinates of the TypeVector

Definition at line 286 of file type_vector.h.

Referenced by TypeVector< T >::absolute_fuzzy_equals(), TypeVector< T >::add(), TypeVector< T >::assign(), TypeVector< T >::cross(), TypeVector< T >::operator*(), TypeVector< T >::operator+(), TypeVector< T >::operator-(), TypeVector< T >::operator==(), TypeVector< T >::relative_fuzzy_equals(), TypeVector< T >::subtract(), and TypeVector< T >::TypeVector().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Protected Member Functions
Protected Attributes
Friends
Detailed Description
template<typename T> class TypeVector< T >
Constructor & Destructor Documentation
template<typename T> TypeVector< T >::TypeVector (const Tx = 0., const Ty = 0., const Tz = 0.) [inline, protected]Constructor. By default sets all entries to 0. Gives the vector 0 in LIBMESH_DIM dimensions.
template<typename T > template<typename T2 > TypeVector< T >::TypeVector (const TypeVector< T2 > &p) [inline]Copy-constructor.
template<typename T > TypeVector< T >::~TypeVector () [inline, virtual]Destructor.
Member Function Documentation
template<typename T> bool TypeVector< T >::absolute_fuzzy_equals (const TypeVector< T > &rhs, Realtol = TOLERANCE) const [inline]Returns:
template<typename T > template<typename T2 > void TypeVector< T >::add (const TypeVector< T2 > &p) [inline]Add to this vector without creating a temporary.
template<typename T> template<typename T2 > void TypeVector< T >::add_scaled (const TypeVector< T2 > &p, const Tfactor) [inline]Add a scaled value to this vector without creating a temporary.
template<typename T > template<typename T2 > void TypeVector< T >::assign (const TypeVector< T2 > &p) [inline]Assign to a vector without creating a temporary.
template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeVector< T >::cross (const TypeVector< T2 > &p) constCross 2 vectors together, i.e. cross-product.
template<typename T> bool TypeVector< T >::operator!= (const TypeVector< T > &rhs) constReturns:
template<typename T > T TypeVector< T >::operator() (const unsigned inti) const [inline]Return the $ i^{th} $ element of the vector.
template<typename T > T & TypeVector< T >::operator() (const unsigned inti) [inline]Return a writeable reference to the $ i^{th} $ element of the vector.
template<typename T > template<typename T2 > CompareTypes< T, T2 >::supertype TypeVector< T >::operator* (const TypeVector< T2 > &p) const [inline]Multiply 2 vectors together, i.e. dot-product. The vectors may be of different types.
template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type TypeVector< T >::operator* (const Scalarfactor) const [inline]Multiply a vector by a number, i.e. scale.
template<typename T> const TypeVector< T > & TypeVector< T >::operator*= (const Tfactor) [inline]Multiply this vector by a number, i.e. scale.
template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeVector< T >::operator+ (const TypeVector< T2 > &p) const [inline]Add two vectors.
template<typename T > template<typename T2 > const TypeVector< T > & TypeVector< T >::operator+= (const TypeVector< T2 > &p) [inline]Add to this vector.
template<typename T > template<typename T2 > TypeVector< typename CompareTypes< T, T2 >::supertype > TypeVector< T >::operator- (const TypeVector< T2 > &p) const [inline]Subtract two vectors.
template<typename T > TypeVector< T > TypeVector< T >::operator- () const [inline]Return the opposite of a vector
template<typename T > template<typename T2 > const TypeVector< T > & TypeVector< T >::operator-= (const TypeVector< T2 > &p) [inline]Subtract from this vector.
template<typename T > template<typename Scalar > boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type TypeVector< T >::operator/ (const Scalarfactor) const [inline]Divide a vector by a number, i.e. scale.
template<typename T> const TypeVector< T > & TypeVector< T >::operator/= (const Tfactor) [inline]Divide this vector by a number, i.e. scale.
template<typename T> bool TypeVector< T >::operator< (const TypeVector< T > &rhs) constReturns:
template<> bool TypeVector< Complex >::operator< (const TypeVector< Complex > &rhs) const
template<typename T> bool TypeVector< T >::operator== (const TypeVector< T > &rhs) const [inline]Returns:
template<> bool TypeVector< Complex >::operator> (const TypeVector< Complex > &rhs) const
template<typename T> bool TypeVector< T >::operator> (const TypeVector< T > &rhs) constReturns:
template<typename T > void TypeVector< T >::print (std::ostream &os) constFormatted print to std::cout.
template<typename T> bool TypeVector< T >::relative_fuzzy_equals (const TypeVector< T > &rhs, Realtol = TOLERANCE) const [inline]Returns:
template<typename T > Real TypeVector< T >::size () const [inline]Returns the magnitude of the vector, i.e. the square-root of the sum of the elements squared.
template<typename T > Real TypeVector< T >::size_sq () const [inline]Returns the magnitude of the vector squared, i.e. the sum of the element magnitudes squared.
template<typename T > template<typename T2 > void TypeVector< T >::subtract (const TypeVector< T2 > &p) [inline]Subtract from this vector without creating a temporary.
template<typename T> template<typename T2 > void TypeVector< T >::subtract_scaled (const TypeVector< T2 > &p, const Tfactor) [inline]Subtract a scaled value from this vector without creating a temporary.
template<typename T > TypeVector< T > TypeVector< T >::unit () constThink of a vector as a dim dimensional vector. This will return a unit vector aligned in that direction.
template<typename T > void TypeVector< T >::write_unformatted (std::ostream &out, const boolnewline = true) constUnformatted print to the stream out. Simply prints the elements of the vector separated by spaces. Optionally prints a newline, which it does by default.
template<typename T > void TypeVector< T >::zero () [inline]Zero the vector in any dimension.
Friends And Related Function Documentation
template<typename T> std::ostream& operator<< (std::ostream &os, const TypeVector< T > &t) [friend]Formatted print as above but allows you to do Point p(1,2,3); std::cout << p << std::endl;
template<typename T> friend class TypeTensor< T > [friend]
template<typename T> friend class TypeVector [friend]
Member Data Documentation
template<typename T> T TypeVector< T >::_coords[LIBMESH_DIM] [protected]The coordinates of the TypeVector
Author

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