From 646a01f9bb6adf0b1483fadf755c6af012dc59eb Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 9 Jul 2018 14:46:44 -0500 Subject: [PATCH] Add integer -> Interpolation function --- src/endf.cpp | 45 ++++++++++++++++++++++++++------------------- src/endf.h | 2 ++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/endf.cpp b/src/endf.cpp index 6846db2ef3..ed23cc3366 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 2930e96481..e3fce4dfbb 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;