ThunderEgg  1.0.0
ThunderEgg::Vector< D > Class Template Reference

Vector class for use in thunderegg. More...

#include <Vector.h>

Public Member Functions

 Vector ()
 Construct a new Vector object of size 0.
 
 Vector (Communicator comm, const std::array< int, D > &ns, int num_components, int num_local_patches, int num_ghost_cells)
 Construct a new Vector object with managed memory. More...
 
 Vector (const Domain< D > &domain, int num_components)
 Construct a new Vector object for a given domain. More...
 
 Vector (Communicator comm, const std::vector< double * > &patch_starts, const std::array< int, D+1 > &strides, const std::array< int, D+1 > &lengths, int num_ghost_cells)
 Construct a new Vector object with unmanaged memory. More...
 
 Vector (const Vector< D > &other)
 Copy constructor. More...
 
Vector< D > & operator= (const Vector< D > &other)
 Copy assignment. More...
 
 Vector (Vector< D > &&other)
 Move constructor. More...
 
Vector< D > & operator= (Vector< D > &&other)
 Move assignment. More...
 
const CommunicatorgetCommunicator () const
 get the MPI Comm that this vector uses More...
 
int getNumComponents () const
 
int getNumLocalPatches () const
 Get the number of local patches.
 
int getNumLocalCells () const
 Get the number of local cells int he vector (excluding ghost cells) More...
 
int getNumGhostCells () const
 Get the number of ghost cells. More...
 
ComponentView< double, D > getComponentView (int component_index, int patch_local_index)
 Get the ComponentView for the specified patch and component. More...
 
ComponentView< const double, D > getComponentView (int component_index, int patch_local_index) const
 Get the ComponentView for the specified patch and component. More...
 
PatchView< double, D > getPatchView (int patch_local_index)
 Get the View objects for the specified patch index of View object will correspond to component index. More...
 
PatchView< const double, D > getPatchView (int patch_local_index) const
 Get the View objects for the specified patch index of View object will correspond to component index. More...
 
void set (double alpha)
 set all value in the vector More...
 
void setWithGhost (double alpha)
 set all values in the vector (including ghost cells) More...
 
void scale (double alpha)
 scale all elements in the vector More...
 
void shift (double delta)
 shift all the values in the vector More...
 
void copy (const Vector< D > &b)
 copy the values of the other vector More...
 
void copyWithGhost (const Vector< D > &b)
 copy the values of the other vector include ghost cell values More...
 
void add (const Vector< D > &b)
 add the other vector to this vector More...
 
void addScaled (double alpha, const Vector< D > &b)
 this = this + alpha * b
 
void addScaled (double alpha, const Vector< D > &a, double beta, const Vector< D > &b)
 this = this + alpha * a + beta * b
 
void scaleThenAdd (double alpha, const Vector< D > &b)
 this = alpha * this + b
 
void scaleThenAddScaled (double alpha, double beta, const Vector< D > &b)
 this = alpha * this + beta * b
 
void scaleThenAddScaled (double alpha, double beta, const Vector< D > &b, double gamma, const Vector< D > &c)
 this = alpha * this + beta * b + gamma * c
 
double twoNorm () const
 get the l2norm
 
double infNorm () const
 get the infnorm
 
double dot (const Vector< D > &b) const
 get the dot product
 
Vector< D > getZeroClone () const
 Get a vector of the same length initialized to zero. More...
 

Detailed Description

template<int D>
class ThunderEgg::Vector< D >

Vector class for use in thunderegg.

Template Parameters
Dthe number of cartesian dimensions

Constructor & Destructor Documentation

◆ Vector() [1/5]

template<int D>
ThunderEgg::Vector< D >::Vector ( Communicator  comm,
const std::array< int, D > &  ns,
int  num_components,
int  num_local_patches,
int  num_ghost_cells 
)
inline

Construct a new Vector object with managed memory.

Parameters
commthe MPI comm that is being used
num_componentsthe number of components for each patch
num_local_patchesthe number of local patches in this vector
num_local_cellsthe number of local (non-ghost) cells in this vector

◆ Vector() [2/5]

template<int D>
ThunderEgg::Vector< D >::Vector ( const Domain< D > &  domain,
int  num_components 
)
inline

Construct a new Vector object for a given domain.

Parameters
domainthe domain
num_componentsthe number of components for each patch

◆ Vector() [3/5]

template<int D>
ThunderEgg::Vector< D >::Vector ( Communicator  comm,
const std::vector< double * > &  patch_starts,
const std::array< int, D+1 > &  strides,
const std::array< int, D+1 > &  lengths,
int  num_ghost_cells 
)
inline

Construct a new Vector object with unmanaged memory.

Parameters
commthe communicator
patch_startspointers to the starts of each patch
stridesthe strides
lengthsthe lengths
num_ghost_cellsthe number of ghost cells

◆ Vector() [4/5]

template<int D>
ThunderEgg::Vector< D >::Vector ( const Vector< D > &  other)
inline

Copy constructor.

will copy all values

Parameters
otherthe vector to copy

◆ Vector() [5/5]

template<int D>
ThunderEgg::Vector< D >::Vector ( Vector< D > &&  other)
inline

Move constructor.

Parameters
otherthe vector to move

Member Function Documentation

◆ add()

template<int D>
void ThunderEgg::Vector< D >::add ( const Vector< D > &  b)
inline

add the other vector to this vector

Parameters
bthe other vector

◆ copy()

template<int D>
void ThunderEgg::Vector< D >::copy ( const Vector< D > &  b)
inline

copy the values of the other vector

Parameters
bthe other vector

◆ copyWithGhost()

template<int D>
void ThunderEgg::Vector< D >::copyWithGhost ( const Vector< D > &  b)
inline

copy the values of the other vector include ghost cell values

Parameters
bthe other vector

◆ getCommunicator()

template<int D>
const Communicator& ThunderEgg::Vector< D >::getCommunicator ( ) const
inline

get the MPI Comm that this vector uses

Returns
MPI_Comm the comm

◆ getComponentView() [1/2]

template<int D>
ComponentView<double, D> ThunderEgg::Vector< D >::getComponentView ( int  component_index,
int  patch_local_index 
)
inline

Get the ComponentView for the specified patch and component.

Parameters
component_indexthe index of the component access
patch_local_indexthe local index of the patch
Returns
ComponentView<D> the View object

◆ getComponentView() [2/2]

template<int D>
ComponentView<const double, D> ThunderEgg::Vector< D >::getComponentView ( int  component_index,
int  patch_local_index 
) const
inline

Get the ComponentView for the specified patch and component.

Parameters
component_indexthe index of the component access
patch_local_indexthe local index of the patch
Returns
ComponentView<D> the View object

◆ getNumGhostCells()

template<int D>
int ThunderEgg::Vector< D >::getNumGhostCells ( ) const
inline

Get the number of ghost cells.

Returns
int the number of ghost cells

◆ getNumLocalCells()

template<int D>
int ThunderEgg::Vector< D >::getNumLocalCells ( ) const
inline

Get the number of local cells int he vector (excluding ghost cells)

Returns
int the number of local cells

◆ getPatchView() [1/2]

template<int D>
PatchView<double, D> ThunderEgg::Vector< D >::getPatchView ( int  patch_local_index)
inline

Get the View objects for the specified patch index of View object will correspond to component index.

Parameters
patch_local_indexthe local index of the patch
Returns
View<D> the View object

◆ getPatchView() [2/2]

template<int D>
PatchView<const double, D> ThunderEgg::Vector< D >::getPatchView ( int  patch_local_index) const
inline

Get the View objects for the specified patch index of View object will correspond to component index.

Parameters
patch_local_indexthe local index of the patch
Returns
View<D> the View object

◆ getZeroClone()

template<int D>
Vector<D> ThunderEgg::Vector< D >::getZeroClone ( ) const
inline

Get a vector of the same length initialized to zero.

Returns
Vector<D> the vector of the same length initialize to zero

◆ operator=() [1/2]

template<int D>
Vector<D>& ThunderEgg::Vector< D >::operator= ( const Vector< D > &  other)
inline

Copy assignment.

will copy all values

Parameters
otherthe vector to copy
Returns
Vector<D>& this

◆ operator=() [2/2]

template<int D>
Vector<D>& ThunderEgg::Vector< D >::operator= ( Vector< D > &&  other)
inline

Move assignment.

Parameters
otherthe vector to move
Returns
Vector<D>&& this

◆ scale()

template<int D>
void ThunderEgg::Vector< D >::scale ( double  alpha)
inline

scale all elements in the vector

Parameters
alphathe value to scale by

◆ set()

template<int D>
void ThunderEgg::Vector< D >::set ( double  alpha)
inline

set all value in the vector

Parameters
alphathe value ot be set

◆ setWithGhost()

template<int D>
void ThunderEgg::Vector< D >::setWithGhost ( double  alpha)
inline

set all values in the vector (including ghost cells)

Parameters
alphathe value ot be set

◆ shift()

template<int D>
void ThunderEgg::Vector< D >::shift ( double  delta)
inline

shift all the values in the vector

Parameters
deltathe value to shift by

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