PSCF v1.3
|
Description of a regular grid of points in a periodic domain. More...
#include <Mesh.h>
Public Member Functions | |
Mesh () | |
Default constructor. | |
Mesh (Mesh< D > const &other) | |
Copy constructor. | |
Mesh (IntVec< D > const &dimensions) | |
Constructor from grid dimensions. | |
Mesh< D > & | operator= (Mesh< D > const &other) |
Assignment operator. | |
void | setDimensions (IntVec< D > const &dimensions) |
Set the grid dimensions for an existing mesh. | |
IntVec< D > | dimensions () const |
Get an IntVec<D> of the grid dimensions. | |
int | dimension (int i) const |
Get grid dimension along Cartesian direction i. | |
int | size () const |
Get total number of grid points. | |
IntVec< D > | position (int rank) const |
Get the position IntVec<D> of a grid point with a specified rank. | |
int | rank (IntVec< D > const &position) const |
Get the rank of a grid point with specified position. | |
bool | isInMesh (int coordinate, int i) const |
Is this coordinate in range? | |
bool | isInMesh (IntVec< D > const &position) const |
Is this IntVec<D> grid position within the grid? | |
int | shift (int &coordinate, int i) const |
Shift a periodic coordinate into range. | |
IntVec< D > | shift (IntVec< D > &position) const |
Shift a periodic position into primary grid. | |
template<class Archive> | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize to/from an archive. |
Friends | |
std::istream & | operator>> (std::istream &in, Mesh< D > &mesh) |
Input stream extractor for reading a Mesh<D> object. | |
std::ostream & | operator<< (std::ostream &out, Mesh< D > const &mesh) |
Output stream inserter for writing a Mesh<D> object. |
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.
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.
Referenced by Mesh(), operator<<, operator=(), and operator>>.
Pscf::Mesh< D >::Mesh | ( | Mesh< D > const & | other | ) |
Pscf::Mesh< D >::Mesh | ( | IntVec< D > const & | dimensions | ) |
Constructor from grid dimensions.
dimensions | IntVec<D> of grid dimensions |
Definition at line 37 of file Mesh.tpp.
References dimensions(), and setDimensions().
Mesh< D > & Pscf::Mesh< D >::operator= | ( | Mesh< D > const & | other | ) |
Assignment operator.
other | Mesh<D> object being copied. |
Definition at line 45 of file Mesh.tpp.
References Mesh(), and setDimensions().
void Pscf::Mesh< D >::setDimensions | ( | IntVec< D > const & | dimensions | ) |
Set the grid dimensions for an existing mesh.
dimensions | IntVec<D> of grid dimensions. |
Definition at line 53 of file Mesh.tpp.
References dimensions(), and UTIL_THROW.
Referenced by Mesh(), operator=(), and operator>>.
|
inline |
Get an IntVec<D> of the grid dimensions.
Definition at line 217 of file Mesh.h.
Referenced by Pscf::Rpc::Propagator< D >::allocate(), Mesh(), operator>>, Pscf::Prdc::MaskReal< D, RFT, FIT >::readBasis(), Pscf::Prdc::readBasisData(), Pscf::Prdc::MaskReal< D, RFT, FIT >::readRGrid(), Pscf::Prdc::WFieldsReal< D, RFT, FIT >::readRGrid(), Pscf::Prdc::MaskReal< D, RFT, FIT >::setBasis(), setDimensions(), Pscf::Prdc::MaskReal< D, RFT, FIT >::setRGrid(), Pscf::Prdc::WFieldsReal< D, Prdc::Cpu::RField< D >, Rpc::FieldIo< D > >::setRGrid(), and Pscf::Rpc::FilmFieldGenMask< D >::stress().
|
inline |
Get grid dimension along Cartesian direction i.
i | index of Cartesian direction 0 <=i < Util::Dimension |
Definition at line 221 of file Mesh.h.
References Util::Dimension.
|
inline |
Get total number of grid points.
Value size() == 0 will be obtained iff the mesh was default constructed and has not yet been given meaningful initial values.
Definition at line 229 of file Mesh.h.
Referenced by Pscf::Prdc::Cpu::WaveList< D >::allocate(), Pscf::Rpg::Propagator< D >::allocate(), Pscf::Rpg::Solvent< D >::associate(), Pscf::Prdc::MaskReal< D, RFT, FIT >::readBasis(), Pscf::Prdc::MaskReal< D, RFT, FIT >::readRGrid(), Pscf::Prdc::MaskReal< D, RFT, FIT >::setBasis(), Pscf::Prdc::WFieldsReal< D, RFT, FIT >::setBasis(), Pscf::Prdc::WFieldsReal< D, Prdc::Cpu::RField< D >, Rpc::FieldIo< D > >::setRGrid(), and Pscf::Rpc::FilmFieldGenMask< D >::stress().
IntVec< D > Pscf::Mesh< D >::position | ( | int | rank | ) | const |
Get the position IntVec<D> of a grid point with a specified rank.
rank | integer rank of a grid point. |
Definition at line 89 of file Mesh.tpp.
References position().
Referenced by isInMesh(), position(), rank(), and shift().
int Pscf::Mesh< D >::rank | ( | IntVec< D > const & | position | ) | const |
Get the rank of a grid point with specified position.
position | integer position of a grid point |
Definition at line 72 of file Mesh.tpp.
References position().
bool Pscf::Mesh< D >::isInMesh | ( | int | coordinate, |
int | i ) const |
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.
position | grid point position |
Definition at line 117 of file Mesh.tpp.
References position().
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’.
coordinate | coordinate in Cartesian direction i. |
i | index of Cartesian direction, i >= 0. |
Definition at line 131 of file Mesh.tpp.
References shift().
Referenced by Pscf::Prdc::readBasisData(), shift(), and shift().
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.
position | IntVec<D> position within a grid. |
Definition at line 145 of file Mesh.tpp.
References position(), and shift().
void Pscf::Mesh< D >::serialize | ( | Archive & | ar, |
const unsigned int | version ) |
|
friend |
Input stream extractor for reading a Mesh<D> object.
in | input stream |
mesh | Mesh<D> object to be read |
Definition at line 245 of file Mesh.h.
References dimensions(), Mesh(), setDimensions(), and UTIL_CHECK.
|
friend |