OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
#include <NDGrid.h>
Public Member Functions | |
NDGrid * | clone () |
Mesh * | dual () const |
NDGrid () | |
////// NDGrid /////// More... | |
NDGrid (int nDimensions, int *size, double *spacing, double *min) | |
NDGrid (std::vector< int > size, std::vector< const double * > gridCoordinates) | |
NDGrid (std::vector< std::vector< double > > gridCoordinates) | |
NDGrid (const NDGrid &grid) | |
~NDGrid () | |
double & | coord (const int &index, const int &dimension) |
const double & | coord (const int &index, const int &dimension) const |
int | size (const int &dimension) const |
std::vector< double > | coordVector (const int &dimension) const |
double * | newCoordArray (const int &dimension) const |
void | coordLowerBound (const double &x, const int &dimension, int &xIndex) const |
void | lowerBound (const std::vector< double > &pos, std::vector< int > &xIndex) const |
double | min (const int &dimension) const |
double | max (const int &dimension) const |
void | setCoord (int dimension, int nCoords, double *x) |
Mesh::Iterator | begin () const |
Mesh::Iterator | end () const |
void | getPosition (const Mesh::Iterator &it, double *position) const |
int | getPositionDimension () const |
bool | getConstantSpacing () const |
void | setConstantSpacing (bool spacing) |
void | setConstantSpacing (double tolerance_m=1e-9) |
int | toInteger (const Mesh::Iterator &lhs) const |
Mesh::Iterator | getNearest (const double *position) const |
![]() | |
Mesh () | |
virtual | ~Mesh () |
Protected Member Functions | |
virtual Mesh::Iterator & | addEquals (Mesh::Iterator &lhs, int difference) const |
virtual Mesh::Iterator & | subEquals (Mesh::Iterator &lhs, int difference) const |
virtual Mesh::Iterator & | addEquals (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
virtual Mesh::Iterator & | subEquals (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
virtual Mesh::Iterator & | addOne (Mesh::Iterator &lhs) const |
virtual Mesh::Iterator & | subOne (Mesh::Iterator &lhs) const |
virtual bool | isGreater (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const |
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) |
Mesh::Iterator | operator-- (Mesh::Iterator &lhs, int) |
Mesh::Iterator & | operator++ (Mesh::Iterator &lhs) |
Mesh::Iterator & | operator-- (Mesh::Iterator &lhs) |
Mesh::Iterator | operator- (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
Mesh::Iterator | operator+ (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
Mesh::Iterator & | operator-= (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
Mesh::Iterator & | operator+= (Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator== (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator!= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator>= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator<= (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator< (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
bool | operator> (const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) |
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 | ( | ) |
////// NDGrid ///////
Build a default, empty grid with zero dimension
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, coord_m, and floor().
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.
Referenced by 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 abs(), 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 |