libMesh::VectorValue< T > Class Template Reference

#include <exact_error_estimator.h>

Inheritance diagram for libMesh::VectorValue< T >:

Public Member Functions

 VectorValue ()
 
 VectorValue (const T x, const T y=0, const T z=0)
 
template<typename Scalar >
 VectorValue (const Scalar x, const Scalar y=0, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type z=0)
 
template<typename T2 >
 VectorValue (const VectorValue< T2 > &p)
 
template<typename T2 >
 VectorValue (const TypeVector< T2 > &p)
 
 VectorValue (const TypeVector< Real > &p_re, const TypeVector< Real > &p_im)
 
template<typename Scalar >
boostcopy::enable_if_c
< ScalarTraits< Scalar >
::value, VectorValue & >::type 
operator= (const Scalar &p)
 
template<typename T2 >
void assign (const TypeVector< T2 > &)
 
const T & operator() (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
const T & slice (const unsigned int i) const
 
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
 
TypeVector< T > operator- () 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)
 
template<typename Scalar >
boostcopy::enable_if_c
< ScalarTraits< Scalar >
::value, TypeVector< typename
CompareTypes< T, Scalar >
::supertype > >::type 
operator* (const Scalar) const
 
template<typename T2 >
CompareTypes< T, T2 >::supertype operator* (const TypeVector< T2 > &) 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 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
 
template<>
bool operator!= (const TypeVector< Real > &rhs) const
 
bool operator< (const TypeVector< T > &rhs) const
 
template<>
bool operator< (const TypeVector< Complex > &rhs) const
 
bool operator<= (const TypeVector< T > &rhs) const
 
template<>
bool operator<= (const TypeVector< Complex > &rhs) const
 
bool operator> (const TypeVector< T > &rhs) const
 
template<>
bool operator> (const TypeVector< Complex > &rhs) const
 
bool operator>= (const TypeVector< T > &rhs) const
 
template<>
bool operator>= (const TypeVector< Complex > &rhs) const
 
void print (std::ostream &os=libMesh::out) const
 
void write_unformatted (std::ostream &out, const bool newline=true) const
 

Protected Attributes

_coords [LIBMESH_DIM]
 

Detailed Description

template<typename T>
class libMesh::VectorValue< T >

This class defines a vector in LIBMESH_DIM dimensional Real or Complex space. The typedef RealVectorValue always defines a real-valued vector, and NumberVectorValue defines a real or complex-valued vector depending on how the library was configured.

Author
Benjamin S. Kirk, 2003.

Definition at line 47 of file exact_error_estimator.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::VectorValue< T >::VectorValue ( )
inline

Empty constructor. Gives the vector 0 in LIBMESH_DIM dimensional T space.

Definition at line 125 of file vector_value.h.

125  :
126  TypeVector<T> ()
127 {
128 }
template<typename T>
libMesh::VectorValue< T >::VectorValue ( const T  x,
const T  y = 0,
const T  z = 0 
)
inline

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

Definition at line 133 of file vector_value.h.

135  :
136  TypeVector<T> (x,y,z)
137 {
138 }
template<typename T >
template<typename Scalar >
libMesh::VectorValue< T >::VectorValue ( const Scalar  x,
const Scalar  y = 0,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type  z = 0 
)
inline

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

Definition at line 145 of file vector_value.h.

149  :
150  TypeVector<T> (x,y,z)
151 {
152 }
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const VectorValue< T2 > &  p)
inline

Copy-constructor.

Definition at line 159 of file vector_value.h.

159  :
160  TypeVector<T> (p)
161 {
162 }
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const TypeVector< T2 > &  p)
inline

Copy-constructor.

Definition at line 169 of file vector_value.h.

169  :
170  TypeVector<T> (p)
171 {
172 }
template<typename T>
libMesh::VectorValue< T >::VectorValue ( const TypeVector< Real > &  p_re,
const TypeVector< Real > &  p_im 
)
inline

Constructor that takes two TypeVector<Real> representing the real and imaginary part as arguments.

Definition at line 177 of file vector_value.h.

178  :
179  TypeVector<T> (Complex (p_re(0), p_im(0)),
180  Complex (p_re(1), p_im(1)),
181  Complex (p_re(2), p_im(2)))
182 {
183 }

Member Function Documentation

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

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 >::add_scaled ( const TypeVector< T2 > &  p,
const T  factor 
)
inlineinherited
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inlineinherited

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
inlineinherited

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
inherited

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
inherited
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
inlineinherited

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
inlineinherited

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

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
inlineinherited

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
inlineinherited

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

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
inlineinherited

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

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
inlineinherited

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
inlineinherited

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

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
inlineinherited

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

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
inherited

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
inherited
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
inherited

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
inherited
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, VectorValue&>::type libMesh::VectorValue< T >::operator= ( const Scalar &  p)
inline

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

Definition at line 98 of file vector_value.h.

99  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
template<typename T>
bool libMesh::TypeVector< T >::operator== ( const TypeVector< T > &  rhs) const
inlineinherited
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
inherited

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
inherited
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
inherited

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
inherited
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
inherited

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
inlineinherited
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::Hex27::has_affine_map(), libMesh::Hex20::has_affine_map(), libMesh::Prism15::has_affine_map(), and libMesh::Prism18::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
inlineinherited
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inlineinherited

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

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

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

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
inherited

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
inherited

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

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 }

Member Data Documentation

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

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:00 UTC

Hosted By:
SourceForge.net Logo