Skip to content

Commit

Permalink
Saves the current for the diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Jul 3, 2024
1 parent ffa3bcc commit 3e3d59b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,31 @@ WarpX::SpectralSourceFreeFieldAdvance()
// Do the first piece of the Strang splitting, source free advance of E and B
// It would be more efficient to write a specialized PSATD advance that does not use J,
// but this works for now.
// Note that erasing J messes up the J in the plot files since it uses the same data.

// Create temporary MultiFabs to hold J
amrex::MultiFab j0(current_fp[0][0]->boxArray(), current_fp[0][0]->DistributionMap(),
current_fp[0][0]->nComp(), current_fp[0][0]->nGrowVect());
amrex::MultiFab j1(current_fp[0][1]->boxArray(), current_fp[0][1]->DistributionMap(),
current_fp[0][1]->nComp(), current_fp[0][1]->nGrowVect());
amrex::MultiFab j2(current_fp[0][2]->boxArray(), current_fp[0][2]->DistributionMap(),
current_fp[0][2]->nComp(), current_fp[0][2]->nGrowVect());
amrex::MultiFab::Copy(j0, *(current_fp[0][0]), 0, 0, current_fp[0][0]->nComp(), current_fp[0][0]->nGrowVect());
amrex::MultiFab::Copy(j1, *(current_fp[0][1]), 0, 0, current_fp[0][1]->nComp(), current_fp[0][1]->nGrowVect());
amrex::MultiFab::Copy(j2, *(current_fp[0][2]), 0, 0, current_fp[0][2]->nComp(), current_fp[0][2]->nGrowVect());

current_fp[0][0]->setVal(0._rt);
current_fp[0][1]->setVal(0._rt);
current_fp[0][2]->setVal(0._rt);
if (rho_fp[0]) { rho_fp[0]->setVal(0._rt); }
PushPSATD(); // Note that this does dt/2
FillBoundaryE(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points);
FillBoundaryB(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points);

// Restore the current_fp MultiFab. Note that this is only needed for diagnostics when
// J is being written out (since current_fp is not otherwise used).
amrex::MultiFab::Copy(*(current_fp[0][0]), j0, 0, 0, 1, current_fp[0][0]->nGrowVect());
amrex::MultiFab::Copy(*(current_fp[0][1]), j1, 0, 0, 1, current_fp[0][1]->nGrowVect());
amrex::MultiFab::Copy(*(current_fp[0][2]), j2, 0, 0, 1, current_fp[0][2]->nGrowVect());
}

void
Expand Down

0 comments on commit 3e3d59b

Please sign in to comment.