libMesh
Public Types | Public Member Functions | Protected Attributes | List of all members
libMesh::VectorValue< T > Class Template Reference

This class defines a vector in LIBMESH_DIM dimensional Real or Complex space. More...

#include <exact_solution.h>

Inheritance diagram for libMesh::VectorValue< T >:
[legend]

Public Types

typedef T value_type
 Helper typedef for C++98 generic programming. More...
 
typedef unsigned int index_type
 Helper typedef for generic index programming. More...
 

Public Member Functions

 VectorValue ()
 Empty constructor. More...
 
 VectorValue (const T &x, const T &y=0, const T &z=0)
 Constructor-from-T. More...
 
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)
 Constructor-from-scalars. More...
 
template<typename Scalar >
 VectorValue (const Scalar &x, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *sfinae=nullptr)
 Constructor-from-scalar. More...
 
template<typename T2 >
 VectorValue (const VectorValue< T2 > &p)
 Copy-constructor. More...
 
template<typename T2 >
 VectorValue (const TypeVector< T2 > &p)
 Copy-constructor. More...
 
 VectorValue (const TypeVector< Real > &p_re, const TypeVector< Real > &p_im)
 Constructor that takes two TypeVector<Real> representing the real and imaginary part as arguments. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, VectorValue & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
template<typename T2 >
void assign (const TypeVector< T2 > &)
 Assign to this vector without creating a temporary. More...
 
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
 Add two vectors. More...
 
template<typename T2 >
const TypeVector< T > & operator+= (const TypeVector< T2 > &)
 Add to this vector. More...
 
template<typename T2 >
void add (const TypeVector< T2 > &)
 Add to this vector without creating a temporary. More...
 
template<typename T2 >
void add_scaled (const TypeVector< T2 > &, const T &)
 Add a scaled value to this vector without creating a temporary. More...
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator- (const TypeVector< T2 > &) const
 Subtract from this vector. More...
 
TypeVector< T > operator- () const
 
template<typename T2 >
const TypeVector< T > & operator-= (const TypeVector< T2 > &)
 Subtract from this vector. More...
 
template<typename T2 >
void subtract (const TypeVector< T2 > &)
 Subtract from this vector without creating a temporary. More...
 
template<typename T2 >
void subtract_scaled (const TypeVector< T2 > &, const T &)
 Subtract a scaled value from this vector without creating a temporary. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator* (const Scalar &) const
 Multiply this vector by a scalar value. More...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype operator* (const TypeVector< T2 > &) const
 
const TypeVector< T > & operator*= (const T &)
 Multiply this vector by a scalar value. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar &) const
 Divide each entry of this vector by scalar value. More...
 
const TypeVector< T > & operator/= (const T &)
 Divide each entry of this vector by scalar value. More...
 
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 > &v) const
 
TypeVector< T > unit () const
 
auto size () const -> decltype(std::norm(T()))
 
auto norm () const -> decltype(std::norm(T()))
 
auto size_sq () const -> decltype(std::norm(T()))
 
auto norm_sq () const -> decltype(std::norm(T()))
 
bool is_zero () const
 
void zero ()
 Set all entries of the vector to 0. More...
 
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
 Formatted print, by default to libMesh::out. More...
 
void write_unformatted (std::ostream &out, const bool newline=true) const
 Unformatted print to the stream out. More...
 

Protected Attributes

_coords [LIBMESH_DIM]
 The coordinates of the TypeVector. More...
 

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 54 of file exact_solution.h.

Member Typedef Documentation

◆ index_type

template<typename T>
typedef unsigned int libMesh::TypeVector< T >::index_type
inherited

Helper typedef for generic index programming.

Definition at line 141 of file type_vector.h.

◆ value_type

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

Helper typedef for C++98 generic programming.

Definition at line 136 of file type_vector.h.

Constructor & Destructor Documentation

◆ VectorValue() [1/7]

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 }

◆ VectorValue() [2/7]

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 }

◆ VectorValue() [3/7]

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 }

◆ VectorValue() [4/7]

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 = 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 }

◆ VectorValue() [5/7]

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 }

◆ VectorValue() [6/7]

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 }

◆ VectorValue() [7/7]

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 }

Member Function Documentation

◆ absolute_fuzzy_equals()

template<typename T>
bool libMesh::TypeVector< T >::absolute_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const
inlineinherited
Returns
true if two vectors are equal to within an absolute tolerance of tol.

Definition at line 1017 of file type_vector.h.

1018 {
1019 #if LIBMESH_DIM == 1
1020  return (std::abs(_coords[0] - rhs._coords[0])
1021  <= tol);
1022 #endif
1023 
1024 #if LIBMESH_DIM == 2
1025  return (std::abs(_coords[0] - rhs._coords[0]) +
1026  std::abs(_coords[1] - rhs._coords[1])
1027  <= tol);
1028 #endif
1029 
1030 #if LIBMESH_DIM == 3
1031  return (std::abs(_coords[0] - rhs._coords[0]) +
1032  std::abs(_coords[1] - rhs._coords[1]) +
1033  std::abs(_coords[2] - rhs._coords[2])
1034  <= tol);
1035 #endif
1036 }

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::LocationMap< T >::find(), and libMesh::Elem::parent_bracketing_nodes().

◆ add()

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

642 {
643 #if LIBMESH_DIM == 1
644  _coords[0] += p._coords[0];
645 #endif
646 
647 #if LIBMESH_DIM == 2
648  _coords[0] += p._coords[0];
649  _coords[1] += p._coords[1];
650 #endif
651 
652 #if LIBMESH_DIM == 3
653  _coords[0] += p._coords[0];
654  _coords[1] += p._coords[1];
655  _coords[2] += p._coords[2];
656 #endif
657 
658 }

Referenced by libMesh::Elem::centroid(), libMesh::FEMap::inverse_map(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().

◆ add_scaled()

template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::add_scaled ( const TypeVector< T2 > &  p,
const T &  factor 
)
inlineinherited

◆ assign()

template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inlineinherited

Assign to this vector without creating a temporary.

Definition at line 570 of file type_vector.h.

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

◆ contract()

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p) const
inlineinherited
Returns
The result of TypeVector::operator*().

Definition at line 910 of file type_vector.h.

911 {
912  return (*this)*(p);
913 }

◆ cross()

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  v) const
inherited
Returns
The cross product of this vector with v.

Definition at line 920 of file type_vector.h.

921 {
922  typedef typename CompareTypes<T, T2>::supertype TS;
923  libmesh_assert_equal_to (LIBMESH_DIM, 3);
924 
925  // | i j k |
926  // |(*this)(0) (*this)(1) (*this)(2)|
927  // | p(0) p(1) p(2) |
928 
929 #if LIBMESH_DIM == 3
930  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
931  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
932  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
933 #else
934  libmesh_ignore(p);
935  return TypeVector<TS>(0);
936 #endif
937 }

Referenced by assemble_shell(), libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), ContainsPointTest::containsPointTri3Helper(), libMesh::Plane::create_from_three_points(), and libMesh::Quad4::volume().

◆ is_zero()

template<typename T >
bool libMesh::TypeVector< T >::is_zero ( ) const
inlineinherited
Returns
True if all values in the vector are zero

Definition at line 1007 of file type_vector.h.

1008 {
1009  for (const auto & val : _coords)
1010  if (val != T(0))
1011  return false;
1012  return true;
1013 }

◆ norm()

template<typename T>
auto libMesh::TypeVector< T >::norm ( ) const -> decltype(std::norm(T()))
inlineinherited

◆ norm_sq()

template<typename T>
auto libMesh::TypeVector< T >::norm_sq ( ) const -> decltype(std::norm(T()))
inlineinherited
Returns
The magnitude of the vector squared, i.e. the sum of the element magnitudes squared.

Definition at line 986 of file type_vector.h.

987 {
988 #if LIBMESH_DIM == 1
989  return (TensorTools::norm_sq(_coords[0]));
990 #endif
991 
992 #if LIBMESH_DIM == 2
993  return (TensorTools::norm_sq(_coords[0]) +
995 #endif
996 
997 #if LIBMESH_DIM == 3
998  return (TensorTools::norm_sq(_coords[0]) +
1001 #endif
1002 }

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::System::calculate_norm(), libMesh::InfQuad4::contains_point(), libMesh::InfPrism::contains_point(), libMesh::InfHex::contains_point(), libMesh::ExactErrorEstimator::find_squared_element_error(), main(), libMesh::HPCoarsenTest::select_refinement(), libMesh::Sphere::Sphere(), and TypeVectorTestBase< VectorValue< Number > >::testNormSqBase().

◆ operator!=()

template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
inlineinherited
Returns
!(*this == rhs)

Definition at line 1089 of file type_vector.h.

1090 {
1091  return (!(*this == rhs));
1092 }

◆ operator()() [1/2]

template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i)
inlineinherited
Returns
A writable reference to the \( i^{th} \) entry of the vector.

Definition at line 591 of file type_vector.h.

592 {
593  libmesh_assert_less (i, LIBMESH_DIM);
594 
595  return _coords[i];
596 }

◆ operator()() [2/2]

template<typename T >
const T & libMesh::TypeVector< T >::operator() ( const unsigned int  i) const
inlineinherited
Returns
A const reference to the \( i^{th} \) entry of the vector.

Definition at line 580 of file type_vector.h.

581 {
582  libmesh_assert_less (i, LIBMESH_DIM);
583 
584  return _coords[i];
585 }

◆ operator*() [1/2]

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 this vector by a scalar value.

Returns
A copy of the result, this vector is unchanged.

Definition at line 777 of file type_vector.h.

778 {
779  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
780 
781 #if LIBMESH_DIM == 1
782  return TypeVector<SuperType>(_coords[0]*factor);
783 #endif
784 
785 #if LIBMESH_DIM == 2
786  return TypeVector<SuperType>(_coords[0]*factor,
787  _coords[1]*factor);
788 #endif
789 
790 #if LIBMESH_DIM == 3
791  return TypeVector<SuperType>(_coords[0]*factor,
792  _coords[1]*factor,
793  _coords[2]*factor);
794 #endif
795 }

◆ operator*() [2/2]

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::operator* ( const TypeVector< T2 > &  p) const
inlineinherited
Returns
The dot-product of this vector with another vector.
Note
The complex conjugate is not taken in the complex-valued case.
The vectors may contain different numeric types.

Definition at line 888 of file type_vector.h.

889 {
890 #if LIBMESH_DIM == 1
891  return _coords[0]*p._coords[0];
892 #endif
893 
894 #if LIBMESH_DIM == 2
895  return (_coords[0]*p._coords[0] +
896  _coords[1]*p._coords[1]);
897 #endif
898 
899 #if LIBMESH_DIM == 3
900  return (_coords[0]*p(0) +
901  _coords[1]*p(1) +
902  _coords[2]*p(2));
903 #endif
904 }

◆ operator*=()

template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator*= ( const T &  factor)
inlineinherited

Multiply this vector by a scalar value.

Returns
A reference to *this.

Definition at line 814 of file type_vector.h.

815 {
816 #if LIBMESH_DIM == 1
817  _coords[0] *= factor;
818 #endif
819 
820 #if LIBMESH_DIM == 2
821  _coords[0] *= factor;
822  _coords[1] *= factor;
823 #endif
824 
825 #if LIBMESH_DIM == 3
826  _coords[0] *= factor;
827  _coords[1] *= factor;
828  _coords[2] *= factor;
829 #endif
830 
831  return *this;
832 }

◆ operator+()

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.

Returns
A copy of the result, this vector is unchanged.

Definition at line 604 of file type_vector.h.

605 {
606  typedef typename CompareTypes<T, T2>::supertype TS;
607 #if LIBMESH_DIM == 1
608  return TypeVector<TS> (_coords[0] + p._coords[0]);
609 #endif
610 
611 #if LIBMESH_DIM == 2
612  return TypeVector<TS> (_coords[0] + p._coords[0],
613  _coords[1] + p._coords[1]);
614 #endif
615 
616 #if LIBMESH_DIM == 3
617  return TypeVector<TS> (_coords[0] + p._coords[0],
618  _coords[1] + p._coords[1],
619  _coords[2] + p._coords[2]);
620 #endif
621 
622 }

◆ operator+=()

template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator+= ( const TypeVector< T2 > &  p)
inlineinherited

Add to this vector.

Returns
A reference to *this.

Definition at line 629 of file type_vector.h.

630 {
631  this->add (p);
632 
633  return *this;
634 }

◆ operator-() [1/2]

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- ( ) const
inlineinherited
Returns
The negative of this vector in a separate copy.

Definition at line 749 of file type_vector.h.

750 {
751 
752 #if LIBMESH_DIM == 1
753  return TypeVector(-_coords[0]);
754 #endif
755 
756 #if LIBMESH_DIM == 2
757  return TypeVector(-_coords[0],
758  -_coords[1]);
759 #endif
760 
761 #if LIBMESH_DIM == 3
762  return TypeVector(-_coords[0],
763  -_coords[1],
764  -_coords[2]);
765 #endif
766 
767 }

◆ operator-() [2/2]

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

Subtract from this vector.

Returns
A copy of the result, this vector is unchanged.

Definition at line 690 of file type_vector.h.

691 {
692  typedef typename CompareTypes<T, T2>::supertype TS;
693 
694 #if LIBMESH_DIM == 1
695  return TypeVector<TS>(_coords[0] - p._coords[0]);
696 #endif
697 
698 #if LIBMESH_DIM == 2
699  return TypeVector<TS>(_coords[0] - p._coords[0],
700  _coords[1] - p._coords[1]);
701 #endif
702 
703 #if LIBMESH_DIM == 3
704  return TypeVector<TS>(_coords[0] - p._coords[0],
705  _coords[1] - p._coords[1],
706  _coords[2] - p._coords[2]);
707 #endif
708 
709 }

◆ operator-=()

template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator-= ( const TypeVector< T2 > &  p)
inlineinherited

Subtract from this vector.

Returns
A reference to *this.

Definition at line 716 of file type_vector.h.

717 {
718  this->subtract (p);
719 
720  return *this;
721 }

◆ operator/()

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 each entry of this vector by scalar value.

Returns
A copy of the result, this vector is unchanged.

Definition at line 842 of file type_vector.h.

843 {
844  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
845 
846  typedef typename CompareTypes<T, Scalar>::supertype TS;
847 
848 #if LIBMESH_DIM == 1
849  return TypeVector<TS>(_coords[0]/factor);
850 #endif
851 
852 #if LIBMESH_DIM == 2
853  return TypeVector<TS>(_coords[0]/factor,
854  _coords[1]/factor);
855 #endif
856 
857 #if LIBMESH_DIM == 3
858  return TypeVector<TS>(_coords[0]/factor,
859  _coords[1]/factor,
860  _coords[2]/factor);
861 #endif
862 
863 }

◆ operator/=()

template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator/= ( const T &  factor)
inlineinherited

Divide each entry of this vector by scalar value.

Returns
A reference to *this.

Definition at line 871 of file type_vector.h.

872 {
873  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
874 
875  for (unsigned int i=0; i<LIBMESH_DIM; i++)
876  _coords[i] /= factor;
877 
878  return *this;
879 }

◆ operator<() [1/2]

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

Definition at line 140 of file type_vector.C.

141 {
142  for (unsigned int i=0; i<LIBMESH_DIM; i++)
143  {
144  if ((*this)(i).real() < rhs(i).real())
145  return true;
146  if ((*this)(i).real() > rhs(i).real())
147  return false;
148  if ((*this)(i).imag() < rhs(i).imag())
149  return true;
150  if ((*this)(i).imag() > rhs(i).imag())
151  return false;
152  }
153  return false;
154 }

◆ operator<() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator< ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is "less" than rhs.

Useful for sorting. Also used for choosing some arbitrary basis function orientations.

Definition at line 82 of file type_vector.C.

83 {
84  for (unsigned int i=0; i<LIBMESH_DIM; i++)
85  {
86  if ((*this)(i) < rhs(i))
87  return true;
88  if ((*this)(i) > rhs(i))
89  return false;
90  }
91  return false;
92 }

◆ operator<=() [1/2]

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

Definition at line 159 of file type_vector.C.

160 {
161  for (unsigned int i=0; i<LIBMESH_DIM; i++)
162  {
163  if ((*this)(i).real() < rhs(i).real())
164  return true;
165  if ((*this)(i).real() > rhs(i).real())
166  return false;
167  if ((*this)(i).imag() < rhs(i).imag())
168  return true;
169  if ((*this)(i).imag() > rhs(i).imag())
170  return false;
171  }
172  return true;
173 }

◆ operator<=() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator<= ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is <= to rhs.

Useful for sorting. Also used for choosing some arbitrary constraint equation directions.

Definition at line 96 of file type_vector.C.

97 {
98  for (unsigned int i=0; i<LIBMESH_DIM; i++)
99  {
100  if ((*this)(i) < rhs(i))
101  return true;
102  if ((*this)(i) > rhs(i))
103  return false;
104  }
105  return true;
106 }

◆ operator=()

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; }

◆ operator==()

template<typename T>
bool libMesh::TypeVector< T >::operator== ( const TypeVector< T > &  rhs) const
inlineinherited
Returns
true if this(i)==rhs(i) for each component of the vector.
Note
For floating point types T, the function absolute_fuzzy_equals() may be a more appropriate choice.

Definition at line 1067 of file type_vector.h.

1068 {
1069 #if LIBMESH_DIM == 1
1070  return (_coords[0] == rhs._coords[0]);
1071 #endif
1072 
1073 #if LIBMESH_DIM == 2
1074  return (_coords[0] == rhs._coords[0] &&
1075  _coords[1] == rhs._coords[1]);
1076 #endif
1077 
1078 #if LIBMESH_DIM == 3
1079  return (_coords[0] == rhs._coords[0] &&
1080  _coords[1] == rhs._coords[1] &&
1081  _coords[2] == rhs._coords[2]);
1082 #endif
1083 }

◆ operator>() [1/2]

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

Definition at line 178 of file type_vector.C.

179 {
180  for (unsigned int i=0; i<LIBMESH_DIM; i++)
181  {
182  if ((*this)(i).real() > rhs(i).real())
183  return true;
184  if ((*this)(i).real() < rhs(i).real())
185  return false;
186  if ((*this)(i).imag() > rhs(i).imag())
187  return true;
188  if ((*this)(i).imag() < rhs(i).imag())
189  return false;
190  }
191  return false;
192 }

◆ operator>() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator> ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is "greater" than rhs.

Useful for sorting. Also used for choosing some arbitrary basis function orientations.

Definition at line 111 of file type_vector.C.

112 {
113  for (unsigned int i=0; i<LIBMESH_DIM; i++)
114  {
115  if ((*this)(i) > rhs(i))
116  return true;
117  if ((*this)(i) < rhs(i))
118  return false;
119  }
120  return false;
121 }

◆ operator>=() [1/2]

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

Definition at line 197 of file type_vector.C.

198 {
199  for (unsigned int i=0; i<LIBMESH_DIM; i++)
200  {
201  if ((*this)(i).real() > rhs(i).real())
202  return true;
203  if ((*this)(i).real() < rhs(i).real())
204  return false;
205  if ((*this)(i).imag() > rhs(i).imag())
206  return true;
207  if ((*this)(i).imag() < rhs(i).imag())
208  return false;
209  }
210  return true;
211 }

◆ operator>=() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator>= ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is >= rhs.

Useful for sorting. Also used for choosing some arbitrary constraint equation directions.

Definition at line 125 of file type_vector.C.

126 {
127  for (unsigned int i=0; i<LIBMESH_DIM; i++)
128  {
129  if ((*this)(i) > rhs(i))
130  return true;
131  if ((*this)(i) < rhs(i))
132  return false;
133  }
134  return true;
135 }

◆ print()

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

38 {
39 #if LIBMESH_DIM == 1
40 
41  os << "x=" << (*this)(0);
42 
43 #endif
44 #if LIBMESH_DIM == 2
45 
46  os << "(x,y)=("
47  << std::setw(8) << (*this)(0) << ", "
48  << std::setw(8) << (*this)(1) << ")";
49 
50 #endif
51 #if LIBMESH_DIM == 3
52 
53  os << "(x,y,z)=("
54  << std::setw(8) << (*this)(0) << ", "
55  << std::setw(8) << (*this)(1) << ", "
56  << std::setw(8) << (*this)(2) << ")";
57 #endif
58 }

◆ relative_fuzzy_equals()

template<typename T>
bool libMesh::TypeVector< T >::relative_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const
inlineinherited
Returns
true if two vectors are equal to within a relative tolerance of tol.

Definition at line 1042 of file type_vector.h.

1043 {
1044 #if LIBMESH_DIM == 1
1045  return this->absolute_fuzzy_equals(rhs, tol *
1046  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
1047 #endif
1048 
1049 #if LIBMESH_DIM == 2
1050  return this->absolute_fuzzy_equals(rhs, tol *
1051  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1052  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
1053 #endif
1054 
1055 #if LIBMESH_DIM == 3
1056  return this->absolute_fuzzy_equals(rhs, tol *
1057  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1058  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
1059  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
1060 #endif
1061 }

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::Hex20::has_affine_map(), libMesh::Hex27::has_affine_map(), libMesh::Prism18::has_affine_map(), libMesh::Prism15::has_affine_map(), libMesh::Quad4::volume(), and libMesh::Tri6::volume().

◆ size()

template<typename T>
auto libMesh::TypeVector< T >::size ( ) const -> decltype(std::norm(T()))
inlineinherited
Returns
The magnitude of the vector, i.e. the square-root of the sum of the elements squared.

Definition at line 944 of file type_vector.h.

945 {
946  libmesh_deprecated();
947  return this->norm();
948 }

Referenced by libMesh::DofMap::allgather_recursive_constraints(), assemble_poisson(), libMesh::DofMap::get_info(), libMesh::InfFEMap::inverse_map(), libMesh::FEInterface::inverse_map(), libMesh::Parallel::sync_dofobject_data_by_xyz(), and SlitMeshRefinedSystemTest::testRestart().

◆ size_sq()

template<typename T>
auto libMesh::TypeVector< T >::size_sq ( ) const -> decltype(std::norm(T()))
inlineinherited
Returns
The magnitude of the vector squared, i.e. the sum of the element magnitudes squared.

Definition at line 975 of file type_vector.h.

976 {
977  libmesh_deprecated();
978  return this->norm_sq();
979 }

◆ slice() [1/2]

template<typename T>
T& libMesh::TypeVector< T >::slice ( const unsigned int  i)
inlineinherited

Definition at line 180 of file type_vector.h.

180 { return (*this)(i); }

◆ slice() [2/2]

template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inlineinherited

Definition at line 174 of file type_vector.h.

174 { return (*this)(i); }

◆ subtract()

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

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

◆ subtract_scaled()

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

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

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

◆ unit()

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const
inlineinherited
Returns
A unit vector in the direction of *this.

Definition at line 1158 of file type_vector.h.

1159 {
1160 
1161  auto && length = norm();
1162 
1163  libmesh_assert_not_equal_to (length, static_cast<Real>(0.));
1164 
1165 #if LIBMESH_DIM == 1
1166  return TypeVector<T>(_coords[0]/length);
1167 #endif
1168 
1169 #if LIBMESH_DIM == 2
1170  return TypeVector<T>(_coords[0]/length,
1171  _coords[1]/length);
1172 #endif
1173 
1174 #if LIBMESH_DIM == 3
1175  return TypeVector<T>(_coords[0]/length,
1176  _coords[1]/length,
1177  _coords[2]/length);
1178 #endif
1179 
1180 }

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

◆ write_unformatted()

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. Also prints a newline by default, however, this behavior can be controlled with the newline parameter.

Definition at line 65 of file type_vector.C.

67 {
68  libmesh_assert (os);
69 
70  os << std::setiosflags(std::ios::showpoint)
71  << (*this)(0) << " "
72  << (*this)(1) << " "
73  << (*this)(2) << " ";
74 
75  if (newline)
76  os << '\n';
77 }

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

◆ zero()

template<typename T >
void libMesh::TypeVector< T >::zero ( )
inlineinherited

Set all entries of the vector to 0.

Definition at line 964 of file type_vector.h.

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

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

Member Data Documentation

◆ _coords

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

The coordinates of the TypeVector.

Definition at line 445 of file type_vector.h.

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


The documentation for this class was generated from the following files:
libMesh::TypeVector::add
void add(const TypeVector< T2 > &)
Add to this vector without creating a temporary.
Definition: type_vector.h:641
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TypeVector::zero
void zero()
Set all entries of the vector to 0.
Definition: type_vector.h:964
libMesh::libmesh_assert
libmesh_assert(ctx)
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TypeVector::norm_sq
auto norm_sq() const -> decltype(std::norm(T()))
Definition: type_vector.h:986
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
libMesh::TypeVector::_coords
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:445
libMesh::CompareTypes::supertype
void supertype
Definition: compare_types.h:100
libMesh::Complex
std::complex< Real > Complex
Definition: libmesh_common.h:160
libMesh::TypeVector::TypeVector
TypeVector()
Empty constructor.
Definition: type_vector.h:457
libMesh::TensorTools::norm_sq
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:85
libMesh::TypeVector::subtract
void subtract(const TypeVector< T2 > &)
Subtract from this vector without creating a temporary.
Definition: type_vector.h:728
libMesh::TypeVector::norm
auto norm() const -> decltype(std::norm(T()))
Definition: type_vector.h:955
std::imag
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
Definition: float128_shims.h:83
libMesh::TypeVector::absolute_fuzzy_equals
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:1017
std::real
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
Definition: float128_shims.h:77