This PR sets a ground for using tabulated data in M2ulPhyS class.
Tabulated data are supposed to be stored in HDF5 format, with a dataset name table.
struct TableInput contains necessary information for using tabulated data:
struct TableInput {
int Ndata;
const double *xdata;
const double *fdata;
bool xLogScale;
bool fLogScale;
int order; // interpolation order. Currently only support order=1.
};
xdata and fdata point to the data. Currently both xdata and fdata are only one-column array, therefore only supporting one-dimensional table.
TableInterpolator base class is initialized with the information in TableInput. TableInterpolator::eval evaluates the function value at given evaluation point, which is differently defined per derived class. Currently, only LinearTable is available as a derived class.
LinearTable derived class supports simple linear interpolation (respecting the log scale options).
h5ReadTable reads the table into mfem::DenseMatrix variable, and returns the size of the table.
M2ulPhyS::readTable reads the input options for the tabulated data, then reads the hdf5 file on the root rank using h5ReadTable. The data is stored as DenseMatrix in std::vector<DenseMatrix> M2ulPhyS.config.tableHost. Each DenseMatrix is broadcast to all mpi ranks, and its device pointer is stored in a TableInput struct, which can be used for objects in the device.
In essence, only the pointers to data is passed when initializing an object inside the device. Passing the entire data within a fixed-size array is prohibitive, where the size of tabulated data can easily exceed that of formal parameter size (4096 bytes).
This PR also supports reaction with tabulated rate data.
Tabulated class is derived from Reaction, having a TableInterpolator pointer. Although only LinearTable is available, any other TableInterpolator can be used once it is implemented.
Previously, model parameters for all reactions are stored into one array ChemistryInput.reactionModelParams. Since now Tabulated is available, this is no longer effective to pass down inputs for all reactions. Instead, an array of ReactionInput is used:
struct ReactionInput {
TableInput tableInput;
// NOTE(kevin): with gpu, this pointer is only valid on the device.
const double *modelParams;
};
Just as TableInput, only pointers to model parameters are stored in ReactionInput. Actual parameters are stored in std::vector<mfem::Vector> M2ulPhyS.config.rxnModelParamsHost.
A simply sanity check test test/tabulated.test is included on cpu side.
TODO:
hdf5 format: currently does not read any attribute in the file. Some more functionalities such as unit conversion can be added, reading attributes from the hdf5 file.
high-order interpolation: a natural cubic spline interpolation algorithm is available (wikipedia), though it is observed that a natural cubic spline cannot avoid overshooting outside the data range. Other spline interpolation libraries are usually object-oriented, which classes cannot be easily incorporated into mfem gpu framework.
collision integrals also must support using tabulated data.
This PR sets a ground for using tabulated data in
M2ulPhyS
class.table
.struct TableInput
contains necessary information for using tabulated data:xdata
andfdata
point to the data. Currently bothxdata
andfdata
are only one-column array, therefore only supporting one-dimensional table.TableInterpolator
base class is initialized with the information inTableInput
.TableInterpolator::eval
evaluates the function value at given evaluation point, which is differently defined per derived class. Currently, onlyLinearTable
is available as a derived class.LinearTable
derived class supports simple linear interpolation (respecting the log scale options).h5ReadTable
reads the table intomfem::DenseMatrix
variable, and returns the size of the table.M2ulPhyS::readTable
reads the input options for the tabulated data, then reads the hdf5 file on the root rank usingh5ReadTable
. The data is stored asDenseMatrix
instd::vector<DenseMatrix> M2ulPhyS.config.tableHost
. EachDenseMatrix
is broadcast to all mpi ranks, and its device pointer is stored in aTableInput
struct, which can be used for objects in the device.This PR also supports reaction with tabulated rate data.
Tabulated
class is derived fromReaction
, having aTableInterpolator
pointer. Although onlyLinearTable
is available, any otherTableInterpolator
can be used once it is implemented.ChemistryInput.reactionModelParams
. Since nowTabulated
is available, this is no longer effective to pass down inputs for all reactions. Instead, an array ofReactionInput
is used:TableInput
, only pointers to model parameters are stored inReactionInput
. Actual parameters are stored instd::vector<mfem::Vector> M2ulPhyS.config.rxnModelParamsHost
.A simply sanity check test
test/tabulated.test
is included on cpu side.TODO:
mfem
gpu framework.