diff options
Diffstat (limited to 'Source/Utils')
-rw-r--r-- | Source/Utils/Make.package | 1 | ||||
-rw-r--r-- | Source/Utils/WarpXConst.H | 13 | ||||
-rw-r--r-- | Source/Utils/WarpXConst.cpp | 61 |
3 files changed, 0 insertions, 75 deletions
diff --git a/Source/Utils/Make.package b/Source/Utils/Make.package index 8cd124ea3..d8e2d2dab 100644 --- a/Source/Utils/Make.package +++ b/Source/Utils/Make.package @@ -1,6 +1,5 @@ F90EXE_sources += utils_ES.F90 CEXE_sources += WarpXMovingWindow.cpp -CEXE_sources += WarpXConst.cpp CEXE_sources += WarpXTagging.cpp CEXE_sources += WarpXUtil.cpp CEXE_headers += WarpXConst.H diff --git a/Source/Utils/WarpXConst.H b/Source/Utils/WarpXConst.H index fdb92f666..4e226e55f 100644 --- a/Source/Utils/WarpXConst.H +++ b/Source/Utils/WarpXConst.H @@ -19,17 +19,4 @@ namespace MathConst static constexpr amrex::Real pi = 3.14159265358979323846; } -class UserConstants{ -public: - std::vector<std::string> constant_names; - std::vector<amrex::Real> constant_values; - - int nb_constants=0; - std::string replaceStringValue(std::string); - void ReadParameters(); -private: - bool initialized = false; - bool use_my_constants = false; -}; - #endif diff --git a/Source/Utils/WarpXConst.cpp b/Source/Utils/WarpXConst.cpp deleted file mode 100644 index bd3ebc3ef..000000000 --- a/Source/Utils/WarpXConst.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include <limits> -#include <cmath> -#include <algorithm> -#include <numeric> -#include <sstream> - -#include <AMReX_ParmParse.H> -#include <WarpX.H> -#include <WarpXConst.H> -#include <WarpX_f.H> -#include <MultiParticleContainer.H> - -std::string UserConstants::replaceStringValue(std::string math_expr){ - std::string pattern, value_str; - std::string patternexp = "e+"; - std::size_t found; - amrex::Real value; - for (int i=0; i<nb_constants; i++){ - pattern = constant_names[i]; - value = constant_values[i]; - - // Convert value to string, with scientific notation - std::ostringstream streamObj; - streamObj << value; - value_str = streamObj.str(); - - // Replace "e+" by "e" in scientific notation for Fortran compatibility - found = value_str.find(patternexp); - if (found != std::string::npos){ - value_str.replace(found,patternexp.length(),"e"); - } - - // Replace all occurences of variable pattern by a string with its value value_str - found = math_expr.find(pattern); - while (found != std::string::npos){ - if ((found==0 - && !isalnum(math_expr[pattern.length() ])) || - (!isalnum(math_expr[found-1]) - && !isalnum(math_expr[found+pattern.length()]))){ - math_expr.replace(found,pattern.length(),value_str); - } - found = math_expr.find(pattern, found + pattern.length()); - } - } - return math_expr; -} - -void UserConstants::ReadParameters() -{ - if (!initialized){ - amrex::ParmParse pp("constants"); - pp.query("use_my_constants", use_my_constants); - if (use_my_constants){ - pp.getarr("constant_names", constant_names); - nb_constants = constant_names.size(); - pp.getarr("constant_values", constant_values); - BL_ASSERT(constant_values.size() == nb_constants); - } - initialized = true; - } -} |