libMesh::VectorValue< T > Class Template Reference

#include <exact_error_estimator.h>

Inheritance diagram for libMesh::VectorValue< T >:

Public Types

typedef T value_type
 

Public Member Functions

 VectorValue ()
 
 VectorValue (const T x, const T y=0, const T z=0)
 
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
 VectorValue (typename boostcopy::enable_if_c< ScalarTraits< Scalar1 >::value, const Scalar1 >::type x, typename boostcopy::enable_if_c< ScalarTraits< Scalar2 >::value, const Scalar2 >::type y=0, typename boostcopy::enable_if_c< ScalarTraits< Scalar3 >::value, const Scalar3 >::type z=0)
 
template<typename Scalar >
 VectorValue (const Scalar x, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *sfinae=libmesh_nullptr)
 
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 &libmesh_dbg_var(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 norm () const
 
Real size_sq () const
 
Real norm_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
 
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
Date
2003

Definition at line 48 of file exact_error_estimator.h.

Member Typedef Documentation

template<typename T>
typedef T libMesh::TypeVector< T >::value_type
inherited

Helper typedef for C++98 generic programming

Definition at line 111 of file type_vector.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 139 of file vector_value.h.

139  :
140  TypeVector<T> ()
141 {
142 }
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 147 of file vector_value.h.

149  :
150  TypeVector<T> (x,y,z)
151 {
152 }
PetscErrorCode Vec x
template<typename T >
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
libMesh::VectorValue< T >::VectorValue ( typename boostcopy::enable_if_c< ScalarTraits< Scalar1 >::value, const Scalar1 >::type  x,
typename boostcopy::enable_if_c< ScalarTraits< Scalar2 >::value, const Scalar2 >::type  y = 0,
typename boostcopy::enable_if_c< ScalarTraits< Scalar3 >::value, const Scalar3 >::type  z = 0 
)
inline

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

Definition at line 159 of file vector_value.h.

167  :
168  TypeVector<T> (x,y,z)
169 {
170 }
PetscErrorCode Vec x
template<typename T >
template<typename Scalar >
libMesh::VectorValue< T >::VectorValue ( const Scalar  x,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *  sfinae = libmesh_nullptr 
)
inline

Constructor-from-scalar. Sets higher dimensional entries to 0. Necessary because for some reason the constructor-from-scalars alone is insufficient to let the compiler figure out VectorValue<Complex> v = 0;

Definition at line 176 of file vector_value.h.

179  :
180  TypeVector<T> (x)
181 {
182 }
PetscErrorCode Vec x
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const VectorValue< T2 > &  p)
inline

Copy-constructor.

Definition at line 187 of file vector_value.h.

187  :
188  TypeVector<T> (p)
189 {
190 }
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const TypeVector< T2 > &  p)
inline

Copy-constructor.

Definition at line 197 of file vector_value.h.

197  :
198  TypeVector<T> (p)
199 {
200 }
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 205 of file vector_value.h.

206  :
207  TypeVector<T> (Complex (p_re(0), p_im(0)),
208  Complex (p_re(1), p_im(1)),
209  Complex (p_re(2), p_im(2)))
210 {
211 }
std::complex< Real > Complex

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

References libMesh::TypeVector< T >::_coords, and std::abs().

Referenced by libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::LocationMap< T >::find(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::Elem::parent_bracketing_nodes(), libMesh::TypeVector< T >::relative_fuzzy_equals(), libMesh::TypeVector< Real >::slice(), and libMesh::ReplicatedMesh::stitching_helper().

939 {
940 #if LIBMESH_DIM == 1
941  return (std::abs(_coords[0] - rhs._coords[0])
942  <= tol);
943 #endif
944 
945 #if LIBMESH_DIM == 2
946  return (std::abs(_coords[0] - rhs._coords[0]) +
947  std::abs(_coords[1] - rhs._coords[1])
948  <= tol);
949 #endif
950 
951 #if LIBMESH_DIM == 3
952  return (std::abs(_coords[0] - rhs._coords[0]) +
953  std::abs(_coords[1] - rhs._coords[1]) +
954  std::abs(_coords[2] - rhs._coords[2])
955  <= tol);
956 #endif
957 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
double abs(double a)
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 580 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::Elem::centroid(), libMesh::FE< Dim, T >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::TypeVector< T >::operator+=(), libMesh::TypeVector< Real >::slice(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().

581 {
582 #if LIBMESH_DIM == 1
583  _coords[0] += p._coords[0];
584 #endif
585 
586 #if LIBMESH_DIM == 2
587  _coords[0] += p._coords[0];
588  _coords[1] += p._coords[1];
589 #endif
590 
591 #if LIBMESH_DIM == 3
592  _coords[0] += p._coords[0];
593  _coords[1] += p._coords[1];
594  _coords[2] += p._coords[2];
595 #endif
596 
597 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 509 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

510 {
511  for (unsigned int i=0; i<LIBMESH_DIM; i++)
512  _coords[i] = p._coords[i];
513 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 849 of file type_vector.h.

Referenced by libMesh::TypeVector< Real >::slice().

850 {
851  return (*this)*(p);
852 }
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 859 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), libMesh::Tri3::contains_point(), libMesh::Plane::create_from_three_points(), libMesh::TypeVector< Real >::slice(), and libMesh::Quad4::volume().

860 {
861  typedef typename CompareTypes<T, T2>::supertype TS;
862  libmesh_assert_equal_to (LIBMESH_DIM, 3);
863 
864  // | i j k |
865  // |(*this)(0) (*this)(1) (*this)(2)|
866  // | p(0) p(1) p(2) |
867 
868  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
869  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
870  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
871 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
inlineinherited
Returns
true iff two vectors do not occupy approximately the same physical location in space.

Definition at line 1010 of file type_vector.h.

Referenced by libMesh::TypeVector< Real >::slice().

1011 {
1012  return (!(*this == rhs));
1013 }
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 519 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

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

520 {
521  libmesh_assert_less (i, LIBMESH_DIM);
522 
523  return _coords[i];
524 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 530 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

531 {
532  libmesh_assert_less (i, LIBMESH_DIM);
533 
534  return _coords[i];
535 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 716 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

717 {
718  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
719 
720 #if LIBMESH_DIM == 1
721  return TypeVector<SuperType>(_coords[0]*factor);
722 #endif
723 
724 #if LIBMESH_DIM == 2
725  return TypeVector<SuperType>(_coords[0]*factor,
726  _coords[1]*factor);
727 #endif
728 
729 #if LIBMESH_DIM == 3
730  return TypeVector<SuperType>(_coords[0]*factor,
731  _coords[1]*factor,
732  _coords[2]*factor);
733 #endif
734 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 827 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

828 {
829 #if LIBMESH_DIM == 1
830  return _coords[0]*p._coords[0];
831 #endif
832 
833 #if LIBMESH_DIM == 2
834  return (_coords[0]*p._coords[0] +
835  _coords[1]*p._coords[1]);
836 #endif
837 
838 #if LIBMESH_DIM == 3
839  return (_coords[0]*p(0) +
840  _coords[1]*p(1) +
841  _coords[2]*p(2));
842 #endif
843 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 753 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

754 {
755 #if LIBMESH_DIM == 1
756  _coords[0] *= factor;
757 #endif
758 
759 #if LIBMESH_DIM == 2
760  _coords[0] *= factor;
761  _coords[1] *= factor;
762 #endif
763 
764 #if LIBMESH_DIM == 3
765  _coords[0] *= factor;
766  _coords[1] *= factor;
767  _coords[2] *= factor;
768 #endif
769 
770  return *this;
771 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 543 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

544 {
545  typedef typename CompareTypes<T, T2>::supertype TS;
546 #if LIBMESH_DIM == 1
547  return TypeVector<TS> (_coords[0] + p._coords[0]);
548 #endif
549 
550 #if LIBMESH_DIM == 2
551  return TypeVector<TS> (_coords[0] + p._coords[0],
552  _coords[1] + p._coords[1]);
553 #endif
554 
555 #if LIBMESH_DIM == 3
556  return TypeVector<TS> (_coords[0] + p._coords[0],
557  _coords[1] + p._coords[1],
558  _coords[2] + p._coords[2]);
559 #endif
560 
561 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 568 of file type_vector.h.

References libMesh::TypeVector< T >::add().

Referenced by libMesh::TypeVector< Real >::slice().

569 {
570  this->add (p);
571 
572  return *this;
573 }
void add(const TypeVector< T2 > &)
Definition: type_vector.h:580
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 629 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

630 {
631  typedef typename CompareTypes<T, T2>::supertype TS;
632 
633 #if LIBMESH_DIM == 1
634  return TypeVector<TS>(_coords[0] - p._coords[0]);
635 #endif
636 
637 #if LIBMESH_DIM == 2
638  return TypeVector<TS>(_coords[0] - p._coords[0],
639  _coords[1] - p._coords[1]);
640 #endif
641 
642 #if LIBMESH_DIM == 3
643  return TypeVector<TS>(_coords[0] - p._coords[0],
644  _coords[1] - p._coords[1],
645  _coords[2] - p._coords[2]);
646 #endif
647 
648 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- ( ) const
inlineinherited

Return the opposite of a vector

Definition at line 688 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and libMesh::TypeVector< T >::TypeVector().

Referenced by libMesh::TypeVector< Real >::slice().

689 {
690 
691 #if LIBMESH_DIM == 1
692  return TypeVector(-_coords[0]);
693 #endif
694 
695 #if LIBMESH_DIM == 2
696  return TypeVector(-_coords[0],
697  -_coords[1]);
698 #endif
699 
700 #if LIBMESH_DIM == 3
701  return TypeVector(-_coords[0],
702  -_coords[1],
703  -_coords[2]);
704 #endif
705 
706 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 655 of file type_vector.h.

References libMesh::TypeVector< T >::subtract().

Referenced by libMesh::TypeVector< Real >::slice().

656 {
657  this->subtract (p);
658 
659  return *this;
660 }
void subtract(const TypeVector< T2 > &)
Definition: type_vector.h:667
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 781 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

782 {
783  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
784 
785  typedef typename CompareTypes<T, Scalar>::supertype TS;
786 
787 #if LIBMESH_DIM == 1
788  return TypeVector<TS>(_coords[0]/factor);
789 #endif
790 
791 #if LIBMESH_DIM == 2
792  return TypeVector<TS>(_coords[0]/factor,
793  _coords[1]/factor);
794 #endif
795 
796 #if LIBMESH_DIM == 3
797  return TypeVector<TS>(_coords[0]/factor,
798  _coords[1]/factor,
799  _coords[2]/factor);
800 #endif
801 
802 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 810 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

811 {
812  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
813 
814  for (unsigned int i=0; i<LIBMESH_DIM; i++)
815  _coords[i] /= factor;
816 
817  return *this;
818 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 &  libmesh_dbg_varp)
inline

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

Definition at line 117 of file vector_value.h.

118  { 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 this(i)==rhs(i) for each component of the vector. For floating point types T, the function absolute_fuzzy_equals may be a more appropriate choice.

Definition at line 988 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

989 {
990 #if LIBMESH_DIM == 1
991  return (_coords[0] == rhs._coords[0]);
992 #endif
993 
994 #if LIBMESH_DIM == 2
995  return (_coords[0] == rhs._coords[0] &&
996  _coords[1] == rhs._coords[1]);
997 #endif
998 
999 #if LIBMESH_DIM == 3
1000  return (_coords[0] == rhs._coords[0] &&
1001  _coords[1] == rhs._coords[1] &&
1002  _coords[2] == rhs._coords[2]);
1003 #endif
1004 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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.

Referenced by libMesh::TypeVector< Real >::slice().

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.

Referenced by libMesh::TypeVector< Real >::slice().

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.

Referenced by libMesh::TypeVector< Real >::slice().

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

References libMesh::TypeVector< T >::_coords, std::abs(), and libMesh::TypeVector< T >::absolute_fuzzy_equals().

Referenced by libMesh::Quad4::has_affine_map(), libMesh::Prism6::has_affine_map(), libMesh::Quad9::has_affine_map(), libMesh::Quad8::has_affine_map(), libMesh::Hex8::has_affine_map(), libMesh::Hex27::has_affine_map(), libMesh::Hex20::has_affine_map(), libMesh::Prism18::has_affine_map(), libMesh::Prism15::has_affine_map(), libMesh::TypeVector< Real >::slice(), libMesh::Quad4::volume(), and libMesh::Tri6::volume().

964 {
965 #if LIBMESH_DIM == 1
966  return this->absolute_fuzzy_equals(rhs, tol *
967  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
968 #endif
969 
970 #if LIBMESH_DIM == 2
971  return this->absolute_fuzzy_equals(rhs, tol *
972  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
973  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
974 #endif
975 
976 #if LIBMESH_DIM == 3
977  return this->absolute_fuzzy_equals(rhs, tol *
978  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
979  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
980  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
981 #endif
982 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
double abs(double a)
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:938
template<typename T >
Real libMesh::TypeVector< T >::size ( ) const
inlineinherited

Returns the magnitude of the vector, i.e. the square-root of the sum of the elements squared. This function is deprecated, instead call norm().

Definition at line 877 of file type_vector.h.

References libMesh::TypeVector< T >::norm().

Referenced by libMesh::DofMap::allgather_recursive_constraints(), libMesh::DofMap::get_info(), libMesh::FEInterface::inverse_map(), libMesh::FE< Dim, T >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::DofMap::scatter_constraints(), libMesh::TypeVector< Real >::slice(), and libMesh::EnsightIO::write_geometry_ascii().

878 {
879  libmesh_deprecated();
880  return this->norm();
881 }
Real norm() const
Definition: type_vector.h:887
template<typename T >
Real libMesh::TypeVector< T >::size_sq ( ) const
inlineinherited

Returns the magnitude of the vector squared, i.e. the sum of the element magnitudes squared. This function is deprecated, instead call norm_sq().

Definition at line 906 of file type_vector.h.

References libMesh::TypeVector< T >::norm_sq().

Referenced by libMesh::TypeVector< Real >::slice().

907 {
908  libmesh_deprecated();
909  return this->norm_sq();
910 }
Real norm_sq() const
Definition: type_vector.h:916
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inlineinherited

Definition at line 145 of file type_vector.h.

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

Definition at line 152 of file type_vector.h.

152 { 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 667 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< T >::operator-=(), and libMesh::TypeVector< Real >::slice().

668 {
669  for (unsigned int i=0; i<LIBMESH_DIM; i++)
670  _coords[i] -= p._coords[i];
671 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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 678 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::HPCoarsenTest::select_refinement(), and libMesh::TypeVector< Real >::slice().

679 {
680  for (unsigned int i=0; i<LIBMESH_DIM; i++)
681  _coords[i] -= factor*p(i);
682 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
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(), libMesh::TypeVector< Real >::slice(), and libMesh::Sphere::unit_normal().

38 {
39 
40  const Real length = norm();
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 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386
Real norm() const
Definition: type_vector.h:887
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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(), and libMesh::TecplotIO::write_ascii().

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 }
libmesh_assert(j)
template<typename T >
void libMesh::TypeVector< T >::zero ( )
inlineinherited

Zero the vector in any dimension.

Definition at line 896 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

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

897 {
898  for (unsigned int i=0; i<LIBMESH_DIM; i++)
899  _coords[i] = 0.;
900 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:386

Member Data Documentation


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