Vector< Cmpt > Class Template Reference

Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators. More...

Inheritance diagram for Vector< Cmpt >:
Collaboration diagram for Vector< Cmpt >:

Public Types

enum  components { X, Y, Z }
 Component labeling enumeration. More...
 
typedef Vector< label > labelType
 Equivalent type of labels used for valid component indexing. More...
 
- Public Types inherited from VectorSpace< Vector< Cmpt >, Cmpt, 3 >
typedef VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts > vsType
 VectorSpace type. More...
 
typedef Cmpt cmptType
 Component type. More...
 
typedef Cmpt magType
 Magnitude type. More...
 
typedef Cmpt * iterator
 Random access iterator for traversing VectorSpace. More...
 
typedef const Cmpt * const_iterator
 Random access iterator for traversing VectorSpace. More...
 

Public Member Functions

 Vector ()=default
 Default construct. More...
 
 Vector (const Vector &)=default
 Copy construct. More...
 
Vectoroperator= (const Vector &)=default
 Copy assignment. More...
 
 Vector (const Foam::zero)
 Construct initialized to zero. More...
 
template<class Cmpt2 >
 Vector (const VectorSpace< Vector< Cmpt2 >, Cmpt2, 3 > &vs)
 Copy construct from VectorSpace of the same rank. More...
 
 Vector (const Cmpt &vx, const Cmpt &vy, const Cmpt &vz)
 Construct from three components. More...
 
 Vector (Istream &is)
 Construct from Istream. More...
 
const Cmpt & x () const noexcept
 Access to the vector x component. More...
 
const Cmpt & y () const noexcept
 Access to the vector y component. More...
 
const Cmpt & z () const noexcept
 Access to the vector z component. More...
 
Cmpt & x () noexcept
 Access to the vector x component. More...
 
Cmpt & y () noexcept
 Access to the vector y component. More...
 
Cmpt & z () noexcept
 Access to the vector z component. More...
 
const Vector< Cmpt > & centre (const Foam::UList< Vector< Cmpt >> &) const noexcept
 Return this (for point which is a typedef to Vector<scalar>) More...
 
scalar mag () const
 The length (L2-norm) of the vector. More...
 
scalar magSqr () const
 The length (L2-norm) squared of the vector. More...
 
scalar dist (const Vector< Cmpt > &v2) const
 The L2-norm distance from another vector. The mag() of the difference. More...
 
scalar distSqr (const Vector< Cmpt > &v2) const
 The L2-norm distance squared from another vector. The magSqr() of the difference. More...
 
Vector< Cmpt > & normalise (const scalar tol=ROOTVSMALL)
 Inplace normalise the vector by its magnitude. More...
 
Vector< Cmpt > & removeCollinear (const Vector< Cmpt > &unitVec)
 Inplace removal of components that are collinear to the given unit vector. More...
 
Cmpt inner (const Vector< Cmpt > &v2) const
 Scalar-product of this with another Vector. More...
 
Vector< Cmpt > cross (const Vector< Cmpt > &v2) const
 Cross-product of this with another Vector. More...
 
- Public Member Functions inherited from VectorSpace< Vector< Cmpt >, Cmpt, 3 >
 VectorSpace ()=default
 Default construct. More...
 
 VectorSpace (const Foam::zero)
 Construct initialized to zero. More...
 
 VectorSpace (const VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts > &vs)
 Copy construct. More...
 
 VectorSpace (const VectorSpace< Form2, Cmpt2, Ncmpts > &)
 Copy construct of a VectorSpace with the same size. More...
 
 VectorSpace (Istream &is)
 Construct from Istream. More...
 
const Cmpt & component (const direction) const
 
Cmpt & component (const direction)
 
void component (Cmpt &, const direction) const
 
void replace (const direction, const Cmpt &)
 
const Cmpt * cdata () const noexcept
 Return const pointer to the first data element. More...
 
Cmpt * data () noexcept
 Return pointer to the first data element. More...
 
const ConstBlock< SubVector, BStart > block () const
 
const Foam::VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts >::template ConstBlock< SubVector, BStart > block () const
 
const Cmpt & operator[] (const direction) const
 
Cmpt & operator[] (const direction)
 
void operator= (const VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts > &)
 
void operator= (const Foam::zero)
 
void operator+= (const VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts > &)
 
void operator-= (const VectorSpace< Vector< Cmpt >, Cmpt, Ncmpts > &)
 
void operator*= (const scalar)
 
void operator/= (const scalar)
 
iterator begin () noexcept
 Return an iterator to begin of VectorSpace. More...
 
const_iterator begin () const noexcept
 Return const_iterator to begin of VectorSpace. More...
 
iterator end () noexcept
 Return an iterator to end of VectorSpace. More...
 
const_iterator end () const noexcept
 Return const_iterator to end of VectorSpace. More...
 
const_iterator cbegin () const noexcept
 Return const_iterator to begin of VectorSpace. More...
 
const_iterator cend () const noexcept
 Return const_iterator to end of VectorSpace. More...
 

Static Public Member Functions

static bool less_xyz (const Vector< Cmpt > &a, const Vector< Cmpt > &b)
 Lexicographically compare a and b with order (x:y:z) More...
 
static bool less_yzx (const Vector< Cmpt > &a, const Vector< Cmpt > &b)
 Lexicographically compare a and b with order (y:z:x) More...
 
static bool less_zxy (const Vector< Cmpt > &a, const Vector< Cmpt > &b)
 Lexicographically compare a and b with order (z:x:y) More...
 
- Static Public Member Functions inherited from VectorSpace< Vector< Cmpt >, Cmpt, 3 >
static constexpr direction size () noexcept
 The number of elements in the VectorSpace = Ncmpts. More...
 
static Vector< Cmpt > uniform (const Cmpt &s)
 Return a VectorSpace with all elements = s. More...
 

Static Public Attributes

static constexpr direction rank = 1
 Rank of Vector is 1. More...
 
- Static Public Attributes inherited from VectorSpace< Vector< Cmpt >, Cmpt, 3 >
static constexpr direction dim
 Dimensionality of space. More...
 
static constexpr direction nComponents
 Number of components in this vector space. More...
 
static constexpr direction mRows
 
static constexpr direction nCols
 
static const char *const typeName
 
static const char *const componentNames []
 
static const Vector< Cmpt > zero
 
static const Vector< Cmpt > one
 
static const Vector< Cmpt > max
 
static const Vector< Cmpt > min
 
static const Vector< Cmpt > rootMax
 
static const Vector< Cmpt > rootMin
 

Additional Inherited Members

- Public Attributes inherited from VectorSpace< Vector< Cmpt >, Cmpt, 3 >
Cmpt v_ [Ncmpts]
 The components of this vector space. More...
 

Detailed Description

template<class Cmpt>
class Foam::Vector< Cmpt >

Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators.

A centre() member function which returns the Vector for which it is called is defined so that point which is a typedef to Vector<scalar> behaves as other shapes in the shape hierarchy.

Source files

Definition at line 58 of file Vector.H.

Member Typedef Documentation

◆ labelType

typedef Vector<label> labelType

Equivalent type of labels used for valid component indexing.

Definition at line 69 of file Vector.H.

Member Enumeration Documentation

◆ components

enum components

Component labeling enumeration.

Enumerator

Definition at line 83 of file Vector.H.

Constructor & Destructor Documentation

◆ Vector() [1/6]

Vector ( )
default

Default construct.

◆ Vector() [2/6]

Vector ( const Vector< Cmpt > &  )
default

Copy construct.

◆ Vector() [3/6]

Vector ( const Foam::zero  )
inline

Construct initialized to zero.

Definition at line 25 of file VectorI.H.

◆ Vector() [4/6]

Vector ( const VectorSpace< Vector< Cmpt2 >, Cmpt2, 3 > &  vs)
inline

Copy construct from VectorSpace of the same rank.

Definition at line 34 of file VectorI.H.

◆ Vector() [5/6]

Vector ( const Cmpt &  vx,
const Cmpt &  vy,
const Cmpt &  vz 
)
inline

Construct from three components.

Definition at line 44 of file VectorI.H.

◆ Vector() [6/6]

Vector ( Istream is)
inlineexplicit

Construct from Istream.

Definition at line 57 of file VectorI.H.

Member Function Documentation

◆ operator=()

Vector& operator= ( const Vector< Cmpt > &  )
default

Copy assignment.

Referenced by triad::operator=().

Here is the caller graph for this function:

◆ x() [1/2]

const Cmpt& x ( ) const
inlinenoexcept

Access to the vector x component.

Definition at line 135 of file Vector.H.

Referenced by SymmTensor< scalar >::addDiag(), Tensor< scalar >::addDiag(), BarycentricTensor< Cmpt >::BarycentricTensor(), blockDescriptor::blockDescriptor(), PDRblock::blockMeshDict(), PDRblock::C(), energySpectrum::calcAndWriteSpectrum(), ijkAddressing::checkIndex(), Tensor< scalar >::col(), Tensor< scalar >::cols(), Vector< Foam::List< scalar > >::cross(), volumetricBSplinesDesignVariables::dCdb(), volBSplinesBase::decomposeDV(), SymmTensor< scalar >::diag(), Tensor< scalar >::diag(), Vector< Foam::List< scalar > >::distSqr(), volumetricBSplinesDesignVariables::dndb(), volumetricBSplinesDesignVariables::dSdb(), PDRblock::dx(), volumetricBSplinesDesignVariables::dxdbFace(), volumetricBSplinesDesignVariables::dxdbVol(), Foam::eigenVector(), Foam::eigenVectors(), Foam::faceNij(), Foam::facePoint(), Foam::facePointN(), PDRblock::grid(), ijkAddressing::index(), voxelMeshSearch::index(), voxelMeshSearch::index3(), Vector< Foam::List< scalar > >::inner(), cellShapeControlMesh::insert(), Foam::lerp(), Vector< Foam::List< scalar > >::less_xyz(), Vector< Foam::List< scalar > >::less_yzx(), Vector< Foam::List< scalar > >::less_zxy(), Field< Foam::vector >::normalise(), voxelMeshSearch::offset(), Foam::operator &(), Foam::operator*(), Foam::operator/(), Foam::operator^(), ijkMesh::pointLabel(), projectFace::project(), PDRblock::reset(), IjkField< Foam::vector >::resize(), SymmTensor< scalar >::row(), Tensor< scalar >::row(), Tensor< scalar >::rows(), SpatialVector< scalar >::SpatialVector(), Foam::sqr(), SymmTensor< scalar >::subtractDiag(), Tensor< scalar >::subtractDiag(), PDRblock::V(), and ijkMesh::vertLabels().

◆ y() [1/2]

const Cmpt& y ( ) const
inlinenoexcept

Access to the vector y component.

Definition at line 140 of file Vector.H.

Referenced by SymmTensor< scalar >::addDiag(), Tensor< scalar >::addDiag(), BarycentricTensor< Cmpt >::BarycentricTensor(), blockDescriptor::blockDescriptor(), PDRblock::blockMeshDict(), PDRblock::C(), energySpectrum::calcAndWriteSpectrum(), ijkAddressing::checkIndex(), Tensor< scalar >::col(), Tensor< scalar >::cols(), Vector< Foam::List< scalar > >::cross(), volumetricBSplinesDesignVariables::dCdb(), volBSplinesBase::decomposeDV(), SymmTensor< scalar >::diag(), Tensor< scalar >::diag(), Vector< Foam::List< scalar > >::distSqr(), volumetricBSplinesDesignVariables::dndb(), volumetricBSplinesDesignVariables::dSdb(), volumetricBSplinesDesignVariables::dxdbFace(), volumetricBSplinesDesignVariables::dxdbVol(), PDRblock::dy(), Foam::eigenVector(), Foam::eigenVectors(), Foam::faceNij(), Foam::facePoint(), Foam::facePointN(), PDRblock::grid(), ijkAddressing::index(), voxelMeshSearch::index(), voxelMeshSearch::index3(), Vector< Foam::List< scalar > >::inner(), cellShapeControlMesh::insert(), Foam::lerp(), Vector< Foam::List< scalar > >::less_xyz(), Vector< Foam::List< scalar > >::less_yzx(), Vector< Foam::List< scalar > >::less_zxy(), Field< Foam::vector >::normalise(), voxelMeshSearch::offset(), Foam::operator &(), Foam::operator*(), Foam::operator/(), Foam::operator^(), ijkMesh::pointLabel(), projectFace::project(), PDRblock::reset(), IjkField< Foam::vector >::resize(), SymmTensor< scalar >::row(), Tensor< scalar >::row(), Tensor< scalar >::rows(), SpatialVector< scalar >::SpatialVector(), Foam::sqr(), SymmTensor< scalar >::subtractDiag(), Tensor< scalar >::subtractDiag(), PDRblock::V(), and ijkMesh::vertLabels().

◆ z() [1/2]

const Cmpt& z ( ) const
inlinenoexcept

Access to the vector z component.

Definition at line 145 of file Vector.H.

Referenced by SymmTensor< scalar >::addDiag(), Tensor< scalar >::addDiag(), BarycentricTensor< Cmpt >::BarycentricTensor(), blockDescriptor::blockDescriptor(), PDRblock::blockMeshDict(), PDRblock::C(), energySpectrum::calcAndWriteSpectrum(), ijkAddressing::checkIndex(), Tensor< scalar >::col(), Tensor< scalar >::cols(), Vector< Foam::List< scalar > >::cross(), volumetricBSplinesDesignVariables::dCdb(), volBSplinesBase::decomposeDV(), SymmTensor< scalar >::diag(), Tensor< scalar >::diag(), Vector< Foam::List< scalar > >::distSqr(), volumetricBSplinesDesignVariables::dndb(), volumetricBSplinesDesignVariables::dSdb(), volumetricBSplinesDesignVariables::dxdbFace(), volumetricBSplinesDesignVariables::dxdbVol(), PDRblock::dz(), Foam::eigenVector(), Foam::eigenVectors(), Foam::faceNij(), Foam::facePoint(), Foam::facePointN(), PDRblock::grid(), ijkAddressing::index(), voxelMeshSearch::index(), voxelMeshSearch::index3(), Vector< Foam::List< scalar > >::inner(), cellShapeControlMesh::insert(), Foam::lerp(), Vector< Foam::List< scalar > >::less_xyz(), Vector< Foam::List< scalar > >::less_yzx(), Vector< Foam::List< scalar > >::less_zxy(), Field< Foam::vector >::normalise(), Foam::operator &(), Foam::operator*(), Foam::operator/(), Foam::operator^(), ijkMesh::pointLabel(), projectFace::project(), PDRblock::reset(), IjkField< Foam::vector >::resize(), SymmTensor< scalar >::row(), Tensor< scalar >::row(), SymmTensor< scalar >::rows(), Tensor< scalar >::rows(), SpatialVector< scalar >::SpatialVector(), Foam::sqr(), SymmTensor< scalar >::subtractDiag(), Tensor< scalar >::subtractDiag(), PDRblock::V(), and ijkMesh::vertLabels().

◆ x() [2/2]

Cmpt& x ( )
inlinenoexcept

Access to the vector x component.

Definition at line 150 of file Vector.H.

◆ y() [2/2]

Cmpt& y ( )
inlinenoexcept

Access to the vector y component.

Definition at line 155 of file Vector.H.

◆ z() [2/2]

Cmpt& z ( )
inlinenoexcept

Access to the vector z component.

Definition at line 160 of file Vector.H.

◆ centre()

const Foam::Vector< Cmpt > & centre ( const Foam::UList< Vector< Cmpt >> &  ) const
inlinenoexcept

Return this (for point which is a typedef to Vector<scalar>)

Definition at line 67 of file VectorI.H.

◆ mag()

Foam::scalar mag ( ) const
inline

The length (L2-norm) of the vector.

Definition at line 88 of file VectorI.H.

◆ magSqr()

Foam::scalar magSqr ( ) const
inline

The length (L2-norm) squared of the vector.

Definition at line 76 of file VectorI.H.

◆ dist()

Foam::scalar dist ( const Vector< Cmpt > &  v2) const
inline

The L2-norm distance from another vector. The mag() of the difference.

Definition at line 107 of file VectorI.H.

◆ distSqr()

Foam::scalar distSqr ( const Vector< Cmpt > &  v2) const
inline

The L2-norm distance squared from another vector. The magSqr() of the difference.

Definition at line 95 of file VectorI.H.

◆ normalise()

Foam::Vector< Cmpt > & normalise ( const scalar  tol = ROOTVSMALL)
inline

Inplace normalise the vector by its magnitude.

For small magnitudes (less than ROOTVSMALL) set to zero. Will not be particularly useful for a vector of labels

Definition at line 114 of file VectorI.H.

◆ removeCollinear()

Foam::Vector< Cmpt > & removeCollinear ( const Vector< Cmpt > &  unitVec)
inline

Inplace removal of components that are collinear to the given unit vector.

Definition at line 136 of file VectorI.H.

◆ inner()

Cmpt inner ( const Vector< Cmpt > &  v2) const
inline

Scalar-product of this with another Vector.

Definition at line 146 of file VectorI.H.

Referenced by Foam::operator &().

Here is the caller graph for this function:

◆ cross()

Foam::Vector< Cmpt > cross ( const Vector< Cmpt > &  v2) const
inline

Cross-product of this with another Vector.

Definition at line 156 of file VectorI.H.

Referenced by Foam::operator^().

Here is the caller graph for this function:

◆ less_xyz()

bool less_xyz ( const Vector< Cmpt > &  a,
const Vector< Cmpt > &  b 
)
inlinestatic

Lexicographically compare a and b with order (x:y:z)

Definition at line 173 of file VectorI.H.

◆ less_yzx()

bool less_yzx ( const Vector< Cmpt > &  a,
const Vector< Cmpt > &  b 
)
inlinestatic

Lexicographically compare a and b with order (y:z:x)

Definition at line 197 of file VectorI.H.

◆ less_zxy()

bool less_zxy ( const Vector< Cmpt > &  a,
const Vector< Cmpt > &  b 
)
inlinestatic

Lexicographically compare a and b with order (z:x:y)

Definition at line 221 of file VectorI.H.

Member Data Documentation

◆ rank

constexpr direction rank = 1
static

Rank of Vector is 1.

Definition at line 77 of file Vector.H.


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