Simpatico  v1.10
List of all members | Public Member Functions
Util::Grid Class Reference

Detailed Description

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.

Definition at line 33 of file Grid.h.

#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...
 

Constructor & Destructor Documentation

Util::Grid::Grid ( )

Default constructor.

Definition at line 15 of file Grid.cpp.

References dimensions(), and setDimensions().

Util::Grid::Grid ( const IntVector dimensions)

Constructor.

Parameters
dimensionsIntVector of grid dimensions

Definition at line 24 of file Grid.cpp.

References setDimensions().

Member Function Documentation

void Util::Grid::setDimensions ( const IntVector dimensions)

Set the grid dimensions in all directions.

Parameters
dimensionsIntVector 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().

IntVector Util::Grid::dimensions ( ) const
inline

Get an IntVector of the grid dimensions.

Definition at line 156 of file Grid.h.

Referenced by Grid(), and setDimensions().

int Util::Grid::dimension ( int  i) const
inline

Get grid dimension along Cartesian direction i.

Parameters
iindex 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().

int Util::Grid::size ( ) const
inline
IntVector Util::Grid::position ( int  rank) const

Get the position IntVector of a grid point with a specified rank.

Parameters
rankinteger rank of a grid point.
Returns
IntVector containing coordinates of specified 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.

Parameters
positioninteger position of a grid point
Returns
integer rank of specified 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?

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

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.

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

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'.

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

Definition at line 100 of file Grid.cpp.

Referenced by DdMd::Domain::save(), and shift().

IntVector Util::Grid::shift ( IntVector 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 IntVector of shift values is returned.

Parameters
positionIntVector position within a grid.
Returns
IntVector of integer shifts.

Definition at line 112 of file Grid.cpp.

References Util::Dimension, and shift().


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