30 : dimensions_(other.dimensions_),
31 offsets_(other.offsets_),
47 setDimensions(other.dimensions_);
56 for (i = 0; i < D; ++i) {
57 if (dimensions[i] <= 0) {
58 UTIL_THROW(
"Mesh dimensions must be positive");
62 dimensions_ = dimensions;
64 for (i = D - 1; i > 0; --i) {
65 offsets_[i-1] = offsets_[i]*dimensions_[i];
67 size_ = offsets_[0]*dimensions_[0];
76 for (i = 0; i < D - 1; ++i) {
77 assert(position[i] >= 0);
78 assert(position[i] < dimensions_[i]);
79 result += position[i]*offsets_[i];
81 assert(position[i] >= 0);
82 assert(position[i] < dimensions_[i]);
83 result += position[i];
95 for (i = 0; i < D - 1; ++i) {
96 position[i] = remainder/offsets_[i];
97 remainder -= position[i]*offsets_[i];
99 position[i] = remainder;
110 if (coordinate >= dimensions_[i])
120 for (
int i = 0; i < D; ++i) {
123 if (position[i] >= dimensions_[i])
134 if (coordinate >= 0) {
135 shift = coordinate/dimensions_[i];
137 shift = -1 + ((coordinate+1)/dimensions_[i]);
139 coordinate -= shift*dimensions_[i];
148 for (
int i = 0; i < D; ++i) {
149 shifts[i] = shift(position[i], i);
An IntVec<D, T> is a D-component vector of elements of integer type T.
Description of a regular grid of points in a periodic domain.
IntVec< D > dimensions() const
Get an IntVec<D> of the grid dimensions.
Mesh< D > & operator=(Mesh< D > const &other)
Assignment operator.
int rank(IntVec< D > const &position) const
Get the rank of a grid point with specified position.
bool isInMesh(int coordinate, int i) const
Is this coordinate in range?
IntVec< D > position(int rank) const
Get the position IntVec<D> of a grid point with a specified rank.
int shift(int &coordinate, int i) const
Shift a periodic coordinate into range.
void setDimensions(IntVec< D > const &dimensions)
Set the grid dimensions for an existing mesh.
Mesh()
Default constructor.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.