PSCF v1.1
Public Member Functions | Friends | List of all members
Pscf::Mesh< D > Class Template Reference

Description of a regular grid of points in a periodic domain. More...

#include <Mesh.h>

Public Member Functions

 Mesh ()
 Default constructor. More...
 
 Mesh (Mesh< D > const &other)
 Copy constructor. More...
 
 Mesh (IntVec< D > const &dimensions)
 Constructor from grid dimensions. More...
 
Mesh< D > & operator= (Mesh< D > const &other)
 Assignment operator. More...
 
void setDimensions (IntVec< D > const &dimensions)
 Set the grid dimensions for an existing mesh. More...
 
IntVec< D > dimensions () const
 Get an IntVec<D> of the grid dimensions. More...
 
int dimension (int i) const
 Get grid dimension along Cartesian direction i. More...
 
int size () const
 Get total number of grid points. More...
 
IntVec< D > position (int rank) const
 Get the position IntVec<D> of a grid point with a specified rank. More...
 
int rank (IntVec< D > const &position) const
 Get the rank of a grid point with specified position. More...
 
bool isInMesh (int coordinate, int i) const
 Is this coordinate in range? More...
 
bool isInMesh (IntVec< D > const &position) const
 Is this IntVec<D> grid position within the grid? More...
 
int shift (int &coordinate, int i) const
 Shift a periodic coordinate into range. More...
 
IntVec< D > shift (IntVec< D > &position) const
 Shift a periodic position into primary grid. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize to/from an archive. More...
 

Friends

std::istream & operator>> (std::istream &, Mesh< D > &)
 Input stream extractor for reading a Mesh<D> object. More...
 
std::ostream & operator<< (std::ostream &, Mesh< D > const &)
 Output stream inserter for writing a Mesh<D> object. More...
 

Detailed Description

template<int D>
class Pscf::Mesh< D >

Description of a regular grid of points in a periodic domain.

The coordinates of a point on a grid form an IntVec<D>, referred to here as a grid position. Each element of a grid position must lie in the range 0 <= position[i] < dimension(i), where i indexes a Cartesian axis, and dimension(i) is the dimension of the grid along axis i.

Each grid position is also assigned a non-negative integer rank. Mesh position ranks are ordered sequentially like elements in a multi-dimensional C array, with the last coordinate being the most rapidly varying.

Definition at line 60 of file Mesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/3]

template<int D>
Pscf::Mesh< D >::Mesh

Default constructor.

Grid dimensions and size are initialized to zero. All functions that set the dimensions and size after construction require that all dimensions are positive, yielding a positive size.

Definition at line 21 of file Mesh.tpp.

◆ Mesh() [2/3]

template<int D>
Pscf::Mesh< D >::Mesh ( Mesh< D > const &  other)

Copy constructor.

Parameters
otherMesh<D> object being copied.

Definition at line 29 of file Mesh.tpp.

◆ Mesh() [3/3]

template<int D>
Pscf::Mesh< D >::Mesh ( IntVec< D > const &  dimensions)

Constructor from grid dimensions.

Parameters
dimensionsIntVec<D> of grid dimensions

Definition at line 37 of file Mesh.tpp.

References Pscf::Mesh< D >::dimensions(), and Pscf::Mesh< D >::setDimensions().

Member Function Documentation

◆ operator=()

template<int D>
Mesh< D > & Pscf::Mesh< D >::operator= ( Mesh< D > const &  other)

Assignment operator.

Parameters
otherMesh<D> object being copied.

Definition at line 45 of file Mesh.tpp.

◆ setDimensions()

template<int D>
void Pscf::Mesh< D >::setDimensions ( IntVec< D > const &  dimensions)

Set the grid dimensions for an existing mesh.

Parameters
dimensionsIntVec<D> of grid dimensions.

Definition at line 53 of file Mesh.tpp.

References UTIL_THROW.

Referenced by Pscf::Mesh< D >::Mesh().

◆ dimensions()

template<int D>
IntVec< D > Pscf::Mesh< D >::dimensions
inline

◆ dimension()

template<int D>
int Pscf::Mesh< D >::dimension ( int  i) const
inline

Get grid dimension along Cartesian direction i.

Parameters
iindex of Cartesian direction 0 <=i < Util::Dimension

Definition at line 221 of file Mesh.h.

References Util::Dimension.

Referenced by Pscf::Pspg::WaveList< D >::allocate(), and Pscf::Pspg::WaveList< D >::computeMinimumImages().

◆ size()

template<int D>
int Pscf::Mesh< D >::size
inline

◆ position()

template<int D>
IntVec< D > Pscf::Mesh< D >::position ( int  rank) const

Get the position IntVec<D> of a grid point with a specified rank.

Parameters
rankinteger rank of a grid point.
Returns
IntVec<D> containing coordinates of specified point.

Definition at line 89 of file Mesh.tpp.

◆ rank()

template<int D>
int Pscf::Mesh< D >::rank ( IntVec< D > const &  position) const

Get the rank of a grid point with specified position.

Parameters
positioninteger position of a grid point
Returns
integer rank of specified grid point

Definition at line 72 of file Mesh.tpp.

Referenced by Pscf::Pspg::WaveList< D >::computeMinimumImages(), Pscf::Pspg::FieldIo< D >::convertBasisToKGrid(), Pscf::Pspc::FieldIo< D >::convertBasisToKGrid(), Pscf::Pspg::FieldIo< D >::convertKGridToBasis(), Pscf::Pspc::FieldIo< D >::convertKGridToBasis(), and Pscf::Pspc::FieldIo< D >::hasSymmetry().

◆ isInMesh() [1/2]

template<int D>
bool Pscf::Mesh< D >::isInMesh ( int  coordinate,
int  i 
) const

Is this coordinate in range?

Parameters
coordinatecoordinate value for direction i
iindex for Cartesian direction
Returns
true iff 0 <= coordinate < dimension(i).

Definition at line 105 of file Mesh.tpp.

◆ isInMesh() [2/2]

template<int D>
bool Pscf::Mesh< D >::isInMesh ( IntVec< D > const &  position) const

Is this IntVec<D> grid position within the grid?

Returns true iff 0 <= coordinate[i] < dimension(i) for all i.

Parameters
positiongrid point position
Returns
true iff 0 <= coordinate[i] < dimension(i) for all i.

Definition at line 117 of file Mesh.tpp.

◆ shift() [1/2]

template<int D>
int Pscf::Mesh< D >::shift ( int &  coordinate,
int  i 
) const

Shift a periodic coordinate into range.

Upon return, the coordinate will be shifted to lie within the range 0 <= coordinate < dimension(i) by subtracting an integer multiple of dimension(i), giving coordinate - shift*dimension(i). The return value is the required integer ‘shift’.

Parameters
coordinatecoordinate in Cartesian direction i.
iindex of Cartesian direction, i >= 0.
Returns
multiple of dimension(i) subtracted from input value.

Definition at line 131 of file Mesh.tpp.

Referenced by Pscf::Pspg::WaveList< D >::computeMinimumImages().

◆ shift() [2/2]

template<int D>
IntVec< D > Pscf::Mesh< D >::shift ( IntVec< D > &  position) const

Shift a periodic position into primary grid.

Upon return, each element of the parameter position is shifted to lie within the range 0 <= position[i] < dimension(i) by adding or subtracting an integer multiple of dimension(i). The IntVec<D> of shift values is returned.

Parameters
positionIntVec<D> position within a grid.
Returns
IntVec<D> of integer shifts.

Definition at line 145 of file Mesh.tpp.

◆ serialize()

template<int D>
template<class Archive >
void Pscf::Mesh< D >::serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize to/from an archive.

Parameters
ararchive
versionarchive version id

Definition at line 237 of file Mesh.h.

Friends And Related Function Documentation

◆ operator>>

template<int D>
std::istream & operator>> ( std::istream &  in,
Mesh< D > &  mesh 
)
friend

Input stream extractor for reading a Mesh<D> object.

Parameters
ininput stream
meshMesh<D> object to be read
Returns
modified input stream

Definition at line 245 of file Mesh.h.

◆ operator<<

template<int D>
std::ostream & operator<< ( std::ostream &  out,
Mesh< D > const &  mesh 
)
friend

Output stream inserter for writing a Mesh<D> object.

Parameters
outoutput stream
meshMesh<D> to be written
Returns
modified output stream

Definition at line 257 of file Mesh.h.


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