diff options
author | 2021-07-08 02:05:26 -0700 | |
---|---|---|
committer | 2021-07-08 02:05:26 -0700 | |
commit | 6269c20a6c42037c85efd76bfa9ed162a312df96 (patch) | |
tree | 0a12767ff0c56c598f6d684625981fec99f75db7 /Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp | |
parent | ecbe32dca65ace0faa092afaf75a3725c65a42e5 (diff) | |
download | WarpX-6269c20a6c42037c85efd76bfa9ed162a312df96.tar.gz WarpX-6269c20a6c42037c85efd76bfa9ed162a312df96.tar.zst WarpX-6269c20a6c42037c85efd76bfa9ed162a312df96.zip |
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)
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
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<amrex::Real>* 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<amrex::Real> mf_arr = mf[mfi].array(); amrex::Array4<const amrex::Real> 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<bool>(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 { |