TypeVector< T > Class Template Reference

#include <type_vector.h>

Inheritance diagram for TypeVector< T >:

List of all members.

Public Member Functions

template<typename T2 >
 TypeVector (const TypeVector< T2 > &p)
virtual ~TypeVector ()
template<typename T2 >
void assign (const TypeVector< T2 > &)
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
template<>
bool operator!= (const TypeVector< Real > &rhs) const

Protected Member Functions

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

Protected Attributes

_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 T  x = 0.,
const T  y = 0.,
const T  z = 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 TypeVector< T >::_coords.

00298 {
00299   _coords[0] = x;
00300 
00301   if (LIBMESH_DIM > 1)
00302     {
00303       _coords[1] = y;
00304 
00305       if (LIBMESH_DIM == 3)
00306         _coords[2] = z;
00307     }
00308 }

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.

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

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

Destructor.

Definition at line 326 of file type_vector.h.

00327 {
00328 }


Member Function Documentation

template<typename T >
bool TypeVector< T >::absolute_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = 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.

Referenced by LocationMap< T >::find(), and TypeVector< T >::relative_fuzzy_equals().

00756 {
00757 #if LIBMESH_DIM == 1
00758   return (std::abs(_coords[0] - rhs._coords[0])
00759           <= tol);
00760 #endif
00761 
00762 #if LIBMESH_DIM == 2
00763   return (std::abs(_coords[0] - rhs._coords[0]) +
00764           std::abs(_coords[1] - rhs._coords[1])
00765           <= tol);
00766 #endif
00767 
00768 #if LIBMESH_DIM == 3
00769   return (std::abs(_coords[0] - rhs._coords[0]) +
00770           std::abs(_coords[1] - rhs._coords[1]) +
00771           std::abs(_coords[2] - rhs._coords[2])
00772           <= tol);
00773 #endif
00774 }

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.

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

00427 {
00428 #if LIBMESH_DIM == 1
00429   _coords[0] += p._coords[0];
00430 #endif
00431   
00432 #if LIBMESH_DIM == 2
00433   _coords[0] += p._coords[0];
00434   _coords[1] += p._coords[1];
00435 #endif
00436   
00437 #if LIBMESH_DIM == 3
00438   _coords[0] += p._coords[0];
00439   _coords[1] += p._coords[1];
00440   _coords[2] += p._coords[2];
00441 #endif
00442 
00443 }

template<typename T >
template<typename T2 >
void TypeVector< T >::add_scaled ( const TypeVector< T2 > &  p,
const T  factor 
) [inline]

Add a scaled value to this vector without creating a temporary.

Definition at line 450 of file type_vector.h.

References TypeVector< T >::_coords.

Referenced by HPCoarsenTest::add_projection(), KellyErrorEstimator::boundary_side_integration(), System::calculate_norm(), Elem::coarsen(), FEBase::coarsened_dof_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(), 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().

00451 {
00452 #if LIBMESH_DIM == 1
00453   _coords[0] += factor*p(0);
00454 #endif
00455   
00456 #if LIBMESH_DIM == 2
00457   _coords[0] += factor*p(0);
00458   _coords[1] += factor*p(1);
00459 #endif
00460   
00461 #if LIBMESH_DIM == 3
00462   _coords[0] += factor*p(0);
00463   _coords[1] += factor*p(1);
00464   _coords[2] += factor*p(2);
00465 #endif
00466 
00467 }

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.

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

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

Cross 2 vectors together, i.e. cross-product.

Definition at line 696 of file type_vector.h.

References TypeVector< 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().

00697 {
00698   typedef typename CompareTypes<T, T2>::supertype TS;
00699   libmesh_assert (LIBMESH_DIM == 3);
00700 
00701   // |     i          j          k    |
00702   // |(*this)(0) (*this)(1) (*this)(2)|
00703   // |   p(0)       p(1)       p(2)   |
00704 
00705   return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
00706                         -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
00707                          _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
00708 }

template<>
bool TypeVector< Real >::operator!= ( const TypeVector< Real > &  rhs  )  const [inline]

Definition at line 827 of file type_vector.h.

00828 {
00829   return (!(*this == rhs));
00830 }

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

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

template<typename T >
T & TypeVector< T >::operator() ( const unsigned int  i  )  [inline]

Return a writeable reference to the $ i^{th} $ element of the vector.

Definition at line 363 of file type_vector.h.

References TypeVector< T >::_coords.

00364 {
00365 #if LIBMESH_DIM < 3
00366 
00367   if (i >= LIBMESH_DIM)
00368     {
00369 //       std::cerr << "ERROR:  You are assigning to a vector component" << std::endl
00370 //              << "that is out of range for the compiled LIBMESH_DIM!"      << std::endl
00371 //              << " LIBMESH_DIM=" << LIBMESH_DIM << " , i=" << i
00372 //              << std::endl;
00373       libmesh_error();
00374     }
00375   
00376 #endif
00377   
00378   libmesh_assert (i<LIBMESH_DIM);
00379   
00380   return _coords[i];
00381 }

template<typename T >
T TypeVector< T >::operator() ( const unsigned int  i  )  const [inline]

Return the $ i^{th} $ element of the vector.

Definition at line 345 of file type_vector.h.

References TypeVector< T >::_coords.

00346 {
00347   libmesh_assert (i<3);
00348 
00349 #if LIBMESH_DIM < 3
00350   
00351   if (i > (LIBMESH_DIM-1))
00352     return 0.;
00353   
00354 #endif
00355   
00356   return _coords[i];
00357 }

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.

00674 {
00675 #if LIBMESH_DIM == 1
00676   return _coords[0]*p._coords[0];
00677 #endif
00678   
00679 #if LIBMESH_DIM == 2
00680   return (_coords[0]*p._coords[0] +
00681           _coords[1]*p._coords[1]);
00682 #endif
00683   
00684 #if LIBMESH_DIM == 3
00685   return (_coords[0]*p(0) +
00686           _coords[1]*p(1) +
00687           _coords[2]*p(2));
00688 #endif
00689 }

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

Multiply a vector by a number, i.e. scale.

Definition at line 562 of file type_vector.h.

References TypeVector< T >::_coords.

00563 {
00564   typedef typename CompareTypes<T, Scalar>::supertype TS;
00565 
00566 #if LIBMESH_DIM == 1
00567   return TypeVector<TS>(_coords[0]*factor);
00568 #endif
00569   
00570 #if LIBMESH_DIM == 2 
00571   return TypeVector<TS>(_coords[0]*factor,
00572                         _coords[1]*factor);
00573 #endif
00574   
00575 #if LIBMESH_DIM == 3
00576   return TypeVector<TS>(_coords[0]*factor,
00577                         _coords[1]*factor, 
00578                         _coords[2]*factor);
00579 #endif  
00580 }

template<typename T >
const TypeVector< T > & TypeVector< T >::operator*= ( const T  factor  )  [inline]

Multiply this vector by a number, i.e. scale.

Definition at line 599 of file type_vector.h.

References TypeVector< T >::_coords.

00600 {
00601 #if LIBMESH_DIM == 1
00602   _coords[0] *= factor;
00603 #endif
00604   
00605 #if LIBMESH_DIM == 2
00606   _coords[0] *= factor;
00607   _coords[1] *= factor;
00608 #endif
00609   
00610 #if LIBMESH_DIM == 3
00611   _coords[0] *= factor;
00612   _coords[1] *= factor;
00613   _coords[2] *= factor;
00614 #endif
00615 
00616   return *this;
00617 }

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.

00390 {
00391   typedef typename CompareTypes<T, T2>::supertype TS;
00392 #if LIBMESH_DIM == 1
00393   return TypeVector<TS> (_coords[0] + p._coords[0]);
00394 #endif
00395 
00396 #if LIBMESH_DIM == 2 
00397   return TypeVector<TS> (_coords[0] + p._coords[0],
00398                          _coords[1] + p._coords[1]);
00399 #endif
00400 
00401 #if LIBMESH_DIM == 3
00402   return TypeVector<TS> (_coords[0] + p._coords[0],
00403                          _coords[1] + p._coords[1],
00404                          _coords[2] + p._coords[2]);
00405 #endif
00406                
00407 }

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.

00415 {
00416   this->add (p);
00417 
00418   return *this;
00419 }

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 TypeVector< T >::_coords, and TypeVector< T >::TypeVector.

00535 {
00536   
00537 #if LIBMESH_DIM == 1
00538   return TypeVector(-_coords[0]);
00539 #endif
00540 
00541 #if LIBMESH_DIM == 2 
00542   return TypeVector(-_coords[0],
00543                     -_coords[1]);
00544 #endif
00545 
00546 #if LIBMESH_DIM == 3
00547   return TypeVector(-_coords[0],
00548                     -_coords[1], 
00549                     -_coords[2]);
00550 #endif
00551   
00552 }

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.

00476 {
00477   typedef typename CompareTypes<T, T2>::supertype TS;
00478 
00479 #if LIBMESH_DIM == 1
00480   return TypeVector<TS>(_coords[0] - p._coords[0]);
00481 #endif
00482 
00483 #if LIBMESH_DIM == 2 
00484   return TypeVector<TS>(_coords[0] - p._coords[0],
00485                         _coords[1] - p._coords[1]);
00486 #endif
00487 
00488 #if LIBMESH_DIM == 3
00489   return TypeVector<TS>(_coords[0] - p._coords[0],
00490                         _coords[1] - p._coords[1],
00491                         _coords[2] - p._coords[2]);
00492 #endif
00493 
00494 }

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 TypeVector< T >::subtract().

00502 {
00503   this->subtract (p);
00504 
00505   return *this;
00506 }

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

Divide a vector by a number, i.e. scale.

Definition at line 627 of file type_vector.h.

References TypeVector< T >::_coords.

00628 {
00629   libmesh_assert (factor != static_cast<T>(0.));
00630 
00631   typedef typename CompareTypes<T, Scalar>::supertype TS;
00632   
00633 #if LIBMESH_DIM == 1
00634   return TypeVector<TS>(_coords[0]/factor);
00635 #endif
00636   
00637 #if LIBMESH_DIM == 2 
00638   return TypeVector<TS>(_coords[0]/factor,
00639                         _coords[1]/factor);
00640 #endif
00641   
00642 #if LIBMESH_DIM == 3
00643   return TypeVector<TS>(_coords[0]/factor,
00644                         _coords[1]/factor, 
00645                         _coords[2]/factor);
00646 #endif
00647   
00648 }

template<typename T >
const TypeVector< T > & TypeVector< T >::operator/= ( const T  factor  )  [inline]

Divide this vector by a number, i.e. scale.

Definition at line 656 of file type_vector.h.

References TypeVector< T >::_coords.

00657 {
00658   libmesh_assert (factor != static_cast<T>(0.));
00659   
00660   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00661     _coords[i] /= factor;
00662 
00663   return *this;
00664 }

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

Definition at line 141 of file type_vector.C.

00142 {
00143   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00144     {
00145       if ((*this)(i).real() < rhs(i).real())
00146         return true;
00147       if ((*this)(i).real() > rhs(i).real())
00148         return false;
00149       if ((*this)(i).imag() < rhs(i).imag())
00150         return true;
00151       if ((*this)(i).imag() > rhs(i).imag())
00152         return false;
00153     }
00154   return false;
00155 }

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

Returns:
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.

00111 {
00112   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00113     {
00114       if ((*this)(i) < rhs(i))
00115         return true;
00116       if ((*this)(i) > rhs(i))
00117         return false;
00118     }
00119   return false;
00120 }

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.

00806 {
00807 #if LIBMESH_DIM == 1
00808   return (_coords[0] == rhs._coords[0]);
00809 #endif
00810 
00811 #if LIBMESH_DIM == 2
00812   return (_coords[0] == rhs._coords[0] &&
00813           _coords[1] == rhs._coords[1]);
00814 #endif
00815 
00816 #if LIBMESH_DIM == 3
00817   return (_coords[0] == rhs._coords[0] &&
00818           _coords[1] == rhs._coords[1] &&
00819           _coords[2] == rhs._coords[2]);
00820 #endif
00821 }

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

Definition at line 160 of file type_vector.C.

00161 {
00162   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00163     {
00164       if ((*this)(i).real() > rhs(i).real())
00165         return true;
00166       if ((*this)(i).real() < rhs(i).real())
00167         return false;
00168       if ((*this)(i).imag() > rhs(i).imag())
00169         return true;
00170       if ((*this)(i).imag() < rhs(i).imag())
00171         return false;
00172     }
00173   return false;
00174 }

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

Returns:
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.

00126 {
00127   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00128     {
00129       if ((*this)(i) > rhs(i))
00130         return true;
00131       if ((*this)(i) < rhs(i))
00132         return false;
00133     }
00134   return false;
00135 }

template<typename T >
void TypeVector< T >::print ( std::ostream &  os  )  const [inline]

Formatted print to std::cout.

Definition at line 63 of file type_vector.C.

00064 {
00065 #if LIBMESH_DIM == 1
00066   
00067   os << "x=" << (*this)(0) << '\n';
00068   
00069 #endif
00070 #if LIBMESH_DIM == 2
00071   
00072   os << "(x,y)=("
00073      << std::setw(8) << (*this)(0) << ", "
00074      << std::setw(8) << (*this)(1) << ")"
00075      << '\n';
00076 
00077 #endif
00078 #if LIBMESH_DIM == 3
00079   
00080   os <<  "(x,y,z)=("
00081      << std::setw(8) << (*this)(0) << ", "
00082      << std::setw(8) << (*this)(1) << ", "
00083      << std::setw(8) << (*this)(2) << ")"
00084      << '\n';
00085 #endif
00086 }

template<typename T >
bool TypeVector< T >::relative_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = 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 TypeVector< T >::absolute_fuzzy_equals().

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().

00781 {
00782 #if LIBMESH_DIM == 1
00783   return this->absolute_fuzzy_equals(rhs, tol *
00784                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
00785 #endif
00786 
00787 #if LIBMESH_DIM == 2
00788   return this->absolute_fuzzy_equals(rhs, tol * 
00789                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
00790                                       std::abs(_coords[1]) + std::abs(rhs._coords[1])));
00791 #endif
00792 
00793 #if LIBMESH_DIM == 3
00794   return this->absolute_fuzzy_equals(rhs, tol *
00795                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
00796                                       std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
00797                                       std::abs(_coords[2]) + std::abs(rhs._coords[2])));
00798 #endif
00799 }

template<typename T >
Real TypeVector< T >::size (  )  const [inline]

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 TypeVector< T >::_coords, and libmesh_norm().

Referenced by ExactSolution::_compute_error(), System::calculate_norm(), ExactErrorEstimator::find_squared_element_error(), HPCoarsenTest::select_refinement(), TypeVector< T >::size(), Sphere::Sphere(), and Edge3::volume().

00734 {
00735 #if LIBMESH_DIM == 1
00736   return (libmesh_norm(_coords[0]));
00737 #endif
00738   
00739 #if LIBMESH_DIM == 2
00740   return (libmesh_norm(_coords[0]) +
00741           libmesh_norm(_coords[1]));
00742 #endif
00743   
00744 #if LIBMESH_DIM == 3
00745   return (libmesh_norm(_coords[0]) +
00746           libmesh_norm(_coords[1]) + 
00747           libmesh_norm(_coords[2]));
00748 #endif
00749 }

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.

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

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

template<typename T >
template<typename T2 >
void TypeVector< T >::subtract_scaled ( const TypeVector< T2 > &  p,
const T  factor 
) [inline]

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

Definition at line 524 of file type_vector.h.

References TypeVector< T >::_coords.

Referenced by HPCoarsenTest::select_refinement().

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

template<typename T >
TypeVector< T > TypeVector< T >::unit (  )  const [inline]

Think 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 TypeVector< T >::_coords, and TypeVector< 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().

00037 {
00038 
00039   const Real length = size();
00040   
00041   libmesh_assert (length != static_cast<Real>(0.));
00042   
00043 #if LIBMESH_DIM == 1
00044   return TypeVector<T>(_coords[0]/length);
00045 #endif
00046   
00047 #if LIBMESH_DIM == 2 
00048   return TypeVector<T>(_coords[0]/length,
00049                        _coords[1]/length);
00050 #endif
00051   
00052 #if LIBMESH_DIM == 3
00053   return TypeVector<T>(_coords[0]/length,
00054                        _coords[1]/length, 
00055                        _coords[2]/length);
00056 #endif
00057   
00058 }

template<typename T >
void TypeVector< T >::write_unformatted ( std::ostream &  out,
const bool  newline = true 
) const [inline]

Unformatted 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().

00095 {
00096   libmesh_assert (out);
00097 
00098   out << std::setiosflags(std::ios::showpoint)
00099       << (*this)(0) << " "
00100       << (*this)(1) << " "
00101       << (*this)(2) << " ";
00102 
00103   if (newline)
00104     out << '\n';      
00105 }

template<typename T >
void TypeVector< T >::zero (  )  [inline]

Zero the vector in any dimension.

Definition at line 723 of file type_vector.h.

References TypeVector< T >::_coords.

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


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.

00269   {
00270     t.print(os);
00271     return os;
00272   }

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.

Referenced by TypeVector< T >::operator-().


Member Data Documentation


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:45:06.

Hosted By:
SourceForge.net Logo