37#ifndef NUMERIC_INTERPOLATOR_LINEAR_H_
38#define NUMERIC_INTERPOLATOR_LINEAR_H_
41#include <AMReX_MultiFab.H>
66 define(a_str, unit_time, unit_data);
68 Linear(
const std::vector<T> _data_points,
const std::vector<Set::Scalar> _interval_points)
70 define(_data_points,_interval_points);
75 std::string str = a_str;
86 std::string str_time = splitstr[0];
87 std::string str_val = splitstr[1];
92 if (str_time_arr.size() != str_val_arr.size())
Util::Abort(
INFO,
"Mismatched number of time values vs array values while trying to parse ", str);
94 for (
unsigned int i = 0; i < str_time_arr.size(); i++)
114 void define(
const std::vector<T> _data_points,
const std::vector<Set::Scalar> _interval_points)
119 Util::Abort(
INFO,
"Data points and interval points have different sizes");
139 start = std::max(start,0);
164 value.
define(in, unit_time, unit_value);
184 for (
unsigned int i = 0; i < b.
data_points.size(); i++)
196 input.open(filename);
198 std::vector<Set::Scalar> theta, w;
200 while (std::getline(input, line))
202 theta.push_back(std::stof(dat[0]));
203 w.push_back(std::stof(dat[1]));
209 else if (derivative == 1)
211 std::vector<Set::Scalar> thetasmall, dw;
212 for (
unsigned int i = 1; i < theta.size() - 1; i++)
214 thetasmall.push_back(theta[i]);
215 dw.push_back((w[i + 1] - w[i - 1]) / (theta[i + 1] - theta[i - 1]));
219 else if (derivative == 2)
221 std::vector<Set::Scalar> thetasmall, ddw;
222 for (
unsigned int i = 1; i < theta.size() - 1; i++)
224 thetasmall.push_back(theta[i]);
225 ddw.push_back((w[i + 1] - 2.0 * w[i] + w[i - 1]) / ((theta[i + 1] - theta[i]) * (theta[i] - theta[i - 1])));
#define ALAMO_SINGLE_DEFINITION
T operator()(const Set::Scalar point) const
std::vector< T > data_points
friend Linear< U > operator*(const Set::Scalar alpha, const Linear< U > &b)
static void Parse(Linear< T > &value, IO::ParmParse &pp, Unit unit_time=Unit::Less(), Unit unit_value=Unit::Less())
void define(const std::vector< T > _data_points, const std::vector< Set::Scalar > _interval_points)
static Linear< T > Read(std::string filename, int derivative=0)
void define(const std::string a_str, Unit a_unit_time, Unit a_unit_val)
Linear(const std::vector< T > _data_points, const std::vector< Set::Scalar > _interval_points)
std::vector< Set::Scalar > interval_points
Linear(const std::string a_str, Unit unit_time=Unit::Less(), Unit unit_data=Unit::Less())
Linear(const Set::Scalar &a_val)
AMREX_FORCE_INLINE Linear< T > operator*(const Set::Scalar alpha, const Linear< T > &b)
This namespace contains some numerical tools.
AMREX_FORCE_INLINE int ReplaceAll(std::string &str, const std::string before, const std::string after)
AMREX_FORCE_INLINE bool Contains(std::string &str, const std::string find)
AMREX_FORCE_INLINE std::vector< std::string > Split(std::string &str, const char delim=' ')
void Abort(const char *msg)
void Exception(std::string file, std::string func, int line, Args const &... args)
bool isType(const Unit &test) const
double normalized_value() const
static Unit Parse(double val, std::string unitstring)