aboutsummaryrefslogtreecommitdiff
path: root/Source/Parallelization
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Parallelization')
-rw-r--r--Source/Parallelization/GuardCellManager.cpp80
-rw-r--r--Source/Parallelization/WarpXSumGuardCells.H41
2 files changed, 61 insertions, 60 deletions
diff --git a/Source/Parallelization/GuardCellManager.cpp b/Source/Parallelization/GuardCellManager.cpp
index 85490f2e0..74e3bff24 100644
--- a/Source/Parallelization/GuardCellManager.cpp
+++ b/Source/Parallelization/GuardCellManager.cpp
@@ -8,14 +8,14 @@
#include "Filter/NCIGodfreyFilter.H"
#include "Utils/WarpXAlgorithmSelection.H"
-#include <AMReX_Print.H>
#include <AMReX_ParmParse.H>
#include <AMReX.H>
+
using namespace amrex;
void
-guardCellManager::Init(
+guardCellManager::Init (
const bool do_subcycling,
const bool do_fdtd_nci_corr,
const bool do_nodal,
@@ -105,23 +105,23 @@ guardCellManager::Init(
if (maxwell_solver_id == MaxwellSolverAlgo::CKC) ng_alloc_F_int = std::max( ng_alloc_F_int, 1 );
ng_alloc_F = IntVect(AMREX_D_DECL(ng_alloc_F_int, ng_alloc_F_int, ng_alloc_F_int));
-#ifdef WARPX_USE_PSATD
- // All boxes should have the same number of guard cells
- // (to avoid temporary parallel copies)
- // Thus take the max of the required number of guards for each field
- // Also: the number of guard cell should be enough to contain
- // the stencil of the FFT solver. Here, this number (`ngFFT`)
- // is determined *empirically* to be the order of the solver
- // for nodal, and half the order of the solver for staggered.
+ if (maxwell_solver_id == MaxwellSolverAlgo::PSATD) {
+ // All boxes should have the same number of guard cells
+ // (to avoid temporary parallel copies)
+ // Thus take the max of the required number of guards for each field
+ // Also: the number of guard cell should be enough to contain
+ // the stencil of the FFT solver. Here, this number (`ngFFT`)
+ // is determined *empirically* to be the order of the solver
+ // for nodal, and half the order of the solver for staggered.
- int ngFFt_x = do_nodal ? nox_fft : nox_fft/2;
- int ngFFt_y = do_nodal ? noy_fft : noy_fft/2;
- int ngFFt_z = do_nodal ? noz_fft : noz_fft/2;
+ int ngFFt_x = do_nodal ? nox_fft : nox_fft / 2;
+ int ngFFt_y = do_nodal ? noy_fft : noy_fft / 2;
+ int ngFFt_z = do_nodal ? noz_fft : noz_fft / 2;
- ParmParse pp("psatd");
- pp.query("nx_guard", ngFFt_x);
- pp.query("ny_guard", ngFFt_y);
- pp.query("nz_guard", ngFFt_z);
+ ParmParse pp("psatd");
+ pp.query("nx_guard", ngFFt_x);
+ pp.query("ny_guard", ngFFt_y);
+ pp.query("nz_guard", ngFFt_z);
#if (AMREX_SPACEDIM == 3)
IntVect ngFFT = IntVect(ngFFt_x, ngFFt_y, ngFFt_z);
@@ -129,35 +129,33 @@ guardCellManager::Init(
IntVect ngFFT = IntVect(ngFFt_x, ngFFt_z);
#endif
- for (int i_dim=0; i_dim<AMREX_SPACEDIM; i_dim++ ){
- int ng_required = ngFFT[i_dim];
- // Get the max
- ng_required = std::max( ng_required, ng_alloc_EB[i_dim] );
- ng_required = std::max( ng_required, ng_alloc_J[i_dim] );
- ng_required = std::max( ng_required, ng_alloc_Rho[i_dim] );
- ng_required = std::max( ng_required, ng_alloc_F[i_dim] );
- // Set the guard cells to this max
- ng_alloc_EB[i_dim] = ng_required;
- ng_alloc_J[i_dim] = ng_required;
- ng_alloc_F[i_dim] = ng_required;
- ng_alloc_Rho[i_dim] = ng_required;
- ng_alloc_F_int = ng_required;
+ for (int i_dim = 0; i_dim < AMREX_SPACEDIM; i_dim++) {
+ int ng_required = ngFFT[i_dim];
+ // Get the max
+ ng_required = std::max(ng_required, ng_alloc_EB[i_dim]);
+ ng_required = std::max(ng_required, ng_alloc_J[i_dim]);
+ ng_required = std::max(ng_required, ng_alloc_Rho[i_dim]);
+ ng_required = std::max(ng_required, ng_alloc_F[i_dim]);
+ // Set the guard cells to this max
+ ng_alloc_EB[i_dim] = ng_required;
+ ng_alloc_J[i_dim] = ng_required;
+ ng_alloc_F[i_dim] = ng_required;
+ ng_alloc_Rho[i_dim] = ng_required;
+ ng_alloc_F_int = ng_required;
+ }
+ ng_alloc_F = IntVect(AMREX_D_DECL(ng_alloc_F_int, ng_alloc_F_int, ng_alloc_F_int));
}
- ng_alloc_F = IntVect(AMREX_D_DECL(ng_alloc_F_int, ng_alloc_F_int, ng_alloc_F_int));
-#else
- ignore_unused(nox_fft, noy_fft, noz_fft);
-#endif
ng_Extra = IntVect(static_cast<int>(aux_is_nodal and !do_nodal));
// Compute number of cells required for Field Solver
-#ifdef WARPX_USE_PSATD
- ng_FieldSolver = ng_alloc_EB;
- ng_FieldSolverF = ng_alloc_EB;
-#else
- ng_FieldSolver = IntVect(AMREX_D_DECL(1,1,1));
- ng_FieldSolverF = IntVect(AMREX_D_DECL(1,1,1));
-#endif
+ if (maxwell_solver_id == MaxwellSolverAlgo::PSATD) {
+ ng_FieldSolver = ng_alloc_EB;
+ ng_FieldSolverF = ng_alloc_EB;
+ } else {
+ ng_FieldSolver = IntVect(AMREX_D_DECL(1, 1, 1));
+ ng_FieldSolverF = IntVect(AMREX_D_DECL(1, 1, 1));
+ }
if (safe_guard_cells){
// Run in safe mode: exchange all allocated guard cells at each
diff --git a/Source/Parallelization/WarpXSumGuardCells.H b/Source/Parallelization/WarpXSumGuardCells.H
index 972c1cd2d..b9789b45c 100644
--- a/Source/Parallelization/WarpXSumGuardCells.H
+++ b/Source/Parallelization/WarpXSumGuardCells.H
@@ -16,22 +16,23 @@
* This is typically called for the sources of the Maxwell equations (J/rho)
* after deposition from the macroparticles.
*
- * - When WarpX is compiled with a finite-difference scheme: this only
+ * - When WarpX is used with a finite-difference scheme: this only
* updates the *valid* cells of `mf`
- * - When WarpX is compiled with a spectral scheme (WARPX_USE_PSATD): this
+ * - When WarpX is used with a spectral scheme (PSATD): this
* updates both the *valid* cells and *guard* cells. (This is because a
* spectral solver requires the value of the sources over a large stencil.)
*/
inline void
WarpXSumGuardCells(amrex::MultiFab& mf, const amrex::Periodicity& period,
- const int icomp=0, const int ncomp=1){
-#ifdef WARPX_USE_PSATD
- // Update both valid cells and guard cells
- const amrex::IntVect n_updated_guards = mf.nGrowVect();
-#else
- // Update only the valid cells
- const amrex::IntVect n_updated_guards = amrex::IntVect::TheZeroVector();
-#endif
+ const int icomp=0, const int ncomp=1)
+{
+ amrex::IntVect n_updated_guards;
+
+ // Update both valid cells and guard cells
+ if (WarpX::maxwell_solver_id == MaxwellSolverAlgo::PSATD)
+ n_updated_guards = mf.nGrowVect();
+ else // Update only the valid cells
+ n_updated_guards = amrex::IntVect::TheZeroVector();
mf.SumBoundary(icomp, ncomp, n_updated_guards, period);
}
@@ -41,9 +42,9 @@ WarpXSumGuardCells(amrex::MultiFab& mf, const amrex::Periodicity& period,
* This is typically called for the sources of the Maxwell equations (J/rho)
* after deposition from the macroparticles + filtering.
*
- * - When WarpX is compiled with a finite-difference scheme: this only
+ * - When WarpX is used with a finite-difference scheme: this only
* updates the *valid* cells of `dst`
- * - When WarpX is compiled with a spectral scheme (WARPX_USE_PSATD): this
+ * - When WarpX is used with a spectral scheme (PSATD): this
* updates both the *valid* cells and *guard* cells. (This is because a
* spectral solver requires the value of the sources over a large stencil.)
*
@@ -53,14 +54,16 @@ WarpXSumGuardCells(amrex::MultiFab& mf, const amrex::Periodicity& period,
inline void
WarpXSumGuardCells(amrex::MultiFab& dst, amrex::MultiFab& src,
const amrex::Periodicity& period,
- const int icomp=0, const int ncomp=1){
-#ifdef WARPX_USE_PSATD
+ const int icomp=0, const int ncomp=1)
+{
+ amrex::IntVect n_updated_guards;
+
// Update both valid cells and guard cells
- const amrex::IntVect n_updated_guards = dst.nGrowVect();
-#else
- // Update only the valid cells
- const amrex::IntVect n_updated_guards = amrex::IntVect::TheZeroVector();
-#endif
+ if (WarpX::maxwell_solver_id == MaxwellSolverAlgo::PSATD)
+ n_updated_guards = dst.nGrowVect();
+ else // Update only the valid cells
+ n_updated_guards = amrex::IntVect::TheZeroVector();
+
src.SumBoundary(0, ncomp, n_updated_guards, period);
amrex::Copy( dst, src, 0, icomp, ncomp, n_updated_guards );
}