37 UTIL_THROW(
"Grid dimensions must be positive");
44 offsets_[i-1] = offsets_[i]*dimensions_[i];
46 size_ = offsets_[0]*dimensions_[0];
55 assert(
position[i] < dimensions_[i]);
59 assert(
position[i] < dimensions_[i]);
72 remainder -=
position[i]*offsets_[i];
83 if (coordinate >= dimensions_[i])
103 if (coordinate >= 0) {
104 shift = coordinate/dimensions_[i];
106 shift = -1 + ((coordinate+1)/dimensions_[i]);
108 coordinate -=
shift*dimensions_[i];
IntVector position(int rank) const
Get the position IntVector of a grid point with a specified rank.
int rank(const IntVector &position) const
Get the rank of a grid point with specified position.
IntVector dimensions() const
Get an IntVector of the grid dimensions.
void setDimensions(const IntVector &dimensions)
Set the grid dimensions in all directions.
bool isInGrid(int coordinate, int i) const
Is this coordinate in range?
int shift(int &coordinate, int i) const
Shift a periodic coordinate into range.
Grid()
Default constructor.
An IntVector is an integer Cartesian vector.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
const int Dimension
Dimensionality of space.
Utility classes for scientific computation.