OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
#include <ThreeDGrid.h>
Public Member Functions | |
ThreeDGrid * | clone () |
Mesh * | dual () const |
ThreeDGrid () | |
ThreeDGrid (double dX, double dY, double dZ, double minX, double minY, double minZ, int numberOfXCoords, int numberOfYCoords, int numberOfZCoords) | |
ThreeDGrid (int xSize, const double *x, int ySize, const double *y, int zSize, const double *z) | |
ThreeDGrid (std::vector< double > x, std::vector< double > y, std::vector< double > z) | |
~ThreeDGrid () | |
double & | x (const int &i) |
double & | y (const int &j) |
double & | z (const int &k) |
const double & | x (const int &i) const |
const double & | y (const int &j) const |
const double & | z (const int &j) const |
int | xSize () const |
int | ySize () const |
int | zSize () const |
std::vector< double > | xVector () |
std::vector< double > | yVector () |
std::vector< double > | zVector () |
double * | newXArray () |
double * | newYArray () |
double * | newZArray () |
void | xLowerBound (const double &x, int &xIndex) const |
void | yLowerBound (const double &y, int &yIndex) const |
void | zLowerBound (const double &z, int &zIndex) const |
void | lowerBound (const double &x, int &xIndex, const double &y, int &yIndex, const double &z, int &zIndex) const |
void | lowerBound (const double &x, const double &y, const double &z, Mesh::Iterator &it) const |
double | minX () const |
double | maxX () const |
double | minY () const |
double | maxY () const |
double | minZ () const |
double | maxZ () const |
void | setX (int nXCoords, double *x) |
void | setY (int nYCoords, double *y) |
void | setZ (int nZCoords, double *z) |
void | add (VectorMap *map) |
void | remove (VectorMap *map) |
Mesh::Iterator | begin () const |
Mesh::Iterator | end () const |
virtual void | getPosition (const Mesh::Iterator &it, double *position) const |
int | getPositionDimension () const |
int | toInteger (const Mesh::Iterator &lhs) const |
void | setConstantSpacing (bool spacing) |
void | setConstantSpacing () |
bool | getConstantSpacing () const |
Mesh::Iterator | getNearest (const double *position) const |
Public Member Functions inherited from interpolation::Mesh | |
Mesh () | |
virtual | ~Mesh () |
Static Public Member Functions | |
static void | vectorLowerBound (std::vector< double > vec, double x, int &index) |
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< double > | x_m |
std::vector< double > | y_m |
std::vector< double > | z_m |
int | xSize_m |
int | ySize_m |
int | zSize_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) |
ThreeDGrid holds grid information for a rectangular grid used in e.g. interpolation
ThreeDGrid holds the necessary information for regular and irregular grid data for interpolation routines.
Constructor is provided to generate a regular grid given grid spacing etc and an irregular grid given lists of x, y, z data for the grid points. Nearest either calculates nearest grid point a priori for regular grids or uses std::lower_bound to calculate nearest grid point (list bisection or somesuch). Controlled by _constantSpacing flag. The regular spacing lookup is quicker, so prefer constant spacing.
ThreeDGrid 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.
Definition at line 57 of file ThreeDGrid.h.
interpolation::ThreeDGrid::ThreeDGrid | ( | ) |
Default constructor
Definition at line 33 of file ThreeDGrid.cpp.
References setConstantSpacing(), x_m, y_m, and z_m.
Referenced by clone(), and dual().
interpolation::ThreeDGrid::ThreeDGrid | ( | double | dX, |
double | dY, | ||
double | dZ, | ||
double | minX, | ||
double | minY, | ||
double | minZ, | ||
int | numberOfXCoords, | ||
int | numberOfYCoords, | ||
int | numberOfZCoords | ||
) |
Make a regular rectangular ThreeDGrid
Set up a ThreeDGrid with regular grid spacing (same distance between every point)
dX | step size in x; should be positive |
dY | step size in y; should be positive |
dZ | step size in z; should be positive |
minX | x position of grid lower edge |
minY | y position of grid lower edge |
minZ | z position of grid lower edge |
numberOfXCoords | number of x coordinates on grid; should be > 1 |
numberOfYCoords | number of y coordinates on grid; should be > 1 |
numberOfZCoords | number of z coordinates on grid; should be > 1 |
Definition at line 70 of file ThreeDGrid.cpp.
References minX(), minY(), minZ(), setConstantSpacing(), x_m, y_m, and z_m.
interpolation::ThreeDGrid::ThreeDGrid | ( | int | xSize, |
const double * | x, | ||
int | ySize, | ||
const double * | y, | ||
int | zSize, | ||
const double * | z | ||
) |
Make a irregular rectangular ThreeDGrid
Set up a ThreeDGrid with irregular grid spacing
xSize | number of points in x |
x | x points array |
ySize | number of points in y |
y | y points array |
zSize | number of points in Z |
z | z point array ThreeDGrid deep copies the data pointed to by x, y, z (i.e. it does not take ownership of these arrays). |
Definition at line 40 of file ThreeDGrid.cpp.
References setConstantSpacing(), xSize_m, ySize_m, and zSize_m.
interpolation::ThreeDGrid::ThreeDGrid | ( | std::vector< double > | x, |
std::vector< double > | y, | ||
std::vector< double > | z | ||
) |
Make a irregular rectangular ThreeDGrid
Set up a ThreeDGrid with irregular grid spacing
x | x points array |
y | y points array |
z | z point array |
Definition at line 55 of file ThreeDGrid.cpp.
References setConstantSpacing(), xSize_m, ySize_m, and zSize_m.
interpolation::ThreeDGrid::~ThreeDGrid | ( | ) |
Destructor
Definition at line 87 of file ThreeDGrid.cpp.
void interpolation::ThreeDGrid::add | ( | VectorMap * | map | ) |
Add *map to the maps_m list if it has not already been added
Definition at line 257 of file ThreeDGrid.cpp.
References Expressions::find(), and maps_m.
Referenced by interpolation::Interpolator3dGridTo3d::setAll(), interpolation::Interpolator3dGridTo1d::setGrid(), interpolation::Interpolator3dGridTo3d::setGrid(), and interpolation::TriLinearInterpolator::TriLinearInterpolator().
|
protectedvirtual |
Add difference to lhs and then return lhs
Implements interpolation::Mesh.
Definition at line 192 of file ThreeDGrid.cpp.
References addEquals(), and interpolation::Mesh::Iterator::toInteger().
|
protectedvirtual |
Add difference to lhs and then return lhs
Implements interpolation::Mesh.
Definition at line 124 of file ThreeDGrid.cpp.
References interpolation::Mesh::Iterator::state_m, subEquals(), ySize_m, and zSize_m.
Referenced by addEquals(), and subEquals().
|
protectedvirtual |
Increment position of lhs by one and then return lhs
Implements interpolation::Mesh.
Definition at line 202 of file ThreeDGrid.cpp.
References interpolation::Mesh::Iterator::state_m, ySize_m, and zSize_m.
|
virtual |
Return an iterator pointing at the first element in the ThreeDGrid
Implements interpolation::Mesh.
Definition at line 91 of file ThreeDGrid.cpp.
Referenced by DumpFields::writeFieldThis().
|
inlinevirtual |
Deep copy the grid
Implements interpolation::Mesh.
Definition at line 62 of file ThreeDGrid.h.
References ThreeDGrid().
Referenced by DumpFields::clone().
|
virtual |
Not implemented (returns NULL)
Implements interpolation::Mesh.
Definition at line 108 of file ThreeDGrid.cpp.
References ThreeDGrid(), x_m, y_m, and z_m.
|
virtual |
Return an iterator pointing at the last+1 element in the ThreeDGrid
Implements interpolation::Mesh.
Definition at line 95 of file ThreeDGrid.cpp.
References xSize_m.
Referenced by DumpFields::writeFieldThis().
|
inline |
Return true if using constant spacing
Definition at line 472 of file ThreeDGrid.h.
References constantSpacing_m.
|
virtual |
Return the point in the mesh nearest to position
Implements interpolation::Mesh.
Definition at line 284 of file ThreeDGrid.cpp.
References lowerBound(), x_m, xSize_m, y_m, ySize_m, z_m, and zSize_m.
|
virtual |
Fill position with the position of it
it | iterator pointing at a grid position |
position | array of length >= 3 that will be filled with the position of it |
Implements interpolation::Mesh.
Definition at line 101 of file ThreeDGrid.cpp.
References interpolation::Mesh::Iterator::state_m, x(), y(), and z().
|
inlinevirtual |
Returns 3, the dimension of the space of the grid
Implements interpolation::Mesh.
Definition at line 458 of file ThreeDGrid.h.
|
protectedvirtual |
Return true if rhs is greater than lhs
Implements interpolation::Mesh.
Definition at line 230 of file ThreeDGrid.cpp.
References interpolation::Mesh::Iterator::state_m.
|
inline |
Find the iterator of the nearest point on the grid less than x, y, z
Note that in the case of a regular grid there is no bound checking; in the case of an irregular grid we always return an element in the grid
Definition at line 387 of file ThreeDGrid.h.
References x(), xLowerBound(), y(), yLowerBound(), z(), and zLowerBound().
|
inline |
Find the indices of the nearest point on the grid less than x, y, z
Note that in the case of a regular grid there is no bound checking; in the case of an irregular grid we always return an element in the grid
Definition at line 379 of file ThreeDGrid.h.
References x(), xLowerBound(), y(), yLowerBound(), z(), and zLowerBound().
Referenced by interpolation::TriLinearInterpolator::function(), and getNearest().
|
inline |
Return the largest value of x in the grid
Definition at line 426 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo3d::function(), and SectorMagneticFieldMap::setInterpolator().
|
inline |
Return the largest value of y in the grid
Definition at line 434 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo3d::function(), and SectorMagneticFieldMap::setInterpolator().
|
inline |
Return the largest value of z in the grid
Definition at line 442 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo3d::function(), SectorMagneticFieldMap::getDeltaPhi(), and SectorMagneticFieldMap::setInterpolator().
|
inline |
Return the smallest value of x in the grid
Definition at line 422 of file ThreeDGrid.h.
References x_m.
Referenced by interpolation::Interpolator3dGridTo3d::function(), SectorMagneticFieldMap::setInterpolator(), and ThreeDGrid().
|
inline |
Return the smallest value of y in the grid
Definition at line 430 of file ThreeDGrid.h.
References y_m.
Referenced by interpolation::Interpolator3dGridTo3d::function(), SectorMagneticFieldMap::setInterpolator(), and ThreeDGrid().
|
inline |
Return the smallest value of z in the grid
Definition at line 438 of file ThreeDGrid.h.
References z_m.
Referenced by interpolation::Interpolator3dGridTo3d::function(), SectorMagneticFieldMap::getDeltaPhi(), SectorMagneticFieldMap::SectorMagneticFieldMap(), SectorMagneticFieldMap::setInterpolator(), and ThreeDGrid().
|
inline |
Allocate a new array containing x grid data
Definition at line 358 of file ThreeDGrid.h.
|
inline |
Allocate a new array containing y grid data
Definition at line 365 of file ThreeDGrid.h.
|
inline |
Allocate a new array containing z grid data
Definition at line 372 of file ThreeDGrid.h.
void interpolation::ThreeDGrid::remove | ( | VectorMap * | map | ) |
Remove *map from the maps_m list if it has not already been removed. If there are no more maps in the list, delete this
Definition at line 245 of file ThreeDGrid.cpp.
References Expressions::find(), and maps_m.
Referenced by interpolation::Interpolator3dGridTo1d::clear(), interpolation::Interpolator3dGridTo3d::clear(), interpolation::Interpolator3dGridTo3d::setAll(), interpolation::Interpolator3dGridTo1d::setGrid(), and interpolation::Interpolator3dGridTo3d::setGrid().
void interpolation::ThreeDGrid::setConstantSpacing | ( | ) |
Autodetect constant spacing with float tolerance of 1e-9
Definition at line 265 of file ThreeDGrid.cpp.
References abs(), constantSpacing_m, Physics::e, x_m, y_m, and z_m.
Referenced by ThreeDGrid().
|
inline |
Set to true to use constant spacing
If constant spacing is true, assume regular grid with spacing given by separation of first two elements in each dimension
Definition at line 468 of file ThreeDGrid.h.
References constantSpacing_m.
Referenced by SectorMagneticFieldMap::IO::generateGrid().
|
inline |
Reset x grid points - note may need to set SetConstantSpacing()
Definition at line 446 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo1d::setX(), and interpolation::Interpolator3dGridTo3d::setX().
|
inline |
Reset y grid points - note may need to set SetConstantSpacing()
Definition at line 450 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo1d::setY(), and interpolation::Interpolator3dGridTo3d::setY().
|
inline |
Reset z grid points - note may need to set SetConstantSpacing()
Definition at line 454 of file ThreeDGrid.h.
Referenced by interpolation::Interpolator3dGridTo1d::setZ(), and interpolation::Interpolator3dGridTo3d::setZ().
|
protectedvirtual |
Subtract difference from lhs and then return lhs
Implements interpolation::Mesh.
Definition at line 197 of file ThreeDGrid.cpp.
References subEquals(), and interpolation::Mesh::Iterator::toInteger().
|
protectedvirtual |
Subtract difference from lhs and then return lhs
Implements interpolation::Mesh.
Definition at line 146 of file ThreeDGrid.cpp.
References addEquals(), interpolation::Mesh::Iterator::state_m, ySize_m, and zSize_m.
Referenced by addEquals(), and subEquals().
|
protectedvirtual |
Decrement position of lhs by one and then return lhs
Implements interpolation::Mesh.
Definition at line 215 of file ThreeDGrid.cpp.
References interpolation::Mesh::Iterator::state_m, ySize_m, and zSize_m.
|
inlinevirtual |
Converts from iterator to integer value
0 corresponds to the mesh beginning. integers index (right most index) indexes z, middle index is y, most significant (left most index) indexes x.
Implements interpolation::Mesh.
Definition at line 462 of file ThreeDGrid.h.
References interpolation::Mesh::Iterator::getState(), ySize_m, and zSize_m.
|
static |
Custom LowerBound routine like std::lower_bound
Make a binary search to find the element in vec with vec[i] <= x.
vec | STL vector object (could make this any sorted iterator...) |
x | object for which to search. |
index | vectorLowerBound sets index to the position of the element. If x < vec[0], vectorLowerBound fills with -1. |
Definition at line 168 of file ThreeDGrid.cpp.
References x().
Referenced by xLowerBound(), yLowerBound(), and zLowerBound().
|
inline |
Get ith coordinate in x
Round bracket indexing starts at 1 goes to nCoords
Definition at line 122 of file ThreeDGrid.h.
References x_m.
Referenced by interpolation::TriLinearInterpolator::function(), getPosition(), lowerBound(), newXArray(), setX(), vectorLowerBound(), and xLowerBound().
|
inline |
Get ith coordinate in x
Round bracket indexing starts at 1 goes to nCoords
Definition at line 140 of file ThreeDGrid.h.
References x_m.
|
inline |
Find the index of the nearest point less than x
Note that in the case of a regular grid there is no bound checking; in the case of an irregular grid we always return an element in the grid
Definition at line 399 of file ThreeDGrid.h.
References constantSpacing_m, floor(), vectorLowerBound(), x(), and x_m.
Referenced by lowerBound().
|
inline |
Get size of x data
Definition at line 155 of file ThreeDGrid.h.
References x_m.
Referenced by interpolation::TriLinearInterpolator::function(), SectorMagneticFieldMap::IO::getInterpolator(), interpolation::Interpolator3dGridTo1d::getNumberOfXCoords(), interpolation::Interpolator3dGridTo3d::getNumberOfXCoords(), and interpolation::TriLinearInterpolator::TriLinearInterpolator().
|
inline |
|
inline |
Get ith coordinate in y
Round bracket indexing starts at 1 goes to nCoords
Definition at line 128 of file ThreeDGrid.h.
References y_m.
Referenced by interpolation::TriLinearInterpolator::function(), getPosition(), lowerBound(), newYArray(), setY(), and yLowerBound().
|
inline |
Get ith coordinate in y
Round bracket indexing starts at 1 goes to nCoords
Definition at line 146 of file ThreeDGrid.h.
References y_m.
|
inline |
Find the index of the nearest point less than y
Note that in the case of a regular grid there is no bound checking; in the case of an irregular grid we always return an element in the grid
Definition at line 408 of file ThreeDGrid.h.
References constantSpacing_m, floor(), vectorLowerBound(), y(), and y_m.
Referenced by lowerBound().
|
inline |
Get size of y data
Definition at line 158 of file ThreeDGrid.h.
References y_m.
Referenced by interpolation::TriLinearInterpolator::function(), SectorMagneticFieldMap::IO::getInterpolator(), interpolation::Interpolator3dGridTo1d::getNumberOfYCoords(), interpolation::Interpolator3dGridTo3d::getNumberOfYCoords(), and interpolation::TriLinearInterpolator::TriLinearInterpolator().
|
inline |
|
inline |
Get ith coordinate in z
Round bracket indexing starts at 1 goes to nCoords
Definition at line 152 of file ThreeDGrid.h.
References z_m.
|
inline |
Get ith coordinate in z
Round bracket indexing starts at 1 goes to nCoords
Definition at line 134 of file ThreeDGrid.h.
References z_m.
Referenced by interpolation::TriLinearInterpolator::function(), getPosition(), lowerBound(), newZArray(), setZ(), and zLowerBound().
|
inline |
Find the index of the nearest point less than z
Note that in the case of a regular grid there is no bound checking; in the case of an irregular grid we always return an element in the grid
Definition at line 415 of file ThreeDGrid.h.
References constantSpacing_m, floor(), vectorLowerBound(), z(), and z_m.
Referenced by lowerBound().
|
inline |
Get size of z data
Definition at line 161 of file ThreeDGrid.h.
References z_m.
Referenced by interpolation::TriLinearInterpolator::function(), SectorMagneticFieldMap::IO::getInterpolator(), interpolation::Interpolator3dGridTo1d::getNumberOfZCoords(), interpolation::Interpolator3dGridTo3d::getNumberOfZCoords(), and interpolation::TriLinearInterpolator::TriLinearInterpolator().
|
inline |
|
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 329 of file ThreeDGrid.h.
Referenced by getConstantSpacing(), setConstantSpacing(), xLowerBound(), yLowerBound(), and zLowerBound().
|
private |
Definition at line 328 of file ThreeDGrid.h.
|
private |
Definition at line 322 of file ThreeDGrid.h.
Referenced by dual(), getNearest(), maxX(), minX(), newXArray(), setConstantSpacing(), setX(), ThreeDGrid(), x(), xLowerBound(), xSize(), and xVector().
|
private |
Definition at line 325 of file ThreeDGrid.h.
Referenced by end(), getNearest(), maxX(), and ThreeDGrid().
|
private |
Definition at line 323 of file ThreeDGrid.h.
Referenced by dual(), getNearest(), maxY(), minY(), newYArray(), setConstantSpacing(), setY(), ThreeDGrid(), y(), yLowerBound(), ySize(), and yVector().
|
private |
Definition at line 326 of file ThreeDGrid.h.
Referenced by addEquals(), addOne(), getNearest(), maxY(), subEquals(), subOne(), ThreeDGrid(), and toInteger().
|
private |
Definition at line 324 of file ThreeDGrid.h.
Referenced by dual(), getNearest(), maxZ(), minZ(), newZArray(), setConstantSpacing(), setZ(), ThreeDGrid(), z(), zLowerBound(), zSize(), and zVector().
|
private |
Definition at line 327 of file ThreeDGrid.h.
Referenced by addEquals(), addOne(), getNearest(), maxZ(), subEquals(), subOne(), ThreeDGrid(), and toInteger().