11 #include "TPolyLine.h"
28 Grid(
const std::vector<Vertex>& vertices);
36 const std::vector<double>& vec);
45 Grid(
double (*fcn)(
const std::vector<double>& val),
46 const std::vector<size_t>& number,
47 const std::vector<double>& lower,
48 const std::vector<double>& upper);
57 Grid(
const std::vector<size_t>& number,
58 const std::vector<double>& lower,
59 const std::vector<double>& upper,
60 const std::string algo=
"flat");
121 std::vector<size_t>
GetLowerIndices(
const std::vector<double>& v)
const;
124 Grid GetCell(
const std::vector<size_t>& indices)
const;
177 {
return _vertices[id].GetCoordinates(); }
180 double GetPosition(
const size_t i,
const size_t id)
const;
183 std::vector<double>
GetPosition(
const std::vector<size_t>& vi,
184 const std::vector<size_t>& ids)
const;
190 size_t ID(
const std::vector<size_t>& indices)
const;
193 std::vector<size_t>
Indices(
size_t id)
const;
196 bool IsInside(
const std::vector<double>& v)
const;
199 std::vector<TPolyLine*>
Polygons()
const;
std::vector< double > _upper
n-vector, upper bounds of the grid
Definition: Grid.hh:208
void InitializeFromFunction(double(*fcn)(const std::vector< double > &val))
Initializes the grid, provided a scalar function defined within boundaries.
Definition: Grid.cc:158
const size_t & GetDimension() const
Returns the dimension of the space in which the grid is constructed.
Definition: Grid.hh:133
double GetPosition(const size_t i, const size_t id) const
Returns the position in dimension i for a point index id in this dimension.
Definition: Grid.cc:356
std::vector< Vertex > & GetVertexArray()
Returns the array of all the vertices, allows modifications.
Definition: Grid.hh:173
Grid GetCell(const std::vector< size_t > &indices) const
Returns a cell of the grid given the lower bound indicies.
Definition: Grid.cc:302
void SetVertex(const std::vector< size_t > &indices, const Vertex &vertex)
Sets the coordinates of the vertex.
Definition: Grid.hh:166
bool IsInside(const std::vector< double > &v) const
Returns the indices of the element within the vertex matrix.
Definition: Grid.cc:402
const Vertex & operator[](const size_t id) const
Returns the vertex.
Definition: Grid.hh:75
Grid()
Default constructor, initilizes everything to 0.
Definition: Grid.cc:3
Data structure for a grid of points and their mapping onto a scalar field.
Definition: Grid.hh:19
const size_t & GetNpoints(const size_t i) const
Returns the number of points in dimension i.
Definition: Grid.hh:139
double GetCellVolume() const
Returns the volume of one of the cell of the grid.
Definition: Grid.cc:347
std::vector< size_t > _number
n-vector, number of steps on each axis
Definition: Grid.hh:204
std::vector< size_t > GetLowerIndices(const std::vector< double > &v) const
Find the IDs of the points on the grid that directly preceed v.
Definition: Grid.cc:280
const double & GetUpperBound(const size_t i) const
Returns the upper bound in dimension i.
Definition: Grid.hh:163
size_t ID(const std::vector< size_t > &indices) const
Returns the id of the element within the vertex matrix.
Definition: Grid.cc:380
std::vector< Vertex > _vertices
N_1*...*N_n-vector of vertices (Vertex object)
Definition: Grid.hh:203
std::vector< double > _lower
n-vector, lower bounds of the grid
Definition: Grid.hh:207
const size_t size() const
Returns the dimension of the vector field in which the vertex is defined.
Definition: Grid.hh:88
std::vector< size_t > _step
n-vector, stepping of each axis
Definition: Grid.hh:205
std::vector< Grid > GetCellArray() const
Returns all the cells of the grid in an array.
Definition: Grid.cc:324
const Vertex & operator[](const std::vector< size_t > indices) const
Subscript operator.
Definition: Grid.hh:81
const std::vector< double > & GetLowerBoundArray() const
Returns the array of lower bounds in each dimension.
Definition: Grid.hh:154
const std::vector< size_t > & GetNpointsArray() const
Returns the array of number of points in each dimension.
Definition: Grid.hh:136
const double & GetPeriod(const size_t i) const
Returns the period size in dimension i.
Definition: Grid.hh:151
const double & GetLowerBound(const size_t i) const
Returns the lower bound in dimension i.
Definition: Grid.hh:157
Vertex & operator[](const size_t id)
Returns the vertex.
Definition: Grid.hh:72
Vertex & operator[](const std::vector< size_t > indices)
Subscript operator.
Definition: Grid.hh:78
const size_t & GetStep(const size_t i) const
Returns the step size in dimension i.
Definition: Grid.hh:145
std::vector< TPolyLine * > Polygons() const
Returns an array of polygons to be drawn in ROOT (only 2D)
Definition: Grid.cc:412
void Initialize()
Initializes the grid.
Definition: Grid.cc:82
Grid & operator=(const Grid &grid)
Equality operator.
Definition: Grid.cc:65
Grid GetBestCell(const std::vector< double > &v) const
Find the closest cell of the grid to a given point of coordinates v.
Definition: Grid.cc:274
size_t _dim
Dimension of the space.
Definition: Grid.hh:202
const std::vector< double > & GetPositionArray(const size_t id) const
Returns the position of a point of index id.
Definition: Grid.hh:176
void InitializeFromMatrix(const Matrix< double > &mat, const std::vector< double > &vec)
Initializes the grid, provided a matrix of vertices and their mapping.
Definition: Grid.cc:136
const std::vector< double > & GetPeriodArray() const
Returns the array of period size in each dimension.
Definition: Grid.hh:148
void InitializeRandom(const std::string &algo)
Initializes the grid to random values of scalar field.
Definition: Grid.cc:214
std::vector< double > _period
n-vector, length of a period of each axis
Definition: Grid.hh:206
const std::vector< double > & GetUpperBoundArray() const
Returns the array of upper bounds in each dimension.
Definition: Grid.hh:160
double GetVolume() const
Returns the volume occupied by the grid.
Definition: Grid.cc:371
bool operator!() const
Not operator.
Definition: Grid.hh:69
std::vector< size_t > Indices(size_t id) const
Returns the indices of the element within the vertex matrix.
Definition: Grid.cc:389
const std::vector< size_t > & GetStepArray() const
Returns the array of step sizes in each dimension.
Definition: Grid.hh:142
const std::vector< Vertex > & GetVertexArray() const
Returns the array of all the vertices.
Definition: Grid.hh:170
Defines an n-dimensional vertex and its mapping onto a sclar field.
Definition: Vertex.hh:13
~Grid()
Destructor.
Definition: Grid.cc:80