Simpatico
v1.10
|
Multi-dimensional array with the dimensionality of space.
The memory for a GridArray is stored in a single one-dimensional C array. The subscript [] operator is overloaded to return an element indexed by a one-dimensional rank, and the () operator is overloaded to return an element indexed by an IntVector of grid coordinates.
Definition at line 28 of file GridArray.h.
#include <GridArray.h>
Public Member Functions | |
GridArray () | |
Constructor. More... | |
GridArray (const GridArray< Data > &other) | |
Copy constructor. More... | |
~GridArray () | |
Destructor. More... | |
GridArray< Data > & | operator= (const GridArray< Data > &other) |
Assignment. More... | |
void | allocate (const IntVector &dimensions) |
Allocate memory for a matrix. More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize a GridArray to/from an Archive. More... | |
bool | isAllocated () const |
Return true if the GridArray has been allocated, false otherwise. More... | |
const IntVector & | dimensions () |
Get all dimensions of array as an IntVector. More... | |
int | dimension (int i) const |
Get number of grid points along 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 1D coordinate in range? More... | |
bool | isInGrid (IntVector &position) const |
Is this position within the grid? More... | |
int | shift (int &coordinate, int i) const |
Shift a periodic 1D coordinate into primary range. More... | |
IntVector | shift (IntVector &position) const |
Shift a periodic position into primary grid. More... | |
const Data & | operator[] (int rank) const |
Return element by const reference, indexed by 1D rank. More... | |
Data & | operator[] (int rank) |
Return element by reference, indexed by 1D rank. More... | |
const Data & | operator() (const IntVector &position) const |
Return element by const reference, indexed by IntVector position. More... | |
Data & | operator() (const IntVector &position) |
Return element by reference, indexed by IntVector position. More... | |
|
inline |
Util::GridArray< Data >::GridArray | ( | const GridArray< Data > & | other | ) |
Copy constructor.
Definition at line 242 of file GridArray.h.
References Util::GridArray< Data >::allocate(), Util::GridArray< Data >::isAllocated(), and UTIL_THROW.
Util::GridArray< Data >::~GridArray | ( | ) |
Destructor.
Delete dynamically allocated C array, if allocated.
Definition at line 230 of file GridArray.h.
GridArray< Data > & Util::GridArray< Data >::operator= | ( | const GridArray< Data > & | other | ) |
Assignment.
Definition at line 272 of file GridArray.h.
References Util::GridArray< Data >::allocate(), Util::GridArray< Data >::isAllocated(), and UTIL_THROW.
void Util::GridArray< Data >::allocate | ( | const IntVector & | dimensions | ) |
Allocate memory for a matrix.
dimensions | IntVector containing dimensions |
Definition at line 312 of file GridArray.h.
References Util::Dimension, Util::GridArray< Data >::dimensions(), Util::GridArray< Data >::isAllocated(), and UTIL_THROW.
Referenced by Util::GridArray< Data >::GridArray(), McMd::MdSpmePotential::makeWaves(), Util::GridArray< Data >::operator=(), and Util::GridArray< Data >::serialize().
void Util::GridArray< Data >::serialize | ( | Archive & | ar, |
const unsigned int | version | ||
) |
Serialize a GridArray to/from an Archive.
ar | archive |
version | archive version id |
Definition at line 336 of file GridArray.h.
References Util::GridArray< Data >::allocate(), Util::GridArray< Data >::dimensions(), and Util::GridArray< Data >::isAllocated().
|
inline |
Return true if the GridArray has been allocated, false otherwise.
Definition at line 517 of file GridArray.h.
Referenced by Util::GridArray< Data >::allocate(), Util::GridArray< Data >::GridArray(), Util::GridArray< Data >::operator=(), and Util::GridArray< Data >::serialize().
|
inline |
Get all dimensions of array as an IntVector.
Definition at line 357 of file GridArray.h.
Referenced by Util::GridArray< Data >::allocate(), and Util::GridArray< Data >::serialize().
|
inline |
Get number of grid points along direction i.
i | index of Cartesian direction 0 <=i < 3. |
Definition at line 364 of file GridArray.h.
Referenced by McMd::MdSpmePotential::makeWaves().
|
inline |
Get total number of grid points.
Definition at line 371 of file GridArray.h.
References Util::Dimension, Util::GridArray< Data >::position(), and Util::GridArray< Data >::rank().
Referenced by McMd::MdSpmePotential::addForces(), McMd::MdSpmePotential::computeEnergy(), McMd::MdSpmePotential::computeStress(), and McMd::MdSpmePotential::makeWaves().
IntVector Util::GridArray< Data >::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 404 of file GridArray.h.
References Util::Dimension, and Util::GridArray< Data >::rank().
Referenced by Util::GridArray< Data >::size().
|
inline |
Get the rank of a grid point with specified position.
position | integer position of a grid point |
Definition at line 394 of file GridArray.h.
Referenced by Util::GridArray< Data >::operator()(), Util::GridArray< Data >::operator[](), Util::GridArray< Data >::position(), and Util::GridArray< Data >::size().
bool Util::GridArray< Data >::isInGrid | ( | int | coordinate, |
int | i | ||
) | const |
Is this 1D coordinate in range?
Returns true iff 0 <= coordinate < dimension(i).
coordinate | coordinate value for direction i |
i | index for Cartesian direction |
Definition at line 422 of file GridArray.h.
bool Util::GridArray< Data >::isInGrid | ( | IntVector & | position | ) | const |
Is this position within the grid?
Returns true iff 0 <= coordinate[i] < dimension(i) for all i.
position | grid point position |
Definition at line 436 of file GridArray.h.
References Util::Dimension.
int Util::GridArray< Data >::shift | ( | int & | coordinate, |
int | i | ||
) | const |
Shift a periodic 1D coordinate into primary 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 452 of file GridArray.h.
Referenced by Util::GridArray< Data >::shift().
IntVector Util::GridArray< Data >::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.
position | IntVector position within a grid. |
Definition at line 468 of file GridArray.h.
References Util::Dimension, and Util::GridArray< Data >::shift().
|
inline |
Return element by const reference, indexed by 1D rank.
rank | 1D array index of element |
Definition at line 481 of file GridArray.h.
References Util::GridArray< Data >::rank().
|
inline |
Return element by reference, indexed by 1D rank.
rank | 1D rank of element |
Definition at line 488 of file GridArray.h.
References Util::GridArray< Data >::rank().
|
inline |
Return element by const reference, indexed by IntVector position.
position | IntVector of coordinates. |
Definition at line 496 of file GridArray.h.
References Util::GridArray< Data >::rank().
|
inline |
Return element by reference, indexed by IntVector position.
position | IntVector of coordinates. |
Definition at line 503 of file GridArray.h.
References Util::GridArray< Data >::rank().