Create [simple] Tabulated1D with x and y vectors

Allow the creation of openmc::Tabulated1D objects using
x and y vectors. The implementation is simple and does not
handle any breakpoints, assuming all y data can be linearly
interpolated.
This commit is contained in:
Andrew Johnson 2019-09-09 17:03:11 -05:00
parent 998a41fff3
commit 3a72bcfb10
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
2 changed files with 16 additions and 0 deletions

View file

@ -81,6 +81,12 @@ public:
//! \param[in] dset Dataset containing tabulated data
explicit Tabulated1D(hid_t dset);
//! Construct using x and y data
//! \param[in] x independent variable
//! \param[in] y dependent variable to be interpolated
//! Assumes no breakpoints with linear interpolation
Tabulated1D(std::vector<double> x, std::vector<double> y);
//! Evaluate the tabulated function
//! \param[in] x independent variable
//! \return Function evaluated at x

View file

@ -151,6 +151,16 @@ Tabulated1D::Tabulated1D(hid_t dset)
n_pairs_ = x_.size();
}
Tabulated1D::Tabulated1D(std::vector<double> x, std::vector<double> y)
{
x_ = x;
y_ = y;
n_pairs_ = x.size();
int_.push_back(Interpolation::lin_lin);
nbt_.push_back(x.size());
n_regions_ = 1;
}
double Tabulated1D::operator()(double x) const
{
// find which bin the abscissa is in -- if the abscissa is outside the