libMesh::Point Class Reference

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

#include <point.h>

Inheritance diagram for libMesh::Point:

Public Types

typedef Real value_type
 
typedef unsigned int index_type
 

Public Member Functions

 Point (const Real x=0., const Real y=0., const Real z=0.)
 
 Point (const Point &p)
 
 Point (const TypeVector< Real > &p)
 
 ~Point ()
 
void assign (const TypeVector< T2 > &)
 
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
 
const TypeVector< Real > & operator+= (const TypeVector< T2 > &)
 
void add (const TypeVector< T2 > &)
 
void add_scaled (const TypeVector< T2 > &, const Real)
 
TypeVector< typename CompareTypes< Real, T2 >::supertype > operator- (const TypeVector< T2 > &) const
 
TypeVector< Realoperator- () const
 
const TypeVector< Real > & operator-= (const TypeVector< T2 > &)
 
void subtract (const TypeVector< T2 > &)
 
void subtract_scaled (const TypeVector< T2 > &, const Real)
 
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real, Scalar >::supertype > >::type operator* (const Scalar) const
 
CompareTypes< Real, T2 >::supertype operator* (const TypeVector< T2 > &) const
 
const TypeVector< Real > & operator*= (const Real)
 
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< Real, Scalar >::supertype > >::type operator/ (const Scalar) const
 
const TypeVector< Real > & operator/= (const Real)
 
CompareTypes< Real, T2 >::supertype contract (const TypeVector< T2 > &) const
 
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross (const TypeVector< T2 > &v) const
 
TypeVector< Realunit () const
 
Real size () const
 
Real norm () const
 
Real size_sq () const
 
Real norm_sq () const
 
void zero ()
 
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
 
void write_unformatted (std::ostream &out, const bool newline=true) const
 

Protected Attributes

Real _coords [LIBMESH_DIM]
 

Friends

class Node
 

Detailed Description

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

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

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

Constructor & Destructor Documentation

◆ Point() [1/3]

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/3]

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/3]

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

libMesh::Point::~Point ( )
inline

Empty.

Definition at line 69 of file point.h.

69 {}

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

References std::abs().

966 {
967 #if LIBMESH_DIM == 1
968  return (std::abs(_coords[0] - rhs._coords[0])
969  <= tol);
970 #endif
971 
972 #if LIBMESH_DIM == 2
973  return (std::abs(_coords[0] - rhs._coords[0]) +
974  std::abs(_coords[1] - rhs._coords[1])
975  <= tol);
976 #endif
977 
978 #if LIBMESH_DIM == 3
979  return (std::abs(_coords[0] - rhs._coords[0]) +
980  std::abs(_coords[1] - rhs._coords[1]) +
981  std::abs(_coords[2] - rhs._coords[2])
982  <= tol);
983 #endif
984 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409
double abs(double a)

◆ add()

void libMesh::TypeVector< Real >::add ( const TypeVector< T2 > &  p)
inlineinherited

Add to this vector without creating a temporary.

Definition at line 603 of file type_vector.h.

604 {
605 #if LIBMESH_DIM == 1
606  _coords[0] += p._coords[0];
607 #endif
608 
609 #if LIBMESH_DIM == 2
610  _coords[0] += p._coords[0];
611  _coords[1] += p._coords[1];
612 #endif
613 
614 #if LIBMESH_DIM == 3
615  _coords[0] += p._coords[0];
616  _coords[1] += p._coords[1];
617  _coords[2] += p._coords[2];
618 #endif
619 
620 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

628 {
629 #if LIBMESH_DIM == 1
630  _coords[0] += factor*p(0);
631 #endif
632 
633 #if LIBMESH_DIM == 2
634  _coords[0] += factor*p(0);
635  _coords[1] += factor*p(1);
636 #endif
637 
638 #if LIBMESH_DIM == 3
639  _coords[0] += factor*p(0);
640  _coords[1] += factor*p(1);
641  _coords[2] += factor*p(2);
642 #endif
643 
644 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ assign()

void libMesh::TypeVector< Real >::assign ( const TypeVector< T2 > &  p)
inlineinherited

Assign to this vector without creating a temporary.

Definition at line 532 of file type_vector.h.

533 {
534  for (unsigned int i=0; i<LIBMESH_DIM; i++)
535  _coords[i] = p._coords[i];
536 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ contract()

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

Definition at line 872 of file type_vector.h.

873 {
874  return (*this)*(p);
875 }

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

883 {
884  typedef typename CompareTypes<T, T2>::supertype TS;
885  libmesh_assert_equal_to (LIBMESH_DIM, 3);
886 
887  // | i j k |
888  // |(*this)(0) (*this)(1) (*this)(2)|
889  // | p(0) p(1) p(2) |
890 
891  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
892  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
893  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
894 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ norm()

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

Definition at line 912 of file type_vector.h.

References libMesh::TensorTools::norm_sq().

913 {
914  return std::sqrt(this->norm_sq());
915 }

◆ norm_sq()

Real libMesh::TypeVector< Real >::norm_sq ( ) const
inlineinherited
Returns
The magnitude of the vector squared, i.e. the sum of the element magnitudes squared.

Definition at line 943 of file type_vector.h.

References libMesh::TensorTools::norm_sq().

944 {
945 #if LIBMESH_DIM == 1
946  return (TensorTools::norm_sq(_coords[0]));
947 #endif
948 
949 #if LIBMESH_DIM == 2
950  return (TensorTools::norm_sq(_coords[0]) +
952 #endif
953 
954 #if LIBMESH_DIM == 3
955  return (TensorTools::norm_sq(_coords[0]) +
958 #endif
959 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ operator!=()

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

Definition at line 1037 of file type_vector.h.

1038 {
1039  return (!(*this == rhs));
1040 }

◆ operator()() [1/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 542 of file type_vector.h.

543 {
544  libmesh_assert_less (i, LIBMESH_DIM);
545 
546  return _coords[i];
547 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ operator()() [2/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 553 of file type_vector.h.

554 {
555  libmesh_assert_less (i, LIBMESH_DIM);
556 
557  return _coords[i];
558 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

740 {
741  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
742 
743 #if LIBMESH_DIM == 1
744  return TypeVector<SuperType>(_coords[0]*factor);
745 #endif
746 
747 #if LIBMESH_DIM == 2
748  return TypeVector<SuperType>(_coords[0]*factor,
749  _coords[1]*factor);
750 #endif
751 
752 #if LIBMESH_DIM == 3
753  return TypeVector<SuperType>(_coords[0]*factor,
754  _coords[1]*factor,
755  _coords[2]*factor);
756 #endif
757 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

851 {
852 #if LIBMESH_DIM == 1
853  return _coords[0]*p._coords[0];
854 #endif
855 
856 #if LIBMESH_DIM == 2
857  return (_coords[0]*p._coords[0] +
858  _coords[1]*p._coords[1]);
859 #endif
860 
861 #if LIBMESH_DIM == 3
862  return (_coords[0]*p(0) +
863  _coords[1]*p(1) +
864  _coords[2]*p(2));
865 #endif
866 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

777 {
778 #if LIBMESH_DIM == 1
779  _coords[0] *= factor;
780 #endif
781 
782 #if LIBMESH_DIM == 2
783  _coords[0] *= factor;
784  _coords[1] *= factor;
785 #endif
786 
787 #if LIBMESH_DIM == 3
788  _coords[0] *= factor;
789  _coords[1] *= factor;
790  _coords[2] *= factor;
791 #endif
792 
793  return *this;
794 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

567 {
568  typedef typename CompareTypes<T, T2>::supertype TS;
569 #if LIBMESH_DIM == 1
570  return TypeVector<TS> (_coords[0] + p._coords[0]);
571 #endif
572 
573 #if LIBMESH_DIM == 2
574  return TypeVector<TS> (_coords[0] + p._coords[0],
575  _coords[1] + p._coords[1]);
576 #endif
577 
578 #if LIBMESH_DIM == 3
579  return TypeVector<TS> (_coords[0] + p._coords[0],
580  _coords[1] + p._coords[1],
581  _coords[2] + p._coords[2]);
582 #endif
583 
584 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

592 {
593  this->add (p);
594 
595  return *this;
596 }
void add(const TypeVector< T2 > &)
Definition: type_vector.h:603

◆ operator-() [1/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 652 of file type_vector.h.

653 {
654  typedef typename CompareTypes<T, T2>::supertype TS;
655 
656 #if LIBMESH_DIM == 1
657  return TypeVector<TS>(_coords[0] - p._coords[0]);
658 #endif
659 
660 #if LIBMESH_DIM == 2
661  return TypeVector<TS>(_coords[0] - p._coords[0],
662  _coords[1] - p._coords[1]);
663 #endif
664 
665 #if LIBMESH_DIM == 3
666  return TypeVector<TS>(_coords[0] - p._coords[0],
667  _coords[1] - p._coords[1],
668  _coords[2] - p._coords[2]);
669 #endif
670 
671 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ operator-() [2/2]

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

Definition at line 711 of file type_vector.h.

712 {
713 
714 #if LIBMESH_DIM == 1
715  return TypeVector(-_coords[0]);
716 #endif
717 
718 #if LIBMESH_DIM == 2
719  return TypeVector(-_coords[0],
720  -_coords[1]);
721 #endif
722 
723 #if LIBMESH_DIM == 3
724  return TypeVector(-_coords[0],
725  -_coords[1],
726  -_coords[2]);
727 #endif
728 
729 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

679 {
680  this->subtract (p);
681 
682  return *this;
683 }
void subtract(const TypeVector< T2 > &)
Definition: type_vector.h:690

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

805 {
806  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
807 
808  typedef typename CompareTypes<T, Scalar>::supertype TS;
809 
810 #if LIBMESH_DIM == 1
811  return TypeVector<TS>(_coords[0]/factor);
812 #endif
813 
814 #if LIBMESH_DIM == 2
815  return TypeVector<TS>(_coords[0]/factor,
816  _coords[1]/factor);
817 #endif
818 
819 #if LIBMESH_DIM == 3
820  return TypeVector<TS>(_coords[0]/factor,
821  _coords[1]/factor,
822  _coords[2]/factor);
823 #endif
824 
825 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

834 {
835  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
836 
837  for (unsigned int i=0; i<LIBMESH_DIM; i++)
838  _coords[i] /= factor;
839 
840  return *this;
841 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ operator<() [1/2]

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 }

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

◆ operator<=() [1/2]

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 }

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

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

Referenced by libMesh::Node::operator==().

1016 {
1017 #if LIBMESH_DIM == 1
1018  return (_coords[0] == rhs._coords[0]);
1019 #endif
1020 
1021 #if LIBMESH_DIM == 2
1022  return (_coords[0] == rhs._coords[0] &&
1023  _coords[1] == rhs._coords[1]);
1024 #endif
1025 
1026 #if LIBMESH_DIM == 3
1027  return (_coords[0] == rhs._coords[0] &&
1028  _coords[1] == rhs._coords[1] &&
1029  _coords[2] == rhs._coords[2]);
1030 #endif
1031 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ operator>() [1/2]

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 }

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

139 {
140  for (unsigned int i=0; i<LIBMESH_DIM; i++)
141  {
142  if ((*this)(i) > rhs(i))
143  return true;
144  if ((*this)(i) < rhs(i))
145  return false;
146  }
147  return false;
148 }

◆ operator>=() [1/2]

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 }

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

153 {
154  for (unsigned int i=0; i<LIBMESH_DIM; i++)
155  {
156  if ((*this)(i) > rhs(i))
157  return true;
158  if ((*this)(i) < rhs(i))
159  return false;
160  }
161  return true;
162 }

◆ print()

void libMesh::TypeVector< Real >::print ( std::ostream &  os = libMesh::out) const
inherited

Formatted print, by default to libMesh::out.

Definition at line 64 of file type_vector.C.

65 {
66 #if LIBMESH_DIM == 1
67 
68  os << "x=" << (*this)(0);
69 
70 #endif
71 #if LIBMESH_DIM == 2
72 
73  os << "(x,y)=("
74  << std::setw(8) << (*this)(0) << ", "
75  << std::setw(8) << (*this)(1) << ")";
76 
77 #endif
78 #if LIBMESH_DIM == 3
79 
80  os << "(x,y,z)=("
81  << std::setw(8) << (*this)(0) << ", "
82  << std::setw(8) << (*this)(1) << ", "
83  << std::setw(8) << (*this)(2) << ")";
84 #endif
85 }

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

References std::abs().

991 {
992 #if LIBMESH_DIM == 1
993  return this->absolute_fuzzy_equals(rhs, tol *
994  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
995 #endif
996 
997 #if LIBMESH_DIM == 2
998  return this->absolute_fuzzy_equals(rhs, tol *
999  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1000  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
1001 #endif
1002 
1003 #if LIBMESH_DIM == 3
1004  return this->absolute_fuzzy_equals(rhs, tol *
1005  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1006  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
1007  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
1008 #endif
1009 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409
double abs(double a)
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:965

◆ size()

Real libMesh::TypeVector< Real >::size ( ) const
inlineinherited
Returns
The magnitude of the vector, i.e. the square-root of the sum of the elements squared.
Deprecated:
Use the norm() function instead.

Definition at line 901 of file type_vector.h.

902 {
903  libmesh_deprecated();
904  return this->norm();
905 }

◆ size_sq()

Real libMesh::TypeVector< Real >::size_sq ( ) const
inlineinherited
Returns
The magnitude of the vector squared, i.e. the sum of the element magnitudes squared.
Deprecated:
Use the norm_sq() function instead.

Definition at line 932 of file type_vector.h.

References libMesh::TensorTools::norm_sq().

933 {
934  libmesh_deprecated();
935  return this->norm_sq();
936 }

◆ slice() [1/2]

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

Definition at line 143 of file type_vector.h.

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

◆ slice() [2/2]

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

Definition at line 149 of file type_vector.h.

149 { 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 690 of file type_vector.h.

691 {
692  for (unsigned int i=0; i<LIBMESH_DIM; i++)
693  _coords[i] -= p._coords[i];
694 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

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

702 {
703  for (unsigned int i=0; i<LIBMESH_DIM; i++)
704  _coords[i] -= factor*p(i);
705 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

◆ unit()

TypeVector< Real > libMesh::TypeVector< Real >::unit ( ) const
inherited
Returns
A unit vector in the direction of *this.

Definition at line 37 of file type_vector.C.

References libMesh::Real.

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 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

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

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 }

◆ zero()

void libMesh::TypeVector< Real >::zero ( )
inlineinherited

Set all entries of the vector to 0.

Definition at line 921 of file type_vector.h.

922 {
923  for (unsigned int i=0; i<LIBMESH_DIM; i++)
924  _coords[i] = 0.;
925 }
Real _coords[LIBMESH_DIM]
Definition: type_vector.h:409

Friends And Related Function Documentation

◆ Node

friend class Node
friend

Make the derived class a friend.

Definition at line 76 of file point.h.

Member Data Documentation

◆ _coords

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

The coordinates of the TypeVector.

Definition at line 409 of file type_vector.h.


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