28#ifndef _CLASSIC_FIELDS_THREEDGRID_HH_
29#define _CLASSIC_FIELDS_THREEDGRID_HH_
86 int numberOfXCoords,
int numberOfYCoords,
int numberOfZCoords);
101 int ySize,
const double *
y,
102 int zSize,
const double *
z);
112 std::vector<double>
y,
113 std::vector<double>
z);
122 inline double&
x(
const int& i) {
return x_m[i-1];}
128 inline double&
y(
const int& j) {
return y_m[j-1];}
134 inline double&
z(
const int& k) {
return z_m[k-1];}
140 inline const double&
x(
const int& i)
const {
return x_m[i-1];}
146 inline const double&
y(
const int& j)
const {
return y_m[j-1];}
152 inline const double&
z(
const int& j)
const {
return z_m[j-1];}
155 inline int xSize()
const {
return static_cast<int>(
x_m.size());}
158 inline int ySize()
const {
return static_cast<int>(
y_m.size());}
161 inline int zSize()
const {
return static_cast<int>(
z_m.size());}
164 std::vector<double>
xVector() {
return std::vector<double>(
x_m);}
167 std::vector<double>
yVector() {
return std::vector<double>(
y_m);}
170 std::vector<double>
zVector() {
return std::vector<double>(
z_m);}
186 inline void xLowerBound(
const double&
x,
int& xIndex)
const;
193 inline void yLowerBound(
const double&
y,
int& yIndex)
const;
200 inline void zLowerBound(
const double&
z,
int& zIndex)
const;
207 inline void lowerBound(
const double&
x,
int& xIndex,
208 const double&
y,
int& yIndex,
209 const double&
z,
int& zIndex)
const;
216 inline void lowerBound(
const double&
x,
const double&
y,
const double&
z,
220 inline double minX()
const;
223 inline double maxX()
const;
226 inline double minY()
const;
229 inline double maxY()
const;
232 inline double minZ()
const;
235 inline double maxZ()
const;
238 inline void setX(
int nXCoords,
double *
x);
241 inline void setY(
int nYCoords,
double *
y);
244 inline void setZ(
int nZCoords,
double *
z);
308 int difference)
const;
310 int difference)
const;
359 double *
x =
new double[
x_m.size()];
360 for (
unsigned int i = 0; i <
x_m.size(); i++)
366 double *
y =
new double[
y_m.size()];
367 for (
unsigned int i = 0; i <
y_m.size(); i++)
373 double *
z =
new double[
z_m.size()];
374 for (
unsigned int i = 0; i <
z_m.size(); i++)
380 const double& y,
int& yIndex,
381 const double& z,
int& zIndex)
const {
447 x_m = std::vector<double>(
x,
x+nXCoords);
451 y_m = std::vector<double>(
y,
y+nYCoords);
455 z_m = std::vector<double>(
z,
z+nZCoords);
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Base class for meshing routines.
Used to loop over some, or all, points in the mesh, as in stl Enables e.g.
std::vector< int > getState() const
Return the internal state of the iterator.
ThreeDGrid holds grid information for a rectangular grid used in e.g.
Mesh::Iterator begin() const
Return an iterator pointing at the first element in the ThreeDGrid.
double maxZ() const
Return the largest value of z in the grid.
void yLowerBound(const double &y, int &yIndex) const
Find the index of the nearest point less than y.
friend bool operator>(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Return true if lhs indexes a position greater than rhs i.e.
void setY(int nYCoords, double *y)
Reset y grid points - note may need to set SetConstantSpacing()
void setZ(int nZCoords, double *z)
Reset z grid points - note may need to set SetConstantSpacing()
void setConstantSpacing()
Autodetect constant spacing with float tolerance of 1e-9.
std::vector< double > zVector()
Get vector containing z grid data.
std::vector< double > xVector()
Get vector containing x grid data.
friend Mesh::Iterator & operator++(Mesh::Iterator &lhs)
Prefix increment operator ++it.
friend bool operator<(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Return true if lhs indexes a position less than rhs i.e.
std::vector< double > y_m
const double & y(const int &j) const
Get ith coordinate in y.
virtual void getPosition(const Mesh::Iterator &it, double *position) const
Fill position with the position of it.
Mesh * dual() const
Not implemented (returns nullptr)
double maxX() const
Return the largest value of x in the grid.
static void vectorLowerBound(std::vector< double > vec, double x, int &index)
Custom LowerBound routine like std::lower_bound.
Mesh::Iterator end() const
Return an iterator pointing at the last+1 element in the ThreeDGrid.
std::vector< double > x_m
int zSize() const
Get size of z data.
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, int difference) const
Subtract difference from lhs and then return lhs.
const double & x(const int &i) const
Get ith coordinate in x.
void remove(VectorMap *map)
Remove *map from the maps_m list if it has not already been removed.
friend bool operator!=(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Return true if lhs does not index the same position as rhs.
std::vector< double > z_m
double maxY() const
Return the largest value of y in the grid.
const double & z(const int &j) const
Get ith coordinate in z.
void zLowerBound(const double &z, int &zIndex) const
Find the index of the nearest point less than z.
friend Mesh::Iterator & operator--(Mesh::Iterator &lhs)
Prefix decrement operator –it retreats iterator by one
ThreeDGrid * clone()
Deep copy the grid.
bool getConstantSpacing() const
Return true if using constant spacing.
int xSize() const
Get size of x data.
void xLowerBound(const double &x, int &xIndex) const
Find the index of the nearest point less than x.
friend bool operator==(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs)
Return true if lhs indexes the same position as rhs.
double minY() const
Return the smallest value of y in the grid.
std::vector< double > yVector()
Get vector containing y grid data.
ThreeDGrid()
Default constructor.
virtual Mesh::Iterator & subOne(Mesh::Iterator &lhs) const
Decrement position of lhs by one and then return lhs.
double & x(const int &i)
Get ith coordinate in x.
friend 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.
double & z(const int &k)
Get ith coordinate in z.
friend Mesh::Iterator operator--(Mesh::Iterator &lhs, int)
Postfix decrement operator it– retreats iterator by one.
virtual bool isGreater(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const
Return true if rhs is greater than lhs.
void setX(int nXCoords, double *x)
Reset x grid points - note may need to set SetConstantSpacing()
double * newYArray()
Allocate a new array containing y grid data.
int getPositionDimension() const
Returns 3, the dimension of the space of the grid.
double & y(const int &j)
Get ith coordinate in y.
void add(VectorMap *map)
Add *map to the maps_m list if it has not already been added.
virtual Mesh::Iterator & addOne(Mesh::Iterator &lhs) const
Increment position of lhs by one and then return lhs.
double * newXArray()
Allocate a new array containing x grid data.
double minX() const
Return the smallest value of x in the grid.
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, int difference) const
Add difference to lhs and then return lhs.
double * newZArray()
Allocate a new array containing z grid data.
int toInteger(const Mesh::Iterator &lhs) const
Converts from iterator to integer value.
int ySize() const
Get size of y data.
void lowerBound(const double &x, int &xIndex, const double &y, int &yIndex, const double &z, int &zIndex) const
Find the indices of the nearest point on the grid less than x, y, z.
friend 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.
double minZ() const
Return the smallest value of z in the grid.
std::vector< VectorMap * > maps_m
Mesh::Iterator getNearest(const double *position) const
Return the point in the mesh nearest to position.
friend Mesh::Iterator operator++(Mesh::Iterator &lhs, int)
Postfix increment operator it++ advances iterator by one.
VectorMap is an abstract class that defines mapping from one vector to another.