9 #ifndef WARPX_UTILS_PARSER_PARSERUTILS_H_
10 #define WARPX_UTILS_PARSER_PARSERUTILS_H_
19 #include <type_traits>
54 std::string
const& parse_function,
68 std::string query_string,
69 std::string& stored_string);
99 return parser->compile<N>();
117 template <
typename T>
122 const int is_specified = a_pp.
query(
str, tmp_str);
134 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
137 val =
static_cast<T
>(
parser.compileHost<0>()());
145 template <
typename T>
149 std::vector<std::string> tmp_str_arr;
150 const int is_specified = a_pp.
queryarr(
str, tmp_str_arr);
154 int const n =
static_cast<int>(tmp_str_arr.size());
156 for (
int i=0 ;
i <
n ;
i++) {
160 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
163 val[
i] =
static_cast<T
>(
parser.compileHost<0>()());
187 template <
typename T>
189 const int start_ix,
const int num_val)
192 std::vector<std::string> tmp_str_arr;
193 const int is_specified = a_pp.
queryarr(
str, tmp_str_arr, start_ix, num_val);
197 int const n =
static_cast<int>(tmp_str_arr.size());
199 for (
int i=0 ;
i <
n ;
i++) {
203 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
206 val[
i] =
static_cast<T
>(
parser.compileHost<0>()());
226 template <
typename T>
236 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
239 val =
static_cast<T
>(
parser.compileHost<0>()());
243 template <
typename T>
247 std::vector<std::string> tmp_str_arr;
250 int const n =
static_cast<int>(tmp_str_arr.size());
252 for (
int i=0 ;
i <
n ;
i++) {
256 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
259 val[
i] =
static_cast<T
>(
parser.compileHost<0>()());
280 template <
typename T>
282 const int start_ix,
const int num_val)
285 std::vector<std::string> tmp_str_arr;
286 a_pp.
getarr(
str, tmp_str_arr, start_ix, num_val);
288 int const n =
static_cast<int>(tmp_str_arr.size());
290 for (
int i=0 ;
i <
n ;
i++) {
294 static_cast<amrex::Real
>(std::round(
parser.compileHost<0>()())),
str);
297 val[
i] =
static_cast<T
>(
parser.compileHost<0>()());
int queryarr(const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
void getarr(const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
int query(const char *name, bool &ref, int ival=FIRST) const
i
Definition: check_interp_points_and_weights.py:174
str
Definition: run_alltests_1node.py:72
name
Definition: run_automated.py:229
int n
Definition: run_libensemble_on_warpx.py:70
parser
Definition: stencil.py:411
value
Definition: updateAMReX.py:141
Definition: IntervalsParser.H:17
int queryArrWithParser(const amrex::ParmParse &a_pp, char const *const str, std::vector< T > &val)
Definition: ParserUtils.H:146
int safeCastToInt(amrex::Real x, const std::string &real_name)
Do a safe cast of a real to an int This ensures that the float value is within the range of ints and ...
Definition: ParserUtils.cpp:69
amrex::Parser makeParser(std::string const &parse_function, amrex::Vector< std::string > const &varnames)
Initialize an amrex::Parser object from a string containing a math expression.
Definition: ParserUtils.cpp:79
long safeCastToLong(amrex::Real x, const std::string &real_name)
Do a safe cast of a real to a long This ensures that the float value is within the range of longs and...
Definition: ParserUtils.cpp:74
int parseStringtoInt(const std::string &str, const std::string &name)
Definition: ParserUtils.cpp:161
double parseStringtoDouble(const std::string &str)
Definition: ParserUtils.cpp:151
void getWithParser(const amrex::ParmParse &a_pp, char const *const str, T &val)
Definition: ParserUtils.H:227
void Store_parserString(const amrex::ParmParse &pp, std::string query_string, std::string &stored_string)
Parse a string (typically a mathematical expression) from the input file and store it into a variable...
Definition: ParserUtils.cpp:21
amrex::ParserExecutor< N > compileParser(amrex::Parser const *parser)
Definition: ParserUtils.H:96
void getArrWithParser(const amrex::ParmParse &a_pp, char const *const str, std::vector< T > &val)
Definition: ParserUtils.H:244
int queryWithParser(const amrex::ParmParse &a_pp, char const *const str, T &val)
Definition: ParserUtils.H:118