libMesh
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
libMesh::Point Class Reference

A Point defines a location in LIBMESH_DIM dimensional Real space. More...

#include <point.h>

Inheritance diagram for libMesh::Point:
[legend]

Public Types

typedef Real 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

 Point (const Real x=0., const Real y=0., const Real z=0.)
 Constructor. More...
 
 Point (const Point &p)
 Copy-constructor. More...
 
 Point (const TypeVector< Real > &p)
 Copy-constructor. More...
 
Pointoperator= (const Point &p)=default
 Copy-assignment operator. More...
 
template<typename T , typename = typename boostcopy::enable_if_c<ScalarTraits<T>::value,void>::type>
 Point (const T x)
 Disambiguate constructing from non-Real scalars. More...
 
 ~Point ()
 Empty. More...
 
void assign (const TypeVector< T2 > &)
 Assign to this vector without creating a temporary. More...
 
const Realoperator() (const unsigned int i) const
 
Realoperator() (const unsigned int i)
 
const Realslice (const unsigned int i) const
 
Realslice (const unsigned int i)
 
TypeVector< typename CompareTypes< Real, T2 >::supertype > operator+ (const TypeVector< T2 > &) const
 Add two vectors. More...
 
const TypeVector< Real > & operator+= (const TypeVector< T2 > &)
 Add to this vector. More...
 
void add (const TypeVector< T2 > &)
 Add to this vector without creating a temporary. More...
 
void add_scaled (const TypeVector< T2 > &, const Real &)
 Add a scaled value to this vector without creating a temporary. More...
 
TypeVector< typename CompareTypes< Real, T2 >::supertype > operator- (const TypeVector< T2 > &) const
 Subtract from this vector. More...
 
TypeVector< Realoperator- () const
 
const TypeVector< Real > & operator-= (const TypeVector< T2 > &)
 Subtract from this vector. More...
 
void subtract (const TypeVector< T2 > &)
 Subtract from this vector without creating a temporary. More...
 
void subtract_scaled (const TypeVector< T2 > &, const Real &)
 Subtract a scaled value from this vector without creating a temporary. More...
 
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real, Scalar >::supertype > >::type operator* (const Scalar &) const
 Multiply this vector by a scalar value. More...
 
CompareTypes< Real, T2 >::supertype operator* (const TypeVector< T2 > &) const
 
const TypeVector< Real > & operator*= (const Real &)
 Multiply this vector by a scalar value. More...
 
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real, Scalar >::supertype > >::type operator/ (const Scalar &) const
 Divide each entry of this vector by scalar value. More...
 
const TypeVector< Real > & operator/= (const Real &)
 Divide each entry of this vector by scalar value. More...
 
CompareTypes< Real, T2 >::supertype contract (const TypeVector< T2 > &) const
 
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross (const TypeVector< T2 > &v) const
 
TypeVector< Realunit () const
 
auto size () const -> decltype(std::norm(Real()))
 
auto norm () const -> decltype(std::norm(Real()))
 
auto size_sq () const -> decltype(std::norm(Real()))
 
auto norm_sq () const -> decltype(std::norm(Real()))
 
bool is_zero () const
 
void zero ()
 Set all entries of the vector to 0. More...
 
bool relative_fuzzy_equals (const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
 
bool absolute_fuzzy_equals (const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
 
bool operator== (const TypeVector< Real > &rhs) const
 
bool operator!= (const TypeVector< Real > &rhs) const
 
bool operator< (const TypeVector< Real > &rhs) const
 
bool operator< (const TypeVector< Complex > &rhs) const
 
bool operator<= (const TypeVector< Real > &rhs) const
 
bool operator<= (const TypeVector< Complex > &rhs) const
 
bool operator> (const TypeVector< Real > &rhs) const
 
bool operator> (const TypeVector< Complex > &rhs) const
 
bool operator>= (const TypeVector< Real > &rhs) const
 
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

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

Friends

class Node
 Make the derived class a friend. More...
 

Detailed Description

A Point defines a location in LIBMESH_DIM dimensional Real space.

Points are always real-valued, even if the library is configured with –enable-complex.

Author
Benjamin S. Kirk
Date
2003

A geometric point in (x,y,z) space.

Definition at line 38 of file point.h.

Member Typedef Documentation

◆ index_type

typedef unsigned int libMesh::TypeVector< Real >::index_type
inherited

Helper typedef for generic index programming.

Definition at line 141 of file type_vector.h.

◆ value_type

typedef Real libMesh::TypeVector< Real >::value_type
inherited

Helper typedef for C++98 generic programming.

Definition at line 136 of file type_vector.h.

Constructor & Destructor Documentation

◆ Point() [1/4]

libMesh::Point::Point ( const Real  x = 0.,
const Real  y = 0.,
const Real  z = 0. 
)
inline

Constructor.

By default sets all entries to 0. Gives the point 0 in LIBMESH_DIM dimensions.

Definition at line 46 of file point.h.

48  :
49  TypeVector<Real> (x,y,z)
50  {}

◆ Point() [2/4]

libMesh::Point::Point ( const Point p)
inline

Copy-constructor.

Definition at line 55 of file point.h.

55  :
56  TypeVector<Real> (p)
57  {}

◆ Point() [3/4]

libMesh::Point::Point ( const TypeVector< Real > &  p)
inline

Copy-constructor.

Definition at line 62 of file point.h.

62  :
63  TypeVector<Real> (p)
64  {}

◆ Point() [4/4]

template<typename T , typename = typename boostcopy::enable_if_c<ScalarTraits<T>::value,void>::type>
libMesh::Point::Point ( const T  x)
inline

Disambiguate constructing from non-Real scalars.

Definition at line 77 of file point.h.

77  :
78  TypeVector<Real> (x,0,0)
79  {}

◆ ~Point()

libMesh::Point::~Point ( )
inline

Empty.

Definition at line 84 of file point.h.

84 {}

Member Function Documentation

◆ absolute_fuzzy_equals()

bool libMesh::TypeVector< Real >::absolute_fuzzy_equals ( const TypeVector< Real > &  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 }

◆ add()

void libMesh::TypeVector< Real >::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 }

◆ add_scaled()

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

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

Definition at line 665 of file type_vector.h.

666 {
667 #if LIBMESH_DIM == 1
668  _coords[0] += factor*p(0);
669 #endif
670 
671 #if LIBMESH_DIM == 2
672  _coords[0] += factor*p(0);
673  _coords[1] += factor*p(1);
674 #endif
675 
676 #if LIBMESH_DIM == 3
677  _coords[0] += factor*p(0);
678  _coords[1] += factor*p(1);
679  _coords[2] += factor*p(2);
680 #endif
681 
682 }

◆ assign()

void libMesh::TypeVector< Real >::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()

CompareTypes< Real , T2 >::supertype libMesh::TypeVector< Real >::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()

TypeVector< typename CompareTypes< Real , T2 >::supertype > libMesh::TypeVector< Real >::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 }

◆ is_zero()

bool libMesh::TypeVector< Real >::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()

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

Definition at line 955 of file type_vector.h.

956 {
957  return std::sqrt(this->norm_sq());
958 }

◆ norm_sq()

auto libMesh::TypeVector< Real >::norm_sq ( ) const-> decltype(std::norm(Real ()))
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 }

◆ operator!=()

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

Definition at line 1089 of file type_vector.h.

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

◆ operator()() [1/2]

Real & libMesh::TypeVector< Real >::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]

const Real & libMesh::TypeVector< Real >::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]

boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real , Scalar >::supertype > >::type libMesh::TypeVector< Real >::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]

CompareTypes< Real , T2 >::supertype libMesh::TypeVector< Real >::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*=()

const TypeVector< Real > & libMesh::TypeVector< Real >::operator*= ( const Real &  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+()

TypeVector< typename CompareTypes< Real , T2 >::supertype > libMesh::TypeVector< Real >::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+=()

const TypeVector< Real > & libMesh::TypeVector< Real >::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]

TypeVector< Real > libMesh::TypeVector< Real >::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]

TypeVector< typename CompareTypes< Real , T2 >::supertype > libMesh::TypeVector< Real >::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-=()

const TypeVector< Real > & libMesh::TypeVector< Real >::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/()

boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real , Scalar >::supertype > >::type libMesh::TypeVector< Real >::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/=()

const TypeVector< Real > & libMesh::TypeVector< Real >::operator/= ( const Real &  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]

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]

bool libMesh::TypeVector< Real >::operator< ( const TypeVector< Real > &  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]

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]

bool libMesh::TypeVector< Real >::operator<= ( const TypeVector< Real > &  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=()

Point& libMesh::Point::operator= ( const Point p)
default

Copy-assignment operator.

◆ operator==()

bool libMesh::TypeVector< Real >::operator== ( const TypeVector< Real > &  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]

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]

bool libMesh::TypeVector< Real >::operator> ( const TypeVector< Real > &  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]

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]

bool libMesh::TypeVector< Real >::operator>= ( const TypeVector< Real > &  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()

void libMesh::TypeVector< Real >::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()

bool libMesh::TypeVector< Real >::relative_fuzzy_equals ( const TypeVector< Real > &  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 }

◆ size()

auto libMesh::TypeVector< Real >::size ( ) const-> decltype(std::norm(Real ()))
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 }

◆ size_sq()

auto libMesh::TypeVector< Real >::size_sq ( ) const-> decltype(std::norm(Real ()))
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]

Real & libMesh::TypeVector< Real >::slice ( const unsigned int  i)
inlineinherited

Definition at line 180 of file type_vector.h.

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

◆ slice() [2/2]

const Real & libMesh::TypeVector< Real >::slice ( const unsigned int  i) const
inlineinherited

Definition at line 174 of file type_vector.h.

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

◆ subtract()

void libMesh::TypeVector< Real >::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()

void libMesh::TypeVector< Real >::subtract_scaled ( const TypeVector< T2 > &  p,
const Real &  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 }

◆ unit()

TypeVector< Real > libMesh::TypeVector< Real >::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 }

◆ write_unformatted()

void libMesh::TypeVector< Real >::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 }

◆ zero()

void libMesh::TypeVector< Real >::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 }

Friends And Related Function Documentation

◆ Node

friend class Node
friend

Make the derived class a friend.

Definition at line 91 of file point.h.

Member Data Documentation

◆ _coords

Real libMesh::TypeVector< Real >::_coords[LIBMESH_DIM]
protectedinherited

The coordinates of the TypeVector.

Definition at line 445 of file type_vector.h.


The documentation for this class was generated from the following file:
libMesh::TypeVector< Real >::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::libmesh_assert
libmesh_assert(ctx)
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TypeVector< Real >::norm_sq
auto norm_sq() const -> decltype(std::norm(Real()))
Definition: type_vector.h:986
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
libMesh::TypeVector< Real >::_coords
Real _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:445
libMesh::TypeVector< Real >::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< Real >::subtract
void subtract(const TypeVector< T2 > &)
Subtract from this vector without creating a temporary.
Definition: type_vector.h:728
libMesh::TypeVector< Real >::norm
auto norm() const -> decltype(std::norm(Real()))
Definition: type_vector.h:955
std::imag
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
Definition: float128_shims.h:83
libMesh::TypeVector< Real >::absolute_fuzzy_equals
bool absolute_fuzzy_equals(const TypeVector< Real > &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