aboutsummaryrefslogtreecommitdiff
path: root/Source/Utils/WarpXAlgorithmSelection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Utils/WarpXAlgorithmSelection.cpp')
-rw-r--r--Source/Utils/WarpXAlgorithmSelection.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp
index e73d3e30e..e250a92c1 100644
--- a/Source/Utils/WarpXAlgorithmSelection.cpp
+++ b/Source/Utils/WarpXAlgorithmSelection.cpp
@@ -90,7 +90,7 @@ const std::map<std::string, int> FieldBCType_algo_to_int = {
{"default", FieldBoundaryType::PML}
};
-const std::map<std::string, int> ParticleBCType_algo_to_int = {
+const std::map<std::string, ParticleBoundaryType> ParticleBCType_algo_to_enum = {
{"absorbing", ParticleBoundaryType::Absorbing},
{"open", ParticleBoundaryType::Open},
{"reflecting", ParticleBoundaryType::Reflecting},
@@ -161,22 +161,35 @@ GetAlgorithmInteger( amrex::ParmParse& pp, const char* pp_search_key ){
}
int
-GetBCTypeInteger( std::string BCType, bool field ){
+GetFieldBCTypeInteger( std::string BCType ){
std::transform(BCType.begin(), BCType.end(), BCType.begin(), ::tolower);
- std::map<std::string, int> BCType_to_int;
+ if (FieldBCType_algo_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 : FieldBCType_algo_to_int) {
+ if (valid_pair.first != "default"){
+ error_message += " - " + valid_pair.first + "\n";
+ }
+ }
+ amrex::Abort(error_message);
+ }
+ // return FieldBCType_algo_to_int[BCType]; // This operator cannot be used for a const map
+ return FieldBCType_algo_to_int.at(BCType);
+}
- if (field) BCType_to_int = FieldBCType_algo_to_int; // set field boundary
- else BCType_to_int = ParticleBCType_algo_to_int; // set particle boundary
+ParticleBoundaryType
+GetParticleBCTypeInteger( std::string BCType ){
+ std::transform(BCType.begin(), BCType.end(), BCType.begin(), ::tolower);
- 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 (ParticleBCType_algo_to_enum.count(BCType) == 0) {
+ std::string error_message = "Invalid string for particle BC. : " + BCType + "\nThe valid values are : \n";
+ for (const auto &valid_pair : ParticleBCType_algo_to_enum) {
if (valid_pair.first != "default"){
error_message += " - " + valid_pair.first + "\n";
}
}
amrex::Abort(error_message);
}
- return BCType_to_int[BCType];
+ // return ParticleBCType_algo_to_enum[BCType]; // This operator cannot be used for a const map
+ return ParticleBCType_algo_to_enum.at(BCType);
}