diff --git a/src/endf.cpp b/src/endf.cpp index 6846db2ef..ed23cc336 100644 --- a/src/endf.cpp +++ b/src/endf.cpp @@ -12,6 +12,26 @@ namespace openmc { +Interpolation int2interp(int i) +{ + switch (i) { + case 1: + return Interpolation::histogram; + case 2: + return Interpolation::lin_lin; + case 3: + return Interpolation::lin_log; + case 4: + return Interpolation::log_lin; + case 5: + return Interpolation::log_log; + } +} + +//============================================================================== +// Polynomial implementation +//============================================================================== + Polynomial::Polynomial(hid_t dset) { // Read coefficients into a vector @@ -29,6 +49,10 @@ double Polynomial::operator()(double x) const return y; } +//============================================================================== +// Tabulated1D implementation +//============================================================================== + Tabulated1D::Tabulated1D(hid_t dset) { read_attribute(dset, "breakpoints", nbt_); @@ -41,25 +65,8 @@ Tabulated1D::Tabulated1D(hid_t dset) read_attribute(dset, "interpolation", int_temp); // Convert vector of ints into Interpolation - for (const auto i : int_temp) { - switch (i) { - case 1: - int_.push_back(Interpolation::histogram); - break; - case 2: - int_.push_back(Interpolation::lin_lin); - break; - case 3: - int_.push_back(Interpolation::lin_log); - break; - case 4: - int_.push_back(Interpolation::log_lin); - break; - case 5: - int_.push_back(Interpolation::log_log); - break; - } - } + for (const auto i : int_temp) + int_.push_back(int2interp(i)); xt::xarray arr; read_dataset(dset, arr); diff --git a/src/endf.h b/src/endf.h index 2930e9648..e3fce4dfb 100644 --- a/src/endf.h +++ b/src/endf.h @@ -8,6 +8,8 @@ namespace openmc { +Interpolation int2interp(int i); + class Function1D { public: virtual double operator()(double x) const = 0;