|
OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
|
NDGrid holds grid information for a rectilinear grid in some arbitrary dimensional space. More...
#include <NDGrid.h>


Public Member Functions | |
| NDGrid * | clone () |
| Inheritable copy constructor. More... | |
| Mesh * | dual () const |
| Not implemented. More... | |
| NDGrid () | |
| Build a default, empty grid with zero dimension. More... | |
| NDGrid (int nDimensions, int *size, double *spacing, double *min) | |
| Build a regular grid. More... | |
| NDGrid (std::vector< int > size, std::vector< const double * > gridCoordinates) | |
| Build an irregular grid. More... | |
| NDGrid (std::vector< std::vector< double > > gridCoordinates) | |
| Build an irregular grid. More... | |
| NDGrid (const NDGrid &grid) | |
| Copy constructor. More... | |
| ~NDGrid () | |
| Destructor. More... | |
| double & | coord (const int &index, const int &dimension) |
| Get the coordinate of a set of grid points. More... | |
| const double & | coord (const int &index, const int &dimension) const |
| Get the coordinate of a set of grid points. More... | |
| int | size (const int &dimension) const |
| Get the size of the grid along a given dimension. More... | |
| std::vector< double > | coordVector (const int &dimension) const |
| Get the vector of grid points along a particular dimension. More... | |
| double * | newCoordArray (const int &dimension) const |
| Get an array of grid points along a particular dimension. More... | |
| void | coordLowerBound (const double &x, const int &dimension, int &xIndex) const |
| Get the grid point of the grid lower bound in a particular dimension. More... | |
| void | lowerBound (const std::vector< double > &pos, std::vector< int > &xIndex) const |
| Get the grid point of the grid lower bound. More... | |
| double | min (const int &dimension) const |
| Return the lowest grid coordinate in the given dimension. More... | |
| double | max (const int &dimension) const |
| Return the highest grid coordinate in the given dimension. More... | |
| void | setCoord (int dimension, int nCoords, double *x) |
| Reset the coordinates in the dimension to a new value. More... | |
| Mesh::Iterator | begin () const |
| Returns the origin of the mesh (lowest possible index in all dimensions) More... | |
| Mesh::Iterator | end () const |
| Returns the end of the mesh (highest possible index in all dimensions) More... | |
| void | getPosition (const Mesh::Iterator &it, double *position) const |
| Get the position of the iterator. More... | |
| int | getPositionDimension () const |
| Get the dimension of the Mesh. More... | |
| bool | getConstantSpacing () const |
| Returns true if the Mesh is a regular grid. More... | |
| void | setConstantSpacing (bool spacing) |
| Set to true to flag the Mesh as a regular grid. More... | |
| void | setConstantSpacing (double tolerance_m=1e-9) |
| Automatically detector whether the Mesh is a regular grid. More... | |
| int | toInteger (const Mesh::Iterator &lhs) const |
| Return an integer corresponding to the iterator position. More... | |
| Mesh::Iterator | getNearest (const double *position) const |
| Return an iterator corresponding to nearest mesh point to position. More... | |
Protected Member Functions | |
| virtual Mesh::Iterator & | addEquals (Mesh::Iterator &lhs, int difference) const |
| Add difference to lhs and then return lhs. More... | |
| virtual Mesh::Iterator & | subEquals (Mesh::Iterator &lhs, int difference) const |
| Subtract difference from lhs and then return lhs. More... | |
| virtual Mesh::Iterator & | addEquals (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
| Add difference to lhs and then return lhs. More... | |
| virtual Mesh::Iterator & | subEquals (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
| Subtract difference from lhs and then return lhs. More... | |
| virtual Mesh::Iterator & | addOne (Mesh::Iterator &lhs) const |
| Increment position of lhs by one and then return lhs. More... | |
| virtual Mesh::Iterator & | subOne (Mesh::Iterator &lhs) const |
| Decrement position of lhs by one and then return lhs. More... | |
| virtual bool | isGreater (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
| Return true if rhs is greater than lhs. More... | |
Private Attributes | |
| std::vector< std::vector< double > > | coord_m |
| std::vector< VectorMap * > | maps_m |
| bool | constantSpacing_m |
Friends | |
| Mesh::Iterator | operator++ (Mesh::Iterator &lhs, int) |
| Postfix increment operator it++ advances iterator by one. More... | |
| Mesh::Iterator | operator-- (Mesh::Iterator &lhs, int) |
| Postfix decrement operator it– retreats iterator by one. More... | |
| Mesh::Iterator & | operator++ (Mesh::Iterator &lhs) |
| Prefix increment operator ++it. More... | |
| Mesh::Iterator & | operator-- (Mesh::Iterator &lhs) |
| Prefix decrement operator –it retreats iterator by one More... | |
| Mesh::Iterator | operator- (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Subtraction operator - subtracts offset of rhs relative to Begin() from lhs. More... | |
| Mesh::Iterator | operator+ (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Addition operator - adds offset of rhs of rhs relative to Begin() to lhs. More... | |
| Mesh::Iterator & | operator-= (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Subtraction operator - subtracts offset of rhs relative to Begin() from lhs and returns lhs. More... | |
| Mesh::Iterator & | operator+= (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Addition operator - adds offset of rhs of rhs relative to Begin() to lhs and returns lhs. More... | |
| bool | operator== (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs indexes the same position as rhs. More... | |
| bool | operator!= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs does not index the same position as rhs. More... | |
| bool | operator>= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs indexes a position greater than or equal to rhs i.e. More... | |
| bool | operator<= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs indexes a position less than or equal to rhs i.e. More... | |
| bool | operator< (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs indexes a position less than rhs i.e. More... | |
| bool | operator> (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
| Return true if lhs indexes a position greater than rhs i.e. More... | |
NDGrid holds grid information for a rectilinear grid in some arbitrary dimensional space.
NDGrid holds the necessary information for regular and irregular grid data for interpolation routines (but it all has to be rectilinear).
Where an irregular grid is used, we use std::lower_bound to find mapping from a generic point to the grid points.
NDGrid holds a list of pointers to VectorMaps that use the grid for interpolation and functions to Add and Remove VectorMaps. If the Remove function removes the last VectorMap, then the ThreeDGrid is deleted. It's a sort of smart pointer.
In general NDGrid is not bound checked.
| interpolation::NDGrid::NDGrid | ( | ) |
Build a default, empty grid with zero dimension.
////// NDGrid ///////
Definition at line 36 of file NDGrid.cpp.
| interpolation::NDGrid::NDGrid | ( | int | nDimensions, |
| int * | size, | ||
| double * | spacing, | ||
| double * | min | ||
| ) |
Build a regular grid.
| nDimensions | number of dimensions of the grid |
| size | array of ints of length nDimensions. Gives the number of grid points in each dimension. Caller owns the memory pointed to by size. Must be at least 1 grid point in each dimension. |
| spacing | array of doubles of length nDimensions. Gives the grid spacing in each dimension. Caller owns memory pointed to by spacing. |
| min | array of doubles of length nDimensions. Gives the coordinate of the zeroth element (origin). Caller owns the memory pointed to by min. |
Definition at line 56 of file NDGrid.cpp.
References coord_m, min(), and size().

| interpolation::NDGrid::NDGrid | ( | std::vector< int > | size, |
| std::vector< const double * > | gridCoordinates | ||
| ) |
Build an irregular grid.
| size | The number of grid points in each dimension. This vector must be the same length as gridCoordinates vector. |
| gridCoordinates | vector of doubles, with the same length as size. Set the coordinates of the grid in each dimension. Caller owns the memory pointed to by gridCoordinates. |
Definition at line 43 of file NDGrid.cpp.
References coord_m, setConstantSpacing(), and size().

| interpolation::NDGrid::NDGrid | ( | std::vector< std::vector< double > > | gridCoordinates | ) |
Build an irregular grid.
| gridCoordinates | Vector of size equal to the dimension of the grid. Element gridCoordinates[i][j] is the position of the jth grid coordinate in the ith dimension. i.e. to find the coordinates of the grid point (23, 17, 21) we would lookup gridCoordinate[0][23] gridCoordinate[1][17] gridCoordinate[2][21] |
Definition at line 70 of file NDGrid.cpp.
References setConstantSpacing(), and size().

| interpolation::NDGrid::NDGrid | ( | const NDGrid & | grid | ) |
Copy constructor.
Definition at line 39 of file NDGrid.cpp.
|
protectedvirtual |
Add difference to lhs and then return lhs.
Implements interpolation::Mesh.
Definition at line 143 of file NDGrid.cpp.
References addEquals(), and interpolation::Mesh::Iterator::toInteger().

|
protectedvirtual |
Add difference to lhs and then return lhs.
Implements interpolation::Mesh.
Definition at line 92 of file NDGrid.cpp.
References coord_m, interpolation::Mesh::Iterator::state_m, and subEquals().
Referenced by addEquals(), and subEquals().

|
protectedvirtual |
Increment position of lhs by one and then return lhs.
Implements interpolation::Mesh.
Definition at line 151 of file NDGrid.cpp.
References coord_m, and size().

|
inlinevirtual |
Returns the origin of the mesh (lowest possible index in all dimensions)
Implements interpolation::Mesh.
Definition at line 358 of file NDGrid.h.
References coord_m.
Referenced by DumpEMFields::writeFieldThis().
|
inlinevirtual |
Inheritable copy constructor.
Implements interpolation::Mesh.
Definition at line 350 of file NDGrid.h.
References NDGrid().
Referenced by DumpEMFields::clone().

|
inline |
Get the coordinate of a set of grid points.
| index | the index of the grid point to be found; indexed from 1. Should be in range 1 <= index <= length |
| dimension | the dimension of the grid point to be found. Should be in range 0 <= dimension < grid dimension |
Note the coord is NOT bound checked - so it is a memory error to go out of the bounds.
Definition at line 302 of file NDGrid.h.
References coord_m.
Referenced by dual().
|
inline |
Get the coordinate of a set of grid points.
| index | the index of the grid point to be found; indexed from 1. Should be in range 1 <= index <= length |
| dimension | the dimension of the grid point to be found. Should be in range 0 <= dimension < grid dimension |
Note the call is NOT bound checked - so it is a memory error to go out of the bounds.
Definition at line 306 of file NDGrid.h.
References coord_m.
|
inline |
Get the grid point of the grid lower bound in a particular dimension.
| x | position in the grid coordinate |
| dimension | the grid coordinate to search along |
| xIndex | will be set with the resultant grid index |
Sets xIndex to the index of the largest mesh position that is less than x in the given dimension. If x is less than all mesh positions, sets xIndex to -1.
Definition at line 318 of file NDGrid.h.
References constantSpacing_m, and coord_m.
Referenced by lowerBound().
|
inline |
Get the vector of grid points along a particular dimension.
| dimension | the dimension of the grid point to be found. Should be in range 0 <= dimension < grid dimension |
Note the call is NOT bound checked - so it is a memory error to go out of the bounds.
Definition at line 314 of file NDGrid.h.
References coord_m.
|
virtual |
Not implemented.
Implements interpolation::Mesh.
Definition at line 232 of file NDGrid.cpp.
References coord(), coord_m, NDGrid(), and size().

|
inlinevirtual |
Returns the end of the mesh (highest possible index in all dimensions)
Implements interpolation::Mesh.
Definition at line 362 of file NDGrid.h.
References coord_m, and end().
Referenced by end(), and DumpEMFields::writeHeader().

|
inline |
Returns true if the Mesh is a regular grid.
Definition at line 380 of file NDGrid.h.
References constantSpacing_m.
|
virtual |
Return an iterator corresponding to nearest mesh point to position.
| position | Array of length dimension, giving a position near the grid. |
Implements interpolation::Mesh.
Definition at line 210 of file NDGrid.cpp.
References coord_m, lowerBound(), and size().

|
inlinevirtual |
Get the position of the iterator.
| it | iterator on this Mesh |
| position | double array of length equal to the mesh dimension. Filled with the iterator position. Caller owns the memory to which position points. |
Implements interpolation::Mesh.
Definition at line 371 of file NDGrid.h.
References coord_m, interpolation::Mesh::Iterator::getState(), and size().

|
inlinevirtual |
Get the dimension of the Mesh.
Implements interpolation::Mesh.
Definition at line 376 of file NDGrid.h.
References coord_m.
|
protectedvirtual |
Return true if rhs is greater than lhs.
Implements interpolation::Mesh.
Definition at line 188 of file NDGrid.cpp.
References interpolation::Mesh::Iterator::state_m.
|
inline |
Get the grid point of the grid lower bound.
| pos | position in the grid coordinate. Should have a length equal to the dimension of the grid. |
| xIndex | will be set with the resultant grid index. Should have a lenght equal to the dimension of the grid. |
Sets xIndex to the index of the largest mesh position that is less than pos in all dimension.
Note that dimension and xIndex are not bound checked.
Definition at line 335 of file NDGrid.h.
References coordLowerBound().
Referenced by getNearest().

|
inline |
|
inline |
| double * interpolation::NDGrid::newCoordArray | ( | const int & | dimension | ) | const |
Get an array of grid points along a particular dimension.
| dimension | the dimension of the grid point to be found. Should be in range 0 <= dimension < grid dimension |
Note the call is NOT bound checked - so it is a memory error to go out of the bounds.
Definition at line 82 of file NDGrid.cpp.
References coord_m.
|
inline |
| void interpolation::NDGrid::setConstantSpacing | ( | double | tolerance_m = 1e-9 | ) |
Automatically detector whether the Mesh is a regular grid.
Loops over all grid points and checks the step size is regular, with tolerance given by tolernance_m
Definition at line 172 of file NDGrid.cpp.
References constantSpacing_m, and coord_m.
|
inline |
|
inline |
Get the size of the grid along a given dimension.
| dimension | the dimension of the grid point to be found. Should be in range 0 <= dimension < grid dimension |
Note the call is NOT bound checked - so it is a memory error to go out of the bounds.
Definition at line 310 of file NDGrid.h.
References coord_m.
Referenced by addOne(), dual(), getNearest(), getPosition(), and NDGrid().
|
protectedvirtual |
Subtract difference from lhs and then return lhs.
Implements interpolation::Mesh.
Definition at line 147 of file NDGrid.cpp.
References subEquals(), and interpolation::Mesh::Iterator::toInteger().

|
protectedvirtual |
Subtract difference from lhs and then return lhs.
Implements interpolation::Mesh.
Definition at line 118 of file NDGrid.cpp.
References addEquals(), coord_m, and interpolation::Mesh::Iterator::state_m.
Referenced by addEquals(), and subEquals().

|
protectedvirtual |
Decrement position of lhs by one and then return lhs.
Implements interpolation::Mesh.
Definition at line 160 of file NDGrid.cpp.
References coord_m, and interpolation::Mesh::Iterator::state_m.
|
virtual |
Return an integer corresponding to the iterator position.
| lhs | iterator whose position is returned. |
Implements interpolation::Mesh.
Definition at line 197 of file NDGrid.cpp.
References coord_m, and interpolation::Mesh::Iterator::state_m.
|
friend |
Return true if lhs does not index the same position as rhs.
|
friend |
Addition operator - adds offset of rhs of rhs relative to Begin() to lhs.
|
friend |
Prefix increment operator ++it.
|
friend |
Postfix increment operator it++ advances iterator by one.
|
friend |
Addition operator - adds offset of rhs of rhs relative to Begin() to lhs and returns lhs.
|
friend |
Subtraction operator - subtracts offset of rhs relative to Begin() from lhs.
|
friend |
Prefix decrement operator –it retreats iterator by one
|
friend |
Postfix decrement operator it– retreats iterator by one.
|
friend |
Subtraction operator - subtracts offset of rhs relative to Begin() from lhs and returns lhs.
|
friend |
Return true if lhs indexes a position less than rhs i.e.
successive operation of decrement operator would eventually reach lhs
|
friend |
Return true if lhs indexes a position less than or equal to rhs i.e.
successive operation of decrement operator would eventually reach lhs
|
friend |
Return true if lhs indexes the same position as rhs.
|
friend |
Return true if lhs indexes a position greater than rhs i.e.
successive operation of increment operator would eventually reach lhs
|
friend |
Return true if lhs indexes a position greater than or equal to rhs i.e.
successive operation of increment operator would eventually reach lhs
|
private |
Definition at line 283 of file NDGrid.h.
Referenced by coordLowerBound(), getConstantSpacing(), and setConstantSpacing().
|
private |
Definition at line 281 of file NDGrid.h.
Referenced by addEquals(), addOne(), begin(), coord(), coordLowerBound(), coordVector(), dual(), end(), getNearest(), getPosition(), getPositionDimension(), max(), min(), NDGrid(), newCoordArray(), setConstantSpacing(), setCoord(), size(), subEquals(), subOne(), and toInteger().
|
private |