37#ifndef NUMERIC_INTERPOLATOR_LINEAR_H_
38#define NUMERIC_INTERPOLATOR_LINEAR_H_
41#include <AMReX_MultiFab.H>
66 Linear(
const std::vector<T> _data_points,
const std::vector<Set::Scalar> _interval_points)
68 define(_data_points,_interval_points);
73 std::string str = a_str;
84 std::string str_time = splitstr[0];
85 std::string str_val = splitstr[1];
90 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);
92 for (
unsigned int i = 0; i < str_time_arr.size(); i++)
106 void define(
const std::vector<T> _data_points,
const std::vector<Set::Scalar> _interval_points)
111 Util::Abort(
INFO,
"Data points and interval points have different sizes");
131 start = std::max(start,0);
176 for (
unsigned int i = 0; i < b.
data_points.size(); i++)
188 input.open(filename);
190 std::vector<Set::Scalar> theta, w;
192 while (std::getline(input, line))
194 theta.push_back(std::stof(dat[0]));
195 w.push_back(std::stof(dat[1]));
201 else if (derivative == 1)
203 std::vector<Set::Scalar> thetasmall, dw;
204 for (
unsigned int i = 1; i < theta.size() - 1; i++)
206 thetasmall.push_back(theta[i]);
207 dw.push_back((w[i + 1] - w[i - 1]) / (theta[i + 1] - theta[i - 1]));
211 else if (derivative == 2)
213 std::vector<Set::Scalar> thetasmall, ddw;
214 for (
unsigned int i = 1; i < theta.size() - 1; i++)
216 thetasmall.push_back(theta[i]);
217 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
static void Parse(Linear< T > &value, IO::ParmParse &pp)
T operator()(const Set::Scalar point) const
void define(const std::string a_str)
std::vector< T > data_points
friend Linear< U > operator*(const Set::Scalar alpha, const Linear< U > &b)
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)
Linear(const std::string a_str)
Linear(const std::vector< T > _data_points, const std::vector< Set::Scalar > _interval_points)
std::vector< Set::Scalar > interval_points
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.
bool Contains(std::string &str, const std::string find)
std::vector< std::string > Split(std::string &str, const char delim)
int ReplaceAll(std::string &str, const std::string before, const std::string after)
void Abort(const char *msg)