libMesh::TypeVector< T > Class Template Reference

#include <tensor_tools.h>

Inheritance diagram for libMesh::TypeVector< T >:

Public Member Functions

template<typename T2 >
 TypeVector (const TypeVector< T2 > &p)
 
 ~TypeVector ()
 
template<typename T2 >
void assign (const TypeVector< T2 > &)
 
template<typename Scalar >
boostcopy::enable_if_c
< ScalarTraits< Scalar >
::value, TypeVector & >::type 
operator= (const Scalar &p)
 
const T & operator() (const unsigned int i) const
 
const T & slice (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
T & slice (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 >
CompareTypes< T, T2 >::supertype contract (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
 
bool operator> (const TypeVector< T > &rhs) const
 
bool operator>= (const TypeVector< T > &rhs) const
 
void print (std::ostream &os=libMesh::out) 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< Complex > &rhs) const
 
template<>
bool operator>= (const TypeVector< Complex > &rhs) const
 
template<>
bool operator!= (const TypeVector< Real > &rhs) const
 

Protected Member Functions

 TypeVector ()
 
 TypeVector (const T x, const T y=0, const T z=0)
 
template<typename Scalar >
 TypeVector (const Scalar x, const Scalar y=0, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type z=0)
 

Protected Attributes

_coords [LIBMESH_DIM]
 

Friends

template<typename T2 >
class TypeVector
 
class TypeTensor< T >
 
std::ostream & operator<< (std::ostream &os, const TypeVector< T > &t)
 

Detailed Description

template<typename T>
class libMesh::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 30 of file tensor_tools.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::TypeVector< T >::TypeVector ( )
inlineprotected

Empty constructor. Gives the vector 0 in LIBMESH_DIM dimensions.

Definition at line 359 of file type_vector.h.

360 {
361  _coords[0] = 0;
362 
363 #if LIBMESH_DIM > 1
364  _coords[1] = 0;
365 #endif
366 
367 #if LIBMESH_DIM > 2
368  _coords[2] = 0;
369 #endif
370 }
template<typename T>
libMesh::TypeVector< T >::TypeVector ( const T  x,
const T  y = 0,
const T  z = 0 
)
inlineprotected

Constructor-from-T. By default sets higher dimensional entries to 0.

Definition at line 376 of file type_vector.h.

379 {
380  _coords[0] = x;
381 
382 #if LIBMESH_DIM > 1
383  _coords[1] = y;
384 #else
385  libmesh_assert_equal_to (y, 0);
386 #endif
387 
388 #if LIBMESH_DIM > 2
389  _coords[2] = z;
390 #else
391  libmesh_assert_equal_to (z, 0);
392 #endif
393 }
template<typename T >
template<typename Scalar >
libMesh::TypeVector< T >::TypeVector ( const Scalar  x,
const Scalar  y = 0,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type  z = 0 
)
inlineprotected

Constructor-from-scalars. By default sets higher dimensional entries to 0.

Definition at line 399 of file type_vector.h.

404 {
405  _coords[0] = x;
406 
407 #if LIBMESH_DIM > 1
408  _coords[1] = y;
409 #else
410  libmesh_assert_equal_to (y, 0);
411 #endif
412 
413 #if LIBMESH_DIM > 2
414  _coords[2] = z;
415 #else
416  libmesh_assert_equal_to (z, 0);
417 #endif
418 }
template<typename T >
template<typename T2 >
libMesh::TypeVector< T >::TypeVector ( const TypeVector< T2 > &  p)
inline

Copy-constructor.

Definition at line 425 of file type_vector.h.

426 {
427  // copy the nodes from vector p to me
428  for (unsigned int i=0; i<LIBMESH_DIM; i++)
429  _coords[i] = p._coords[i];
430 }
template<typename T >
libMesh::TypeVector< T >::~TypeVector ( )
inline

Destructor.

Definition at line 436 of file type_vector.h.

437 {
438 }

Member Function Documentation

template<typename T>
bool libMesh::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 854 of file type_vector.h.

References std::abs().

Referenced by libMesh::FEGenericBase< T >::compute_periodic_constraints(), libMesh::LocationMap< T >::find(), and libMesh::SerialMesh::stitching_helper().

855 {
856 #if LIBMESH_DIM == 1
857  return (std::abs(_coords[0] - rhs._coords[0])
858  <= tol);
859 #endif
860 
861 #if LIBMESH_DIM == 2
862  return (std::abs(_coords[0] - rhs._coords[0]) +
863  std::abs(_coords[1] - rhs._coords[1])
864  <= tol);
865 #endif
866 
867 #if LIBMESH_DIM == 3
868  return (std::abs(_coords[0] - rhs._coords[0]) +
869  std::abs(_coords[1] - rhs._coords[1]) +
870  std::abs(_coords[2] - rhs._coords[2])
871  <= tol);
872 #endif
873 }
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::add ( const TypeVector< T2 > &  p)
inline

Add to this vector without creating a temporary.

Definition at line 516 of file type_vector.h.

Referenced by libMesh::Elem::centroid(), libMesh::FE< Dim, T >::inverse_map(), libMesh::InfFE< friend_Dim, friend_T_radial, friend_T_map >::inverse_map(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().

517 {
518 #if LIBMESH_DIM == 1
519  _coords[0] += p._coords[0];
520 #endif
521 
522 #if LIBMESH_DIM == 2
523  _coords[0] += p._coords[0];
524  _coords[1] += p._coords[1];
525 #endif
526 
527 #if LIBMESH_DIM == 3
528  _coords[0] += p._coords[0];
529  _coords[1] += p._coords[1];
530  _coords[2] += p._coords[2];
531 #endif
532 
533 }
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inline

Assign to a vector without creating a temporary.

Definition at line 445 of file type_vector.h.

446 {
447  for (unsigned int i=0; i<LIBMESH_DIM; i++)
448  _coords[i] = p._coords[i];
449 }
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p) const
inline

Multiply 2 vectors together, i.e. dot-product. The vectors may be of different types.

Definition at line 785 of file type_vector.h.

786 {
787  return (*this)*(p);
788 }
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  p) const

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

Definition at line 795 of file type_vector.h.

Referenced by libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), libMesh::Plane::create_from_three_points(), libMesh::Quad4::volume(), libMesh::Tri3::volume(), libMesh::Pyramid5::volume(), libMesh::Prism6::volume(), libMesh::Hex8::volume(), and libMesh::Tet4::volume().

796 {
797  typedef typename CompareTypes<T, T2>::supertype TS;
798  libmesh_assert_equal_to (LIBMESH_DIM, 3);
799 
800  // | i j k |
801  // |(*this)(0) (*this)(1) (*this)(2)|
802  // | p(0) p(1) p(2) |
803 
804  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
805  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
806  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
807 }
template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
Returns
true iff two vectors do not occupy approximately the same physical location in space.
template<>
bool libMesh::TypeVector< Real >::operator!= ( const TypeVector< Real > &  rhs) const
inline

Definition at line 926 of file type_vector.h.

927 {
928  return (!(*this == rhs));
929 }
template<typename T >
const T & libMesh::TypeVector< T >::operator() ( const unsigned int  i) const
inline

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

Definition at line 455 of file type_vector.h.

456 {
457  libmesh_assert_less (i, LIBMESH_DIM);
458 
459  return _coords[i];
460 }
template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i)
inline

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

Definition at line 466 of file type_vector.h.

467 {
468  libmesh_assert_less (i, LIBMESH_DIM);
469 
470  return _coords[i];
471 }
template<typename T >
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type libMesh::TypeVector< T >::operator* ( const Scalar  factor) const
inline

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

Definition at line 652 of file type_vector.h.

653 {
654  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
655 
656 #if LIBMESH_DIM == 1
657  return TypeVector<SuperType>(_coords[0]*factor);
658 #endif
659 
660 #if LIBMESH_DIM == 2
661  return TypeVector<SuperType>(_coords[0]*factor,
662  _coords[1]*factor);
663 #endif
664 
665 #if LIBMESH_DIM == 3
666  return TypeVector<SuperType>(_coords[0]*factor,
667  _coords[1]*factor,
668  _coords[2]*factor);
669 #endif
670 }
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::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 763 of file type_vector.h.

764 {
765 #if LIBMESH_DIM == 1
766  return _coords[0]*p._coords[0];
767 #endif
768 
769 #if LIBMESH_DIM == 2
770  return (_coords[0]*p._coords[0] +
771  _coords[1]*p._coords[1]);
772 #endif
773 
774 #if LIBMESH_DIM == 3
775  return (_coords[0]*p(0) +
776  _coords[1]*p(1) +
777  _coords[2]*p(2));
778 #endif
779 }
template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator*= ( const T  factor)
inline

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

Definition at line 689 of file type_vector.h.

690 {
691 #if LIBMESH_DIM == 1
692  _coords[0] *= factor;
693 #endif
694 
695 #if LIBMESH_DIM == 2
696  _coords[0] *= factor;
697  _coords[1] *= factor;
698 #endif
699 
700 #if LIBMESH_DIM == 3
701  _coords[0] *= factor;
702  _coords[1] *= factor;
703  _coords[2] *= factor;
704 #endif
705 
706  return *this;
707 }
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator+ ( const TypeVector< T2 > &  p) const
inline

Add two vectors.

Definition at line 479 of file type_vector.h.

480 {
481  typedef typename CompareTypes<T, T2>::supertype TS;
482 #if LIBMESH_DIM == 1
483  return TypeVector<TS> (_coords[0] + p._coords[0]);
484 #endif
485 
486 #if LIBMESH_DIM == 2
487  return TypeVector<TS> (_coords[0] + p._coords[0],
488  _coords[1] + p._coords[1]);
489 #endif
490 
491 #if LIBMESH_DIM == 3
492  return TypeVector<TS> (_coords[0] + p._coords[0],
493  _coords[1] + p._coords[1],
494  _coords[2] + p._coords[2]);
495 #endif
496 
497 }
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator+= ( const TypeVector< T2 > &  p)
inline

Add to this vector.

Definition at line 504 of file type_vector.h.

505 {
506  this->add (p);
507 
508  return *this;
509 }
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator- ( const TypeVector< T2 > &  p) const
inline

Subtract two vectors.

Definition at line 565 of file type_vector.h.

566 {
567  typedef typename CompareTypes<T, T2>::supertype TS;
568 
569 #if LIBMESH_DIM == 1
570  return TypeVector<TS>(_coords[0] - p._coords[0]);
571 #endif
572 
573 #if LIBMESH_DIM == 2
574  return TypeVector<TS>(_coords[0] - p._coords[0],
575  _coords[1] - p._coords[1]);
576 #endif
577 
578 #if LIBMESH_DIM == 3
579  return TypeVector<TS>(_coords[0] - p._coords[0],
580  _coords[1] - p._coords[1],
581  _coords[2] - p._coords[2]);
582 #endif
583 
584 }
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- ( ) const
inline

Return the opposite of a vector

Definition at line 624 of file type_vector.h.

625 {
626 
627 #if LIBMESH_DIM == 1
628  return TypeVector(-_coords[0]);
629 #endif
630 
631 #if LIBMESH_DIM == 2
632  return TypeVector(-_coords[0],
633  -_coords[1]);
634 #endif
635 
636 #if LIBMESH_DIM == 3
637  return TypeVector(-_coords[0],
638  -_coords[1],
639  -_coords[2]);
640 #endif
641 
642 }
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator-= ( const TypeVector< T2 > &  p)
inline

Subtract from this vector.

Definition at line 591 of file type_vector.h.

592 {
593  this->subtract (p);
594 
595  return *this;
596 }
template<typename T >
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type libMesh::TypeVector< T >::operator/ ( const Scalar  factor) const
inline

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

Definition at line 717 of file type_vector.h.

718 {
719  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
720 
721  typedef typename CompareTypes<T, Scalar>::supertype TS;
722 
723 #if LIBMESH_DIM == 1
724  return TypeVector<TS>(_coords[0]/factor);
725 #endif
726 
727 #if LIBMESH_DIM == 2
728  return TypeVector<TS>(_coords[0]/factor,
729  _coords[1]/factor);
730 #endif
731 
732 #if LIBMESH_DIM == 3
733  return TypeVector<TS>(_coords[0]/factor,
734  _coords[1]/factor,
735  _coords[2]/factor);
736 #endif
737 
738 }
template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator/= ( const T  factor)
inline

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

Definition at line 746 of file type_vector.h.

747 {
748  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
749 
750  for (unsigned int i=0; i<LIBMESH_DIM; i++)
751  _coords[i] /= factor;
752 
753  return *this;
754 }
template<>
bool libMesh::TypeVector< Complex >::operator< ( const TypeVector< Complex > &  rhs) const

Definition at line 167 of file type_vector.C.

168 {
169  for (unsigned int i=0; i<LIBMESH_DIM; i++)
170  {
171  if ((*this)(i).real() < rhs(i).real())
172  return true;
173  if ((*this)(i).real() > rhs(i).real())
174  return false;
175  if ((*this)(i).imag() < rhs(i).imag())
176  return true;
177  if ((*this)(i).imag() > rhs(i).imag())
178  return false;
179  }
180  return false;
181 }
template<typename T>
bool libMesh::TypeVector< T >::operator< ( const TypeVector< T > &  rhs) const
Returns
true if this vector is "less" than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 109 of file type_vector.C.

110 {
111  for (unsigned int i=0; i<LIBMESH_DIM; i++)
112  {
113  if ((*this)(i) < rhs(i))
114  return true;
115  if ((*this)(i) > rhs(i))
116  return false;
117  }
118  return false;
119 }
template<>
bool libMesh::TypeVector< Complex >::operator<= ( const TypeVector< Complex > &  rhs) const

Definition at line 186 of file type_vector.C.

187 {
188  for (unsigned int i=0; i<LIBMESH_DIM; i++)
189  {
190  if ((*this)(i).real() < rhs(i).real())
191  return true;
192  if ((*this)(i).real() > rhs(i).real())
193  return false;
194  if ((*this)(i).imag() < rhs(i).imag())
195  return true;
196  if ((*this)(i).imag() > rhs(i).imag())
197  return false;
198  }
199  return true;
200 }
template<typename T>
bool libMesh::TypeVector< T >::operator<= ( const TypeVector< T > &  rhs) const
Returns
true if this vector is "less" than or equal to another. Useful for sorting. Also used for choosing some arbitrary constraint equation directions

Definition at line 123 of file type_vector.C.

124 {
125  for (unsigned int i=0; i<LIBMESH_DIM; i++)
126  {
127  if ((*this)(i) < rhs(i))
128  return true;
129  if ((*this)(i) > rhs(i))
130  return false;
131  }
132  return true;
133 }
template<typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TypeVector&>::type libMesh::TypeVector< T >::operator= ( const Scalar &  p)
inline

Assignment-from-scalar operator. Used only to zero out vectors.

Definition at line 115 of file type_vector.h.

116  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
template<typename T>
bool libMesh::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 904 of file type_vector.h.

905 {
906 #if LIBMESH_DIM == 1
907  return (_coords[0] == rhs._coords[0]);
908 #endif
909 
910 #if LIBMESH_DIM == 2
911  return (_coords[0] == rhs._coords[0] &&
912  _coords[1] == rhs._coords[1]);
913 #endif
914 
915 #if LIBMESH_DIM == 3
916  return (_coords[0] == rhs._coords[0] &&
917  _coords[1] == rhs._coords[1] &&
918  _coords[2] == rhs._coords[2]);
919 #endif
920 }
template<>
bool libMesh::TypeVector< Complex >::operator> ( const TypeVector< Complex > &  rhs) const

Definition at line 205 of file type_vector.C.

206 {
207  for (unsigned int i=0; i<LIBMESH_DIM; i++)
208  {
209  if ((*this)(i).real() > rhs(i).real())
210  return true;
211  if ((*this)(i).real() < rhs(i).real())
212  return false;
213  if ((*this)(i).imag() > rhs(i).imag())
214  return true;
215  if ((*this)(i).imag() < rhs(i).imag())
216  return false;
217  }
218  return false;
219 }
template<typename T>
bool libMesh::TypeVector< T >::operator> ( const TypeVector< T > &  rhs) const
Returns
true if this vector is "greater" than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 138 of file type_vector.C.

139 {
140  for (unsigned int i=0; i<LIBMESH_DIM; i++)
141  {
142  if ((*this)(i) > rhs(i))
143  return true;
144  if ((*this)(i) < rhs(i))
145  return false;
146  }
147  return false;
148 }
template<>
bool libMesh::TypeVector< Complex >::operator>= ( const TypeVector< Complex > &  rhs) const

Definition at line 224 of file type_vector.C.

225 {
226  for (unsigned int i=0; i<LIBMESH_DIM; i++)
227  {
228  if ((*this)(i).real() > rhs(i).real())
229  return true;
230  if ((*this)(i).real() < rhs(i).real())
231  return false;
232  if ((*this)(i).imag() > rhs(i).imag())
233  return true;
234  if ((*this)(i).imag() < rhs(i).imag())
235  return false;
236  }
237  return true;
238 }
template<typename T>
bool libMesh::TypeVector< T >::operator>= ( const TypeVector< T > &  rhs) const
Returns
true if this vector is "greater" than or equal to another. Useful for sorting. Also used for choosing some arbitrary constraint equation directions

Definition at line 152 of file type_vector.C.

153 {
154  for (unsigned int i=0; i<LIBMESH_DIM; i++)
155  {
156  if ((*this)(i) > rhs(i))
157  return true;
158  if ((*this)(i) < rhs(i))
159  return false;
160  }
161  return true;
162 }
template<typename T >
void libMesh::TypeVector< T >::print ( std::ostream &  os = libMesh::out) const

Formatted print, by default to libMesh::out.

Definition at line 64 of file type_vector.C.

65 {
66 #if LIBMESH_DIM == 1
67 
68  os << "x=" << (*this)(0);
69 
70 #endif
71 #if LIBMESH_DIM == 2
72 
73  os << "(x,y)=("
74  << std::setw(8) << (*this)(0) << ", "
75  << std::setw(8) << (*this)(1) << ")";
76 
77 #endif
78 #if LIBMESH_DIM == 3
79 
80  os << "(x,y,z)=("
81  << std::setw(8) << (*this)(0) << ", "
82  << std::setw(8) << (*this)(1) << ", "
83  << std::setw(8) << (*this)(2) << ")";
84 #endif
85 }
template<typename T>
bool libMesh::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 879 of file type_vector.h.

References std::abs().

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

880 {
881 #if LIBMESH_DIM == 1
882  return this->absolute_fuzzy_equals(rhs, tol *
883  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
884 #endif
885 
886 #if LIBMESH_DIM == 2
887  return this->absolute_fuzzy_equals(rhs, tol *
888  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
889  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
890 #endif
891 
892 #if LIBMESH_DIM == 3
893  return this->absolute_fuzzy_equals(rhs, tol *
894  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
895  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
896  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
897 #endif
898 }
template<typename T >
Real libMesh::TypeVector< T >::size_sq ( ) const
inline
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inline

Definition at line 123 of file type_vector.h.

123 { return (*this)(i); }
template<typename T>
T& libMesh::TypeVector< T >::slice ( const unsigned int  i)
inline

Definition at line 130 of file type_vector.h.

130 { return (*this)(i); }
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::subtract ( const TypeVector< T2 > &  p)
inline

Subtract from this vector without creating a temporary.

Definition at line 603 of file type_vector.h.

604 {
605  for (unsigned int i=0; i<LIBMESH_DIM; i++)
606  _coords[i] -= p._coords[i];
607 }
template<typename T>
template<typename T2 >
void libMesh::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 614 of file type_vector.h.

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

615 {
616  for (unsigned int i=0; i<LIBMESH_DIM; i++)
617  _coords[i] -= factor*p(i);
618 }
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const

Think of a vector as a dim dimensional vector. This will return a unit vector aligned in that direction.

Definition at line 37 of file type_vector.C.

References libMesh::Real.

Referenced by libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), libMesh::Plane::create_from_point_normal(), libMesh::Plane::create_from_three_points(), libMesh::MeshTools::Modification::distort(), and libMesh::Sphere::unit_normal().

38 {
39 
40  const Real length = size();
41 
42  libmesh_assert_not_equal_to (length, static_cast<Real>(0.));
43 
44 #if LIBMESH_DIM == 1
45  return TypeVector<T>(_coords[0]/length);
46 #endif
47 
48 #if LIBMESH_DIM == 2
49  return TypeVector<T>(_coords[0]/length,
50  _coords[1]/length);
51 #endif
52 
53 #if LIBMESH_DIM == 3
54  return TypeVector<T>(_coords[0]/length,
55  _coords[1]/length,
56  _coords[2]/length);
57 #endif
58 
59 }
template<typename T >
void libMesh::TypeVector< T >::write_unformatted ( std::ostream &  out,
const bool  newline = true 
) const

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 92 of file type_vector.C.

References libMesh::libmesh_assert().

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

94 {
95  libmesh_assert (os);
96 
97  os << std::setiosflags(std::ios::showpoint)
98  << (*this)(0) << " "
99  << (*this)(1) << " "
100  << (*this)(2) << " ";
101 
102  if (newline)
103  os << '\n';
104 }
template<typename T >
void libMesh::TypeVector< T >::zero ( )
inline

Zero the vector in any dimension.

Definition at line 822 of file type_vector.h.

Referenced by libMesh::VectorValue< Real >::operator=(), and libMesh::TypeVector< Real >::operator=().

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

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 329 of file type_vector.h.

330  {
331  t.print(os);
332  return os;
333  }
template<typename T>
friend class TypeTensor< T >
friend

Definition at line 58 of file type_vector.h.

template<typename T>
template<typename T2 >
friend class TypeVector
friend

Definition at line 56 of file type_vector.h.

Member Data Documentation

template<typename T>
T libMesh::TypeVector< T >::_coords[LIBMESH_DIM]
protected

The coordinates of the TypeVector

Definition at line 347 of file type_vector.h.

Referenced by libMesh::TypeTensor< T >::row().


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo