Container for holding a function defined on a grid of arbitrary dimension. More...
#include <GriddedData.h>
Public Types | |
typedef MooseUtils::SemidynamicVector< Real, 4 > | GridPoint |
typedef MooseUtils::SemidynamicVector< ADReal, 4 > | ADGridPoint |
typedef MooseUtils::SemidynamicVector< unsigned int, 4 > | GridIndex |
Public Member Functions | |
GriddedData (std::string file_name) | |
Construct with a file name. More... | |
virtual | ~GriddedData ()=default |
unsigned int | getDim () |
Returns the dimensionality of the grid. More... | |
void | getAxes (std::vector< int > &axes) |
Yields axes information. More... | |
void | getGrid (std::vector< std::vector< Real >> &grid) |
Yields the grid. More... | |
void | getFcn (std::vector< Real > &fcn) |
Yields the values defined at the grid points. More... | |
Real | evaluateFcn (const GridIndex &ijk) |
Evaluates the function at a given grid point. More... | |
Static Public Member Functions | |
static void | parse (unsigned int &dim, std::vector< int > &axes, std::vector< std::vector< Real >> &grid, std::vector< Real > &f, std::vector< unsigned int > &step, std::string file_name) |
parse the file_name extracting information. More... | |
Private Member Functions | |
void | updateGrid (unsigned int &dim, const std::vector< Real > &axis_i, const int axis_index) |
Static Private Member Functions | |
static bool | getSignificantLine (std::ifstream &file_stream, std::string &line) |
Extracts the next line from file_stream that is: More... | |
static void | splitToRealVec (const std::string &input_string, std::vector< Real > &output_vec) |
Splits an input_string using space as the separator Converts the resulting items to Real, and adds these to the end of output_vec. More... | |
Private Attributes | |
unsigned int | _dim |
std::vector< int > | _axes |
std::vector< std::vector< Real > > | _grid |
std::vector< Real > | _fcn |
std::vector< unsigned int > | _step |
Container for holding a function defined on a grid of arbitrary dimension.
Information is read from a file. The file contains the grid, which has dimension _dim, and consists of _dim vectors of Reals. The file also contains the function values at each grid point. The file also contains information on how to embed the grid into a MOOSE simulation. This is achieved through specifying the MOOSE direction that each grid axis corresponds to. For instance, the first grid axis might correspond to the MOOSE "y" direction, the second grid axis might correspond to the MOOSE "t" direction, etc.
Definition at line 32 of file GriddedData.h.
Definition at line 43 of file GriddedData.h.
typedef MooseUtils::SemidynamicVector<unsigned int, 4> GriddedData::GridIndex |
Definition at line 44 of file GriddedData.h.
typedef MooseUtils::SemidynamicVector<Real, 4> GriddedData::GridPoint |
Definition at line 42 of file GriddedData.h.
GriddedData::GriddedData | ( | std::string | file_name | ) |
Construct with a file name.
Creates a GriddedData object by reading info from file_name A grid is defined in _grid.
For example, if grid[0] = {1, 2, 3} and grid[1] = {-1, 1} this defines a 2D grid (_dim = 2), with points (1,-1), (2,-1), (3,-1), (1,1), (2,1), (3,1) The i_th axis of the grid corresponds to the axes[i] axis of the simulation: see the function getAxes Values at each grid point are stored in _fcn. They are ordered as in the example above. _step is just a quantity used in evaluateFcn The file must have the following format: All blank lines and lines starting with # are ignored The first significant line (not blank or starting with #) should be either AXIS X or AXIS Y or AXIS Z or AXIS T The next significant line should be a space-separated array of real numbers defining the grid along that axis direction. Any number of AXIS and subsequent space-separated arrays can be defined, but if using this in conjunction with PiecewiseMultilinear, a maximum of 4 should be defined. The AXIS lines define the grid in the MOOSE simulation reference frame, and is used by PiecewiseMultilinear, for instance. The next significant line should be DATA All significant lines after DATA should be the function values at each grid point, on any number of lines of the file, but each line must be space separated. The ordering is such that when the function is evaluated, f[i,j,k,l] corresponds to the i + j*Ni + k*Ni*Nj + l*Ni*Nj*Nk data value. Here i>=0 corresponds to the index along the first AXIS, and Ni is the number of grid points along that axis, etc. See the function parse for an example.
Definition at line 55 of file GriddedData.C.
|
virtualdefault |
Evaluates the function at a given grid point.
For instance, evaluateFcn({n,m}) = value at (grid[0][n], grid[1][m]), for a function defined on a 2D grid
Definition at line 92 of file GriddedData.C.
Yields axes information.
If axes[i] == 0 then the i_th axis in the grid data corresponds to the x axis in the simulation If axes[i] == 1 then the i_th axis in the grid data corresponds to the y axis in the simulation If axes[i] == 2 then the i_th axis in the grid data corresponds to the z axis in the simulation If axes[i] == 3 then the i_th axis in the grid data corresponds to the time in the simulation
Definition at line 67 of file GriddedData.C.
unsigned int GriddedData::getDim | ( | ) |
Returns the dimensionality of the grid.
This may have nothing to do with the dimensionality of the simulation. Eg, a 2D grid with axes (Y,Z) (so dim=2) be used in a 3D simulation.
Definition at line 61 of file GriddedData.C.
Yields the grid.
grid[i] = a vector of Reals that define the i_th axis of the grid.
Definition at line 74 of file GriddedData.C.
|
staticprivate |
Extracts the next line from file_stream that is:
Definition at line 209 of file GriddedData.C.
Referenced by parse().
|
static |
parse the file_name extracting information.
Here is an example file:
AXIS Y -1.5 0
AXIS X 1 2 3
AXIS T 0 199
DATA
1 2
2 3
2 3
89 900
1 -3 -5 -6.898
Definition at line 110 of file GriddedData.C.
Referenced by GriddedData().
|
staticprivate |
Splits an input_string using space as the separator Converts the resulting items to Real, and adds these to the end of output_vec.
Definition at line 225 of file GriddedData.C.
Referenced by parse().
|
private |
|
private |
Definition at line 117 of file GriddedData.h.
Referenced by getAxes(), and GriddedData().
|
private |
Definition at line 116 of file GriddedData.h.
Referenced by evaluateFcn(), getAxes(), getDim(), getGrid(), and GriddedData().
|
private |
Definition at line 119 of file GriddedData.h.
Referenced by evaluateFcn(), getFcn(), and GriddedData().
|
private |
Definition at line 118 of file GriddedData.h.
Referenced by getGrid(), and GriddedData().
|
private |
Definition at line 120 of file GriddedData.h.
Referenced by evaluateFcn(), and GriddedData().