diff options
author | 2020-12-02 09:43:11 +0100 | |
---|---|---|
committer | 2020-12-02 00:43:11 -0800 | |
commit | 2fbb92dca17e624c6d3c4f51caa412a585b10c32 (patch) | |
tree | c6b5e4534e65d0cb487061e6108419a7d4fe23a1 /Source/Utils/WarpXUtil.H | |
parent | 330c6c56ea64a3f4183483f529e66f59aff8f92d (diff) | |
download | WarpX-2fbb92dca17e624c6d3c4f51caa412a585b10c32.tar.gz WarpX-2fbb92dca17e624c6d3c4f51caa412a585b10c32.tar.zst WarpX-2fbb92dca17e624c6d3c4f51caa412a585b10c32.zip |
More parser-enabled ParmParse.query and ParmParse.get (#1501)
* Parser can be used for most input parameters, including charge and mass
* update documentation for the math parser
* eol
* remove typo and update doc for parser
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Utils/WarpXUtil.H')
-rw-r--r-- | Source/Utils/WarpXUtil.H | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Source/Utils/WarpXUtil.H b/Source/Utils/WarpXUtil.H index e5a01a44a..d72ed683b 100644 --- a/Source/Utils/WarpXUtil.H +++ b/Source/Utils/WarpXUtil.H @@ -42,7 +42,7 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, * \param query_string ParmParse.query will look for this string * \param stored_string variable in which the string to parse is stored */ -void Store_parserString(amrex::ParmParse &pp, std::string query_string, +void Store_parserString(const amrex::ParmParse &pp, std::string query_string, std::string& stored_string); namespace WarpXUtilIO{ @@ -173,7 +173,21 @@ WarpXParser makeParser (std::string const& parse_function, std::vector<std::stri * \param[in] str name of the parameter to read * \param[out] val where the value queried and parsed is stored */ -int queryWithParser (amrex::ParmParse& a_pp, char const * const str, amrex::Real& val); +int queryWithParser (const amrex::ParmParse& a_pp, char const * const str, amrex::Real& val); + +/** + * \brief Similar to amrex::ParmParse::get, but also supports math expressions for the value. + * + * amrex::ParmParse::get reads a name and a value from the input file. This function does the + * same, and applies the WarpXParser to the value, so the user has the choice to specify a value or + * a math expression (including user-defined constants). + * Only works for amrex::Real numbers, one would need another version for integers etc. + * + * \param[in] a_pp amrex::ParmParse object + * \param[in] str name of the parameter to read + * \param[out] val where the value queried and parsed is stored + */ +void getWithParser (const amrex::ParmParse& a_pp, char const * const str, amrex::Real& val); namespace WarpXUtilMsg{ |