diff options
author | 2022-05-24 17:57:51 -0700 | |
---|---|---|
committer | 2022-05-24 17:57:51 -0700 | |
commit | 0344c42e27c61b286e885889028c7f77725e7f74 (patch) | |
tree | ec116dbe570b342c7df3da3e6d620cbdd4032db5 /Source/Utils/WarpXUtil.cpp | |
parent | a681d1994aa5748d4faceb658199c1a61d418a79 (diff) | |
download | WarpX-0344c42e27c61b286e885889028c7f77725e7f74.tar.gz WarpX-0344c42e27c61b286e885889028c7f77725e7f74.tar.zst WarpX-0344c42e27c61b286e885889028c7f77725e7f74.zip |
Specify particle precision (#3065)
* Add precision to printed PIC parameters
* Added WarpX_PARTICLE_PRECISION as a build option
* Update types to ParticleReal
* Updated libwarpx to inject particles with correct ParticleReal type
* Fix syntax error
* Add logic to avoid duplicate definitions
* Use correct ParticleReal type in add_particles
* Cleaned up code, addressed comments
* Update Python/pywarpx/_libwarpx.py
Co-authored-by: Peter Scherpelz <31747262+peterscherpelz@users.noreply.github.com>
* Removed redundant functions, fixed some typing
* Modified template functions
* Cast d_w to Real
* Fixed failing tests
* Cast types to be consistent
* removed in-tree-build from pip command
* Added GPU device macros to PDim3 methods
* rerun tests
* Removed unecessary casting, update calls to use PDim3 instead of XDim3
* Refactored comments
* Added mcc fields double precision, particles single precision test
* Updated casting and formatting
* Removed cast, updated declaration
Co-authored-by: Peter Scherpelz <peter.scherpelz@modernelectron.com>
Co-authored-by: Peter Scherpelz <31747262+peterscherpelz@users.noreply.github.com>
Diffstat (limited to 'Source/Utils/WarpXUtil.cpp')
-rw-r--r-- | Source/Utils/WarpXUtil.cpp | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index 9ab96873a..afe8b7daa 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -388,135 +388,6 @@ parseStringtoInt(std::string str, std::string name) return ival; } -// Overloads for float/double instead of amrex::Real to allow makeParser() to query for -// my_constants as double even in single precision mode -// Always parsing in double precision avoids potential overflows that may occur when parsing user's -// expressions because of the limited range of exponentials in single precision -int -queryWithParser (const amrex::ParmParse& a_pp, char const * const str, float& val) -{ - // call amrex::ParmParse::query, check if the user specified str. - std::string tmp_str; - int is_specified = a_pp.query(str, tmp_str); - if (is_specified) - { - // If so, create a parser object and apply it to the value provided by the user. - std::string str_val; - Store_parserString(a_pp, str, str_val); - val = static_cast<float>(parseStringtoReal(str_val)); - } - // return the same output as amrex::ParmParse::query - return is_specified; -} - -void -getWithParser (const amrex::ParmParse& a_pp, char const * const str, float& val) -{ - // If so, create a parser object and apply it to the value provided by the user. - std::string str_val; - Store_parserString(a_pp, str, str_val); - val = static_cast<float>(parseStringtoReal(str_val)); -} - -int -queryWithParser (const amrex::ParmParse& a_pp, char const * const str, double& val) -{ - // call amrex::ParmParse::query, check if the user specified str. - std::string tmp_str; - int is_specified = a_pp.query(str, tmp_str); - if (is_specified) - { - // If so, create a parser object and apply it to the value provided by the user. - std::string str_val; - Store_parserString(a_pp, str, str_val); - val = parseStringtoReal(str_val); - } - // return the same output as amrex::ParmParse::query - return is_specified; -} - -void -getWithParser (const amrex::ParmParse& a_pp, char const * const str, double& val) -{ - // If so, create a parser object and apply it to the value provided by the user. - std::string str_val; - Store_parserString(a_pp, str, str_val); - val = parseStringtoReal(str_val); -} - -int -queryArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<amrex::Real>& val, - const int start_ix, const int num_val) -{ - // call amrex::ParmParse::query, check if the user specified str. - std::vector<std::string> tmp_str_arr; - int is_specified = a_pp.queryarr(str, tmp_str_arr, start_ix, num_val); - if (is_specified) - { - // If so, create parser objects and apply them to the values provided by the user. - int const n = static_cast<int>(tmp_str_arr.size()); - val.resize(n); - for (int i=0 ; i < n ; i++) { - val[i] = static_cast<amrex::Real>(parseStringtoReal(tmp_str_arr[i])); - } - } - // return the same output as amrex::ParmParse::query - return is_specified; -} - -void -getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<amrex::Real>& val, - const int start_ix, const int num_val) -{ - // Create parser objects and apply them to the values provided by the user. - std::vector<std::string> tmp_str_arr; - a_pp.getarr(str, tmp_str_arr, start_ix, num_val); - - int const n = static_cast<int>(tmp_str_arr.size()); - val.resize(n); - for (int i=0 ; i < n ; i++) { - val[i] = static_cast<amrex::Real>(parseStringtoReal(tmp_str_arr[i])); - } -} - -int queryWithParser (const amrex::ParmParse& a_pp, char const * const str, int& val) { - amrex::Real rval; - const int result = queryWithParser(a_pp, str, rval); - if (result) { - val = safeCastToInt(std::round(rval), str); - } - return result; -} - -void getWithParser (const amrex::ParmParse& a_pp, char const * const str, int& val) { - amrex::Real rval; - getWithParser(a_pp, str, rval); - val = safeCastToInt(std::round(rval), str); -} - -int queryArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<int>& val, - const int start_ix, const int num_val) { - std::vector<amrex::Real> rval; - const int result = queryArrWithParser(a_pp, str, rval, start_ix, num_val); - if (result) { - val.resize(rval.size()); - for (unsigned long i = 0 ; i < val.size() ; i++) { - val[i] = safeCastToInt(std::round(rval[i]), str); - } - } - return result; -} - -void getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<int>& val, - const int start_ix, const int num_val) { - std::vector<amrex::Real> rval; - getArrWithParser(a_pp, str, rval, start_ix, num_val); - val.resize(rval.size()); - for (unsigned long i = 0 ; i < val.size() ; i++) { - val[i] = safeCastToInt(std::round(rval[i]), str); - } -} - void CheckDims () { // Ensure that geometry.dims is set properly. |