From 9cebb7d06fb10405c4422a606ca1e32dace0edbb Mon Sep 17 00:00:00 2001 From: Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com> Date: Tue, 16 Mar 2021 14:36:34 -0700 Subject: Boundary input - Periodic (#1730) * Read boundary and set periodicity, enumerate BC types, added support for periodic * eol * separate particle and field boudnary structs * Update comment for particle struct * the valid values are for field/particle * adding docs * eol * remove warning * add doc only for periodic * typo --- Source/Utils/WarpXAlgorithmSelection.cpp | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'Source/Utils/WarpXAlgorithmSelection.cpp') 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 MaxwellSolver_medium_algo_to_int = { const std::map MacroscopicSolver_algo_to_int = { {"backwardeuler", MacroscopicSolverAlgo::BackwardEuler}, {"laxwendroff", MacroscopicSolverAlgo::LaxWendroff}, - {"default", MacroscopicSolverAlgo::BackwardEuler}, + {"default", MacroscopicSolverAlgo::BackwardEuler} +}; + +const std::map FieldBCType_algo_to_int = { + {"pec", FieldBoundaryType::PEC}, + {"periodic", FieldBoundaryType::Periodic}, + {"pml", FieldBoundaryType::PML}, + {"pmc", FieldBoundaryType::PMC}, + {"default", FieldBoundaryType::PEC} +}; + +const std::map 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 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]; +} -- cgit v1.2.3