mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Add integer -> Interpolation function
This commit is contained in:
parent
6f04f9ce2c
commit
646a01f9bb
2 changed files with 28 additions and 19 deletions
45
src/endf.cpp
45
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<double> arr;
|
||||
read_dataset(dset, arr);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
Interpolation int2interp(int i);
|
||||
|
||||
class Function1D {
|
||||
public:
|
||||
virtual double operator()(double x) const = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue