aboutsummaryrefslogtreecommitdiff
path: root/Source/Evolve/WarpXEvolve.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Evolve/WarpXEvolve.cpp')
-rw-r--r--Source/Evolve/WarpXEvolve.cpp158
1 files changed, 80 insertions, 78 deletions
diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp
index 5efd000c6..3d89c15a0 100644
--- a/Source/Evolve/WarpXEvolve.cpp
+++ b/Source/Evolve/WarpXEvolve.cpp
@@ -135,7 +135,13 @@ WarpX::Evolve (int numsteps)
// Main PIC operation:
// gather fields, push particles, deposit sources, update fields
- if (do_subcycling == 0 || finest_level == 0) {
+ if ( do_electrostatic != ElectrostaticSolverAlgo::None ) {
+ // Special case: electrostatic solver.
+ // In this case, we only gather fields and push particles
+ // The deposition and calculation of fields is done further below
+ bool const skip_deposition=true;
+ PushParticlesandDepose(cur_time, skip_deposition);
+ } else if (do_subcycling == 0 || finest_level == 0) {
OneStep_nosub(cur_time);
// E : guard cells are up-to-date
// B : guard cells are NOT up-to-date
@@ -327,75 +333,70 @@ WarpX::OneStep_nosub (Real cur_time)
if (warpx_py_beforeEsolve) warpx_py_beforeEsolve();
- if( do_electrostatic == ElectrostaticSolverAlgo::None ) {
- // Electromagnetic solver:
- // Push E and B from {n} to {n+1}
- // (And update guard cells immediately afterwards)
- if (WarpX::maxwell_solver_id == MaxwellSolverAlgo::PSATD) {
- if (use_hybrid_QED)
- {
- WarpX::Hybrid_QED_Push(dt);
- FillBoundaryE(guard_cells.ng_alloc_EB);
- }
- PushPSATD(dt[0]);
+ // Push E and B from {n} to {n+1}
+ // (And update guard cells immediately afterwards)
+ if (WarpX::maxwell_solver_id == MaxwellSolverAlgo::PSATD) {
+ if (use_hybrid_QED)
+ {
+ WarpX::Hybrid_QED_Push(dt);
FillBoundaryE(guard_cells.ng_alloc_EB);
- FillBoundaryB(guard_cells.ng_alloc_EB);
+ }
+ PushPSATD(dt[0]);
+ FillBoundaryE(guard_cells.ng_alloc_EB);
+ FillBoundaryB(guard_cells.ng_alloc_EB);
- if (use_hybrid_QED)
- {
- WarpX::Hybrid_QED_Push(dt);
- FillBoundaryE(guard_cells.ng_alloc_EB);
- }
+ if (use_hybrid_QED) {
+ WarpX::Hybrid_QED_Push(dt);
+ FillBoundaryE(guard_cells.ng_alloc_EB);
+ }
- // Synchronize E and B fields on nodal points
- NodalSyncE();
- NodalSyncB();
+ // Synchronize E and B fields on nodal points
+ NodalSyncE();
+ NodalSyncB();
- if (do_pml) {
- DampPML();
- NodalSyncPML();
- }
+ if (do_pml) {
+ DampPML();
+ NodalSyncPML();
+ }
+ } else {
+ EvolveF(0.5_rt * dt[0], DtType::FirstHalf);
+ FillBoundaryF(guard_cells.ng_FieldSolverF);
+ EvolveB(0.5_rt * dt[0]); // We now have B^{n+1/2}
+
+ if (do_silver_mueller) ApplySilverMuellerBoundary( dt[0] );
+ FillBoundaryB(guard_cells.ng_FieldSolver);
+
+ if (WarpX::em_solver_medium == MediumForEM::Vacuum) {
+ // vacuum medium
+ EvolveE(dt[0]); // We now have E^{n+1}
+ } else if (WarpX::em_solver_medium == MediumForEM::Macroscopic) {
+ // macroscopic medium
+ MacroscopicEvolveE(dt[0]); // We now have E^{n+1}
} else {
- EvolveF(0.5_rt * dt[0], DtType::FirstHalf);
- FillBoundaryF(guard_cells.ng_FieldSolverF);
- EvolveB(0.5_rt * dt[0]); // We now have B^{n+1/2}
-
- if (do_silver_mueller) ApplySilverMuellerBoundary( dt[0] );
- FillBoundaryB(guard_cells.ng_FieldSolver);
-
- if (WarpX::em_solver_medium == MediumForEM::Vacuum) {
- // vacuum medium
- EvolveE(dt[0]); // We now have E^{n+1}
- } else if (WarpX::em_solver_medium == MediumForEM::Macroscopic) {
- // macroscopic medium
- MacroscopicEvolveE(dt[0]); // We now have E^{n+1}
- } else {
- amrex::Abort(" Medium for EM is unknown \n");
- }
-
- FillBoundaryE(guard_cells.ng_FieldSolver);
- EvolveF(0.5_rt * dt[0], DtType::SecondHalf);
- EvolveB(0.5_rt * dt[0]); // We now have B^{n+1}
-
- // Synchronize E and B fields on nodal points
- NodalSyncE();
- NodalSyncB();
-
- if (do_pml) {
- FillBoundaryF(guard_cells.ng_alloc_F);
- DampPML();
- NodalSyncPML();
- FillBoundaryE(guard_cells.ng_MovingWindow);
- FillBoundaryF(guard_cells.ng_MovingWindow);
- FillBoundaryB(guard_cells.ng_MovingWindow);
- }
- // E and B are up-to-date in the domain, but all guard cells are
- // outdated.
- if (safe_guard_cells)
- FillBoundaryB(guard_cells.ng_alloc_EB);
- } // !PSATD
+ amrex::Abort(" Medium for EM is unknown \n");
+ }
- } // !do_electrostatic
+ FillBoundaryE(guard_cells.ng_FieldSolver);
+ EvolveF(0.5_rt * dt[0], DtType::SecondHalf);
+ EvolveB(0.5_rt * dt[0]); // We now have B^{n+1}
+
+ // Synchronize E and B fields on nodal points
+ NodalSyncE();
+ NodalSyncB();
+
+ if (do_pml) {
+ FillBoundaryF(guard_cells.ng_alloc_F);
+ DampPML();
+ NodalSyncPML();
+ FillBoundaryE(guard_cells.ng_MovingWindow);
+ FillBoundaryF(guard_cells.ng_MovingWindow);
+ FillBoundaryB(guard_cells.ng_MovingWindow);
+ }
+ // E and B are up-to-date in the domain, but all guard cells are
+ // outdated.
+ if (safe_guard_cells)
+ FillBoundaryB(guard_cells.ng_alloc_EB);
+ } // !PSATD
if (warpx_py_afterEsolve) warpx_py_afterEsolve();
}
@@ -598,17 +599,17 @@ WarpX::doQEDEvents (int lev)
#endif
void
-WarpX::PushParticlesandDepose (amrex::Real cur_time)
+WarpX::PushParticlesandDepose (amrex::Real cur_time, bool skip_deposition)
{
// Evolve particles to p^{n+1/2} and x^{n+1}
// Depose current, j^{n+1/2}
for (int lev = 0; lev <= finest_level; ++lev) {
- PushParticlesandDepose(lev, cur_time);
+ PushParticlesandDepose(lev, cur_time, DtType::Full, skip_deposition);
}
}
void
-WarpX::PushParticlesandDepose (int lev, amrex::Real cur_time, DtType a_dt_type)
+WarpX::PushParticlesandDepose (int lev, amrex::Real cur_time, DtType a_dt_type, bool skip_deposition)
{
// If warpx.do_current_centering = 1, the current is deposited on the nodal MultiFab current_fp_nodal
// and then centered onto the staggered MultiFab current_fp
@@ -627,18 +628,19 @@ WarpX::PushParticlesandDepose (int lev, amrex::Real cur_time, DtType a_dt_type)
rho_fp[lev].get(), charge_buf[lev].get(),
Efield_cax[lev][0].get(), Efield_cax[lev][1].get(), Efield_cax[lev][2].get(),
Bfield_cax[lev][0].get(), Bfield_cax[lev][1].get(), Bfield_cax[lev][2].get(),
- cur_time, dt[lev], a_dt_type);
-
+ cur_time, dt[lev], a_dt_type, skip_deposition);
#ifdef WARPX_DIM_RZ
- // This is called after all particles have deposited their current and charge.
- ApplyInverseVolumeScalingToCurrentDensity(current_fp[lev][0].get(), current_fp[lev][1].get(), current_fp[lev][2].get(), lev);
- if (current_buf[lev][0].get()) {
- ApplyInverseVolumeScalingToCurrentDensity(current_buf[lev][0].get(), current_buf[lev][1].get(), current_buf[lev][2].get(), lev-1);
- }
- if (rho_fp[lev].get()) {
- ApplyInverseVolumeScalingToChargeDensity(rho_fp[lev].get(), lev);
- if (charge_buf[lev].get()) {
- ApplyInverseVolumeScalingToChargeDensity(charge_buf[lev].get(), lev-1);
+ if (! skip_deposition) {
+ // This is called after all particles have deposited their current and charge.
+ ApplyInverseVolumeScalingToCurrentDensity(current_fp[lev][0].get(), current_fp[lev][1].get(), current_fp[lev][2].get(), lev);
+ if (current_buf[lev][0].get()) {
+ ApplyInverseVolumeScalingToCurrentDensity(current_buf[lev][0].get(), current_buf[lev][1].get(), current_buf[lev][2].get(), lev-1);
+ }
+ if (rho_fp[lev].get()) {
+ ApplyInverseVolumeScalingToChargeDensity(rho_fp[lev].get(), lev);
+ if (charge_buf[lev].get()) {
+ ApplyInverseVolumeScalingToChargeDensity(charge_buf[lev].get(), lev-1);
+ }
}
}
#endif