aboutsummaryrefslogtreecommitdiff
path: root/Source/Utils
diff options
context:
space:
mode:
authorGravatar Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2023-03-08 20:52:56 -0800
committerGravatar GitHub <noreply@github.com> 2023-03-09 04:52:56 +0000
commit03b2fe60ff49748aaff8402824ea0457eef24d5c (patch)
tree1f29cb899516a03eecc5babd9e9a65f84a8f7dd4 /Source/Utils
parent92013ab8403512a0d42ee3ba49f474b72d1ed88f (diff)
downloadWarpX-03b2fe60ff49748aaff8402824ea0457eef24d5c.tar.gz
WarpX-03b2fe60ff49748aaff8402824ea0457eef24d5c.tar.zst
WarpX-03b2fe60ff49748aaff8402824ea0457eef24d5c.zip
New user input for grid type (collocated, staggered, hybrid) (#3683)
* Introduce `warpx.grid_type` parameter * Replace `or` with `||` * Update examples with new user input syntax * Fix `if` condition * Improve error message * Fix `if` condition * Fix bugs * Fix warning * Fix RZ * Debugging * Fix RZ * Fix bug * Clean up * More changes: - set default algo parameters with hybrid grid - all hybrid input parameters under warpx name * Set default field gathering algo for hybrid grids * Update documentation
Diffstat (limited to 'Source/Utils')
-rw-r--r--Source/Utils/RelativeCellPosition.cpp2
-rw-r--r--Source/Utils/WarpXAlgorithmSelection.H8
-rw-r--r--Source/Utils/WarpXAlgorithmSelection.cpp9
3 files changed, 18 insertions, 1 deletions
diff --git a/Source/Utils/RelativeCellPosition.cpp b/Source/Utils/RelativeCellPosition.cpp
index 55e933af0..1a108b54b 100644
--- a/Source/Utils/RelativeCellPosition.cpp
+++ b/Source/Utils/RelativeCellPosition.cpp
@@ -19,7 +19,7 @@ utils::getRelativeCellPosition(amrex::MultiFab const& mf)
// amrex::CellIndex::CELL means: 0.5 from lower corner for that index/direction
// amrex::CellIndex::NODE means: at corner for that index/direction
- // WarpX::do_nodal means: all indices/directions on CellIndex::NODE
+ // WarpX::grid_type==GridType::Collocated means: all indices/directions on CellIndex::NODE
for (int d = 0; d < AMREX_SPACEDIM; d++)
{
if (idx_type.cellCentered(d))
diff --git a/Source/Utils/WarpXAlgorithmSelection.H b/Source/Utils/WarpXAlgorithmSelection.H
index fe90cb196..d0d8678f5 100644
--- a/Source/Utils/WarpXAlgorithmSelection.H
+++ b/Source/Utils/WarpXAlgorithmSelection.H
@@ -36,6 +36,14 @@ struct MacroscopicSolverAlgo {
};
};
+struct GridType {
+ enum {
+ Collocated = 0,
+ Staggered = 1,
+ Hybrid = 2
+ };
+};
+
struct ElectromagneticSolverAlgo {
enum {
None = 0,
diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp
index d3b5f5e43..99c068fc0 100644
--- a/Source/Utils/WarpXAlgorithmSelection.cpp
+++ b/Source/Utils/WarpXAlgorithmSelection.cpp
@@ -22,6 +22,13 @@
// Define dictionary with correspondance between user-input strings,
// and corresponding integer for use inside the code
+const std::map<std::string, int> grid_to_int = {
+ {"collocated", GridType::Collocated},
+ {"staggered", GridType::Staggered},
+ {"hybrid", GridType::Hybrid},
+ {"default", GridType::Staggered}
+};
+
const std::map<std::string, int> electromagnetic_solver_algo_to_int = {
{"none", ElectromagneticSolverAlgo::None },
{"yee", ElectromagneticSolverAlgo::Yee },
@@ -140,6 +147,8 @@ GetAlgorithmInteger( amrex::ParmParse& pp, const char* pp_search_key ){
std::map<std::string, int> algo_to_int;
if (0 == std::strcmp(pp_search_key, "maxwell_solver")) {
algo_to_int = electromagnetic_solver_algo_to_int;
+ } else if (0 == std::strcmp(pp_search_key, "grid_type")) {
+ algo_to_int = grid_to_int;
} else if (0 == std::strcmp(pp_search_key, "do_electrostatic")) {
algo_to_int = electrostatic_solver_algo_to_int;
} else if (0 == std::strcmp(pp_search_key, "particle_pusher")) {