From 48c1a86047fb06b957474c5a92d15f104c77b039 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Fri, 26 Aug 2022 08:31:09 -0700 Subject: Fix Bugs w/ Current Correction and Vay Deposition (#3290) * Fix Bugs w/ Current Correction and Vay Deposition * Vay Deposition and Current Correction Cannot be Combined Together * Add Comment for Future Implementation of Vay Deposition w/ MR * Add Comment for Future Implementation of Vay Deposition w/ MR * Define SyncCurrentAndRho, Clean Up * Vay Deposition: Remove Extra FFT of Rho * Fix Bug in RZ Geometry (Double Filtering) * Add 2D Galilean Test w/o Periodic Single Box * Add RZ Galilean Test w/o Periodic Single Box * Add 3D Galilean Test w/o Periodic Single Box --- Source/Evolve/WarpXEvolve.cpp | 56 +++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'Source/Evolve/WarpXEvolve.cpp') diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index b7a8c64f1..cc71e78d5 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -398,19 +398,9 @@ WarpX::OneStep_nosub (Real cur_time) ExecutePythonCallback("afterdeposition"); - // Synchronize J and rho: filter, exchange boundary, interpolate across levels. - // With Vay current deposition, the current deposited at this point is not yet - // the actual current J. This is computed later in WarpX::PushPSATD, by calling - // WarpX::PSATDVayDeposition. The function SyncCurrent is called after that, - // instead of here, so that we synchronize the correct current. - // With current centering, the nodal current is deposited in 'current_fp_nodal': - // SyncCurrent stores the result of its centering into 'current_fp' and then - // performs both filtering, if used, and exchange of guard cells. - if (WarpX::current_deposition_algo != CurrentDepositionAlgo::Vay) - { - SyncCurrent(current_fp, current_cp); - } - SyncRho(); + // Synchronize J and rho: + // filter (if used), exchange guard cells, interpolate across MR levels + SyncCurrentAndRho(); // At this point, J is up-to-date inside the domain, and E and B are // up-to-date including enough guard cells for first step of the field @@ -495,6 +485,46 @@ WarpX::OneStep_nosub (Real cur_time) ExecutePythonCallback("afterEsolve"); } +void WarpX::SyncCurrentAndRho () +{ + if (maxwell_solver_id == MaxwellSolverAlgo::PSATD) + { + if (fft_periodic_single_box) + { + // With periodic single box, synchronize J and rho here, + // even with current correction or Vay deposition + if (current_deposition_algo == CurrentDepositionAlgo::Vay) + { + // TODO Replace current_cp with current_cp_vay once Vay deposition is implemented with MR + SyncCurrent(current_fp_vay, current_cp); + SyncRho(); + } + else + { + SyncCurrent(current_fp, current_cp); + SyncRho(); + } + } + else // no periodic single box + { + // Without periodic single box, synchronize J and rho here, + // except with current correction or Vay deposition: + // in these cases, synchronize later (in WarpX::PushPSATD) + if (current_correction == false && + current_deposition_algo != CurrentDepositionAlgo::Vay) + { + SyncCurrent(current_fp, current_cp); + SyncRho(); + } + } + } + else // FDTD + { + SyncCurrent(current_fp, current_cp); + SyncRho(); + } +} + void WarpX::OneStep_multiJ (const amrex::Real cur_time) { -- cgit v1.2.3