Hipace
Functions | Variables
Parser Namespace Reference

Functions

void addConstantsToParser ()
 add Physical constants to Parser constants More...
 
template<class T >
void replaceWithParser (amrex::ParmParse &pp, char const *const str)
 replace ParmParse input with a Parsed version More...
 
template<class T >
void replaceArrWithParser (amrex::ParmParse &pp, char const *const str)
 array version of replaceWithParser More...
 
void replaceAmrexParamsWithParser ()
 replace AMReX input parameters with Parsed version More...
 
void setDefaultParams ()
 set default ParmParse parameters before AMReX is initialized More...
 
int safeCastToInt (const double x, const std::string &real_name)
 return valid int, asserts if inf or NaN More...
 
amrex::Long safeCastToLong (const double x, const std::string &real_name)
 return valid Long, asserts if inf or NaN More...
 
void initParser (amrex::Parser &parser, amrex::Vector< std::string > const &varnames)
 init Parser ready to compile More...
 
void fillWithParser (std::string const &str, double &val)
 fill second argument val with a value obtained through Parsing str for std::string: val is same as str More...
 
void fillWithParser (std::string const &str, float &val)
 
void fillWithParser (std::string const &str, int &val)
 
void fillWithParser (std::string const &str, amrex::Long &val)
 
void fillWithParser (std::string const &str, bool &val)
 
void fillWithParser (std::string const &str, std::string &val, bool do_escape_backtransform=true)
 
template<class T >
void fillWithParserArr (std::vector< std::string > const &str_arr, T &val)
 fill second argument val of array type with a value obtained through Parsing str_arr if val is just a single value, str_arr is reduced to a single string with spaces as separators More...
 
template<class T >
void fillWithParserArr (std::vector< std::string > const &str_arr, std::vector< T > &val_arr)
 
template<class T >
void fillWithParserArr (std::vector< std::string > const &str_arr, amrex::Vector< T > &val_arr)
 
template<class T , std::size_t size>
void fillWithParserArr (std::vector< std::string > const &str_arr, std::array< T, size > &val_arr)
 
void fillWithParserArr (std::vector< std::string > const &str_arr, amrex::RealVect &val_arr)
 
void fillWithParserArr (std::vector< std::string > const &str_arr, amrex::IntVect &val_arr)
 

Variables

std::map< std::string, double > my_constants_cache {}
 
std::map< std::string, double > hipace_constants
 

Function Documentation

◆ addConstantsToParser()

void Parser::addConstantsToParser ( )
inline

add Physical constants to Parser constants

◆ fillWithParser() [1/6]

void Parser::fillWithParser ( std::string const &  str,
amrex::Long &  val 
)
inline

◆ fillWithParser() [2/6]

void Parser::fillWithParser ( std::string const &  str,
bool &  val 
)
inline

◆ fillWithParser() [3/6]

void Parser::fillWithParser ( std::string const &  str,
double &  val 
)
inline

fill second argument val with a value obtained through Parsing str for std::string: val is same as str

Parameters
[in]strexpression in string form
[out]valvalue parsed, can be double, float, int, bool or std::string

◆ fillWithParser() [4/6]

void Parser::fillWithParser ( std::string const &  str,
float &  val 
)
inline

◆ fillWithParser() [5/6]

void Parser::fillWithParser ( std::string const &  str,
int val 
)
inline

◆ fillWithParser() [6/6]

void Parser::fillWithParser ( std::string const &  str,
std::string &  val,
bool  do_escape_backtransform = true 
)
inline

◆ fillWithParserArr() [1/6]

void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
amrex::IntVect val_arr 
)
inline

◆ fillWithParserArr() [2/6]

void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
amrex::RealVect val_arr 
)
inline

◆ fillWithParserArr() [3/6]

template<class T >
void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
amrex::Vector< T > &  val_arr 
)
inline

◆ fillWithParserArr() [4/6]

template<class T , std::size_t size>
void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
std::array< T, size > &  val_arr 
)
inline

◆ fillWithParserArr() [5/6]

template<class T >
void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
std::vector< T > &  val_arr 
)
inline

◆ fillWithParserArr() [6/6]

template<class T >
void Parser::fillWithParserArr ( std::vector< std::string > const &  str_arr,
T &  val 
)
inline

fill second argument val of array type with a value obtained through Parsing str_arr if val is just a single value, str_arr is reduced to a single string with spaces as separators

Parameters
[in]str_arrvector of expressions to be parsed
[out]valvalue parsed, can be scalar, std::vector, amrex::Vector or std::array

◆ initParser()

void Parser::initParser ( amrex::Parser parser,
amrex::Vector< std::string > const &  varnames 
)
inline

init Parser ready to compile

Parameters
[in,out]parserParser that has been defined
[in]varnamesnames of input variables if a function is Parsed

◆ replaceAmrexParamsWithParser()

void Parser::replaceAmrexParamsWithParser ( )
inline

replace AMReX input parameters with Parsed version

AMReX only uses ParmParse when reading in these parameter, not a Parser

◆ replaceArrWithParser()

template<class T >
void Parser::replaceArrWithParser ( amrex::ParmParse pp,
char const *const  str 
)
inline

array version of replaceWithParser

Parameters
[in]ppParmParse object
[in]strname of input value to replace

◆ replaceWithParser()

template<class T >
void Parser::replaceWithParser ( amrex::ParmParse pp,
char const *const  str 
)
inline

replace ParmParse input with a Parsed version

Parameters
[in]ppParmParse object
[in]strname of input value to replace

◆ safeCastToInt()

int Parser::safeCastToInt ( const double  x,
const std::string &  real_name 
)
inline

return valid int, asserts if inf or NaN

Parameters
[in]xvalue to cast
[in]real_namename of value for error message

◆ safeCastToLong()

amrex::Long Parser::safeCastToLong ( const double  x,
const std::string &  real_name 
)
inline

return valid Long, asserts if inf or NaN

Parameters
[in]xvalue to cast
[in]real_namename of value for error message

◆ setDefaultParams()

void Parser::setDefaultParams ( )
inline

set default ParmParse parameters before AMReX is initialized

Variable Documentation

◆ hipace_constants

std::map< std::string, double > Parser::hipace_constants
Initial value:
{
{"pi", MathConst::pi},
{"true", 1},
{"false", 0}
}
static constexpr amrex::Real pi
Definition: Constants.H:30

◆ my_constants_cache

std::map< std::string, double > Parser::my_constants_cache {}