From 6269c20a6c42037c85efd76bfa9ed162a312df96 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Thu, 8 Jul 2021 02:05:26 -0700 Subject: Do Not Fill Guard Cells with Inverse FFTs, Unless for Field Damping (#2045) * Do Not Always Fill Guard Cells with Inverse FFTs * Query psatd.fill_guards from Inputs * Clean Up and Reduce Style Changes * Fix Bug for Periodic Single Box * Clean Up and Reduce Style Changes * Fix Bug for RZ PSATD * Remove Input Parameter, Default 0 Unless Damping * Fix CI Tests (2D) * Fix CI Tests (3D) --- .../FieldSolver/SpectralSolver/SpectralFieldData.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp') diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp index 5d8c52cc0..b26ac4943 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp @@ -223,10 +223,11 @@ SpectralFieldData::ForwardTransform (const int lev, /* \brief Transform spectral field specified by `field_index` back to * real space, and store it in the component `i_comp` of `mf` */ void -SpectralFieldData::BackwardTransform( const int lev, +SpectralFieldData::BackwardTransform (const int lev, MultiFab& mf, const int field_index, - const int i_comp ) + const int i_comp, + const amrex::IntVect& fill_guards) { amrex::LayoutData* cost = WarpX::getCosts(lev); @@ -248,6 +249,9 @@ SpectralFieldData::BackwardTransform( const int lev, const int sk = (is_nodal_z) ? 1 : 0; #endif + // Numbers of guard cells + const amrex::IntVect& mf_ng = mf.nGrowVect(); + // Loop over boxes // Note: we do NOT OpenMP parallelize here, since we use OpenMP threads for // the iFFTs on each box! @@ -295,7 +299,7 @@ SpectralFieldData::BackwardTransform( const int lev, // Copy the temporary field tmpRealField to the real-space field mf and // normalize, dividing by N, since (FFT + inverse FFT) results in a factor N { - amrex::Box const& mf_box = (m_periodic_single_box) ? mfi.validbox() : mfi.fabbox(); + amrex::Box mf_box = (m_periodic_single_box) ? mfi.validbox() : mfi.fabbox(); amrex::Array4 mf_arr = mf[mfi].array(); amrex::Array4 tmp_arr = tmpRealField[mfi].array(); @@ -317,6 +321,16 @@ SpectralFieldData::BackwardTransform( const int lev, #elif (AMREX_SPACEDIM == 3) const int lo_k = amrex::lbound(mf_box).z; #endif + // If necessary, do not fill the guard cells + // (shrink box by passing negative number of cells) + if (m_periodic_single_box == false) + { + for (int dir = 0; dir < AMREX_SPACEDIM; dir++) + { + if (static_cast(fill_guards[dir]) == false) mf_box.grow(dir, -mf_ng[dir]); + } + } + // Loop over cells within full box, including ghost cells ParallelFor(mf_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { -- cgit v1.2.3