diff options
author | 2021-10-12 02:39:58 +0200 | |
---|---|---|
committer | 2021-10-11 17:39:58 -0700 | |
commit | 5a12391f0c2350e9083bf3138da210eb81707e6e (patch) | |
tree | 5755fcbc17dfd120e2f3ad8fd019de7b15aca24f /Source/Utils/WarpXUtil.cpp | |
parent | d367eb0c15c36baf390d0c9ec7bc068fe25490b7 (diff) | |
download | WarpX-5a12391f0c2350e9083bf3138da210eb81707e6e.tar.gz WarpX-5a12391f0c2350e9083bf3138da210eb81707e6e.tar.zst WarpX-5a12391f0c2350e9083bf3138da210eb81707e6e.zip |
Use parser for more input parameters (#2386)
* Use parser for more input parameters
* Fix PSATD compilation and apply suggestions from code review
* Avoid out of bound array access for num_particles_per_cell_each_dim
* Fix few input files with respect to num_particles_per_cell_each_dim
* Fix get that incorrectly became query
Diffstat (limited to 'Source/Utils/WarpXUtil.cpp')
-rw-r--r-- | Source/Utils/WarpXUtil.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index d92f75b9e..64b30a9b1 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -455,20 +455,6 @@ queryArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::v } void -getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<amrex::Real>& 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); - - int const n = static_cast<int>(tmp_str_arr.size()); - val.resize(n); - for (int i=0 ; i < n ; i++) { - val[i] = parseStringtoReal(tmp_str_arr[i]); - } -} - -void getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<amrex::Real>& val, const int start_ix, const int num_val) { @@ -511,15 +497,6 @@ int queryArrWithParser (const amrex::ParmParse& a_pp, char const * const str, st return result; } -void getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std::vector<int>& val) { - std::vector<amrex::Real> rval; - getArrWithParser(a_pp, str, rval); - val.resize(rval.size()); - for (unsigned long i = 0 ; i < val.size() ; i++) { - val[i] = safeCastToInt(std::round(rval[i]), str); - } -} - 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; @@ -564,7 +541,7 @@ void CheckGriddingForRZSpectral () ParmParse pp_amr("amr"); pp_amr.get("max_level",max_level); - pp_amr.getarr("n_cell",n_cell,0,AMREX_SPACEDIM); + pp_amr.getarr("n_cell", n_cell, 0, AMREX_SPACEDIM); Vector<int> blocking_factor_x(max_level+1); Vector<int> max_grid_size_x(max_level+1); @@ -596,8 +573,8 @@ void CheckGriddingForRZSpectral () // Get the longitudinal blocking factor in case it was set by the user. // If not set, use the default value of 8. Vector<int> bf; - pp_amr.queryarr("blocking_factor",bf); - pp_amr.queryarr("blocking_factor_y",bf); + pp_amr.queryarr("blocking_factor", bf); + pp_amr.queryarr("blocking_factor_y", bf); bf.resize(std::max(static_cast<int>(bf.size()),1),8); // Modify the default or any user input, making sure that the blocking factor @@ -611,8 +588,8 @@ void CheckGriddingForRZSpectral () // Get the longitudinal max grid size in case it was set by the user. // If not set, use the default value of 128. Vector<int> mg; - pp_amr.queryarr("max_grid_size",mg); - pp_amr.queryarr("max_grid_size_y",mg); + pp_amr.queryarr("max_grid_size", mg); + pp_amr.queryarr("max_grid_size_y", mg); mg.resize(std::max(static_cast<int>(mg.size()),1),128); // Modify the default or any user input, making sure that the max grid size |