PSCF v1.1
|
Multi-dimensional array with the dimensionality of space. More...
#include <GridArray.h>
Public Member Functions | |
GridArray () | |
Constructor. More... | |
GridArray (GridArray< Data > const &other) | |
Copy constructor. More... | |
~GridArray () | |
Destructor. More... | |
GridArray< Data > & | operator= (GridArray< Data > const &other) |
Assignment. More... | |
void | allocate (IntVector const &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... | |
IntVector const & | 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 (IntVector const &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... | |
Data const & | 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... | |
Data const & | operator() (IntVector const &position) const |
Return element by const reference, indexed by IntVector position. More... | |
Data & | operator() (IntVector const &position) |
Return element by reference, indexed by IntVector position. More... | |
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.
|
inline |
Util::GridArray< Data >::GridArray | ( | GridArray< Data > const & | 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= | ( | GridArray< Data > const & | other | ) |
void Util::GridArray< Data >::allocate | ( | IntVector const & | dimensions | ) |
Allocate memory for a matrix.
dimensions | IntVector containing dimensions |
Definition at line 313 of file GridArray.h.
References Util::Dimension, and UTIL_THROW.
Referenced by Util::GridArray< Data >::GridArray().
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 337 of file GridArray.h.
|
inline |
Return true if the GridArray has been allocated, false otherwise.
Definition at line 519 of file GridArray.h.
Referenced by Util::GridArray< Data >::GridArray().
|
inline |
Get all dimensions of array as an IntVector.
Definition at line 358 of file GridArray.h.
|
inline |
Get number of grid points along direction i.
i | index of Cartesian direction 0 <=i < 3. |
Definition at line 365 of file GridArray.h.
|
inline |
Get total number of grid points.
Definition at line 372 of file GridArray.h.
Referenced by pscfpp.file.File::__eq__(), pscfpp.text.Record::__init__(), pscfpp.file.File::__init__(), pscfpp.file.File::__repr__(), and pscfpp.text.Record::__str__().
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 405 of file GridArray.h.
References Util::Dimension.
|
inline |
Get the rank of a grid point with specified position.
position | integer position of a grid point |
Definition at line 395 of file GridArray.h.
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 423 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 437 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 453 of file GridArray.h.
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 469 of file GridArray.h.
References Util::Dimension.
|
inline |
Return element by const reference, indexed by 1D rank.
rank | 1D array index of element |
Definition at line 482 of file GridArray.h.
|
inline |
Return element by reference, indexed by 1D rank.
rank | 1D rank of element |
Definition at line 489 of file GridArray.h.
|
inline |
Return element by const reference, indexed by IntVector position.
position | IntVector of coordinates. |
Definition at line 497 of file GridArray.h.
|
inline |
Return element by reference, indexed by IntVector position.
position | IntVector of coordinates. |
Definition at line 505 of file GridArray.h.