diff options
Diffstat (limited to 'Source/Utils/WarpXAlgorithmSelection.cpp')
-rw-r--r-- | Source/Utils/WarpXAlgorithmSelection.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index 76cdb4653..302060b1a 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -72,7 +72,23 @@ const std::map<std::string, int> MaxwellSolver_medium_algo_to_int = { const std::map<std::string, int> MacroscopicSolver_algo_to_int = { {"backwardeuler", MacroscopicSolverAlgo::BackwardEuler}, {"laxwendroff", MacroscopicSolverAlgo::LaxWendroff}, - {"default", MacroscopicSolverAlgo::BackwardEuler}, + {"default", MacroscopicSolverAlgo::BackwardEuler} +}; + +const std::map<std::string, int> FieldBCType_algo_to_int = { + {"pec", FieldBoundaryType::PEC}, + {"periodic", FieldBoundaryType::Periodic}, + {"pml", FieldBoundaryType::PML}, + {"pmc", FieldBoundaryType::PMC}, + {"default", FieldBoundaryType::PEC} +}; + +const std::map<std::string, int> ParticleBCType_algo_to_int = { + {"absorbing", ParticleBoundaryType::Absorbing}, + {"open", ParticleBoundaryType::Open}, + {"reflecting", ParticleBoundaryType::Reflecting}, + {"periodic", ParticleBoundaryType::Periodic}, + {"default", ParticleBoundaryType::Absorbing} }; int @@ -128,3 +144,24 @@ GetAlgorithmInteger( amrex::ParmParse& pp, const char* pp_search_key ){ // If the input is a valid key, return the value return algo_to_int[algo]; } + +int +GetBCTypeInteger( std::string BCType, bool field ){ + std::transform(BCType.begin(), BCType.end(), BCType.begin(), ::tolower); + + std::map<std::string, int> BCType_to_int; + + if (field) BCType_to_int = FieldBCType_algo_to_int; // set field boundary + else BCType_to_int = ParticleBCType_algo_to_int; // set particle boundary + + if (BCType_to_int.count(BCType) == 0) { + std::string error_message = "Invalid string for field/particle BC. : " + BCType + "\nThe valid values are : \n"; + for (const auto &valid_pair : BCType_to_int) { + if (valid_pair.first != "default"){ + error_message += " - " + valid_pair.first + "\n"; + } + } + amrex::Abort(error_message); + } + return BCType_to_int[BCType]; +} |