Simpatico
v1.10
|
A grid of points indexed by integer coordinates.
The coordinates of a point on a grid form an IntVector, 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. Grid position ranks are ordered sequentially like elements in a multi-dimensional C array, with the last coordinate being the most rapidly varying.
#include <Grid.h>
Public Member Functions | |
Grid () | |
Default constructor. More... | |
Grid (const IntVector &dimensions) | |
Constructor. More... | |
void | setDimensions (const IntVector &dimensions) |
Set the grid dimensions in all directions. More... | |
IntVector | dimensions () const |
Get an IntVector 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... | |
IntVector | position (int rank) const |
Get the position IntVector of a grid point with a specified rank. More... | |
int | rank (const IntVector &position) const |
Get the rank of a grid point with specified position. More... | |
bool | isInGrid (int coordinate, int i) const |
Is this coordinate in range? More... | |
bool | isInGrid (IntVector &position) const |
Is this IntVector grid position within the grid? More... | |
int | shift (int &coordinate, int i) const |
Shift a periodic coordinate into range. More... | |
IntVector | shift (IntVector &position) const |
Shift a periodic position into primary grid. More... | |
Util::Grid::Grid | ( | ) |
Default constructor.
Definition at line 15 of file Grid.cpp.
References dimensions(), and setDimensions().
Util::Grid::Grid | ( | const IntVector & | dimensions | ) |
Constructor.
dimensions | IntVector of grid dimensions |
Definition at line 24 of file Grid.cpp.
References setDimensions().
void Util::Grid::setDimensions | ( | const IntVector & | dimensions | ) |
Set the grid dimensions in all directions.
dimensions | IntVector of grid dimensions. |
Definition at line 32 of file Grid.cpp.
References Util::Dimension, dimensions(), and UTIL_THROW.
Referenced by Tools::CellList::allocate(), DdMd::CellList::allocate(), Grid(), and DdMd::Domain::save().
|
inline |
Get an IntVector of the grid dimensions.
Definition at line 156 of file Grid.h.
Referenced by Grid(), and setDimensions().
|
inline |
Get grid dimension along Cartesian direction i.
i | index of Cartesian direction 0 <=i < Util::Dimension |
Definition at line 159 of file Grid.h.
References Util::Dimension.
Referenced by Tools::CellList::allocate(), DdMd::CellList::allocate(), DdMd::Exchanger::exchange(), and DdMd::CellList::makeGrid().
|
inline |
Get total number of grid points.
Definition at line 166 of file Grid.h.
Referenced by DdMd::AtomDistributor::addAtom(), Tools::CellList::allocate(), DdMd::CellList::allocate(), Tools::CellList::build(), DdMd::CellList::build(), Tools::CellList::clear(), DdMd::CellList::clear(), Tools::CellList::isValid(), DdMd::CellList::isValid(), Tools::CellList::makeGrid(), DdMd::AtomCollector::nextPtr(), DdMd::GroupCollector< N >::nextPtr(), DdMd::AtomDistributor::readParameters(), DdMd::AtomDistributor::send(), and DdMd::AtomDistributor::setup().
IntVector Util::Grid::position | ( | int | rank | ) | const |
Get the position IntVector of a grid point with a specified rank.
rank | integer rank of a grid point. |
Definition at line 64 of file Grid.cpp.
References Util::Dimension.
Referenced by DdMd::Domain::save().
int Util::Grid::rank | ( | const IntVector & | position | ) | const |
Get the rank of a grid point with specified position.
position | integer position of a grid point |
Definition at line 49 of file Grid.cpp.
References Util::Dimension.
Referenced by Tools::CellList::allocate(), DdMd::CellList::allocate(), DdMd::Domain::ownerRank(), and DdMd::Domain::save().
bool Util::Grid::isInGrid | ( | int | coordinate, |
int | i | ||
) | const |
Is this coordinate in range?
coordinate | coordinate value for direction i |
i | index for Cartesian direction |
Definition at line 78 of file Grid.cpp.
Referenced by DdMd::Domain::save().
bool Util::Grid::isInGrid | ( | IntVector & | position | ) | const |
Is this IntVector grid position within the grid?
Returns true iff 0 <= coordinate[i] < dimension(i) for all i.
position | grid point position |
Definition at line 88 of file Grid.cpp.
References Util::Dimension.
int Util::Grid::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 100 of file Grid.cpp.
Referenced by DdMd::Domain::save(), and shift().
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 IntVector of shift values is returned.
position | IntVector position within a grid. |
Definition at line 112 of file Grid.cpp.
References Util::Dimension, and shift().