From e7db4accb266632b85ce0bbc8fe3897e5518f874 Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 26 Nov 2024 12:10:48 -0800 Subject: [PATCH 01/11] Pass time into ApplyEfieldBoundary and ApplyBfieldBoundary --- .../WarpXFieldBoundaries.cpp | 18 +++--- Source/Evolve/WarpXEvolve.cpp | 46 +++++++-------- .../HybridPICModel/HybridPICModel.cpp | 6 +- .../ImplicitSolvers/SemiImplicitEM.cpp | 11 ++-- .../StrangImplicitSpectralEM.cpp | 12 ++-- .../ImplicitSolvers/ThetaImplicitEM.cpp | 10 ++-- .../ImplicitSolvers/WarpXImplicitOps.cpp | 16 +++--- .../SpectralSolver/SpectralSolver.H | 3 + .../SpectralSolver/SpectralSolver.cpp | 1 + .../SpectralSolver/SpectralSolverRZ.H | 3 + .../SpectralSolver/SpectralSolverRZ.cpp | 2 +- Source/FieldSolver/WarpXPushFieldsEM.cpp | 57 ++++++++++--------- Source/WarpX.H | 32 +++++------ 13 files changed, 114 insertions(+), 103 deletions(-) diff --git a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp index 7566979557e..692c9938e86 100644 --- a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp +++ b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp @@ -49,7 +49,7 @@ namespace } -void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) +void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type, amrex::Real time) { using ablastr::fields::Direction; @@ -94,7 +94,6 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) } if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { - amrex::Real const tnew = gett_new(lev); if (patch_type == PatchType::fine) { pec_insulator_boundary->ApplyPEC_InsulatortoEfield( {m_fields.get(FieldType::Efield_fp,Direction{0},lev), @@ -102,7 +101,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) m_fields.get(FieldType::Efield_fp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew); + lev, patch_type, ref_ratio, time); if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { // apply pec on split E-fields in PML region const bool split_pml_field = true; @@ -110,7 +109,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) m_fields.get_alldirs(FieldType::pml_E_fp, lev), field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew, + lev, patch_type, ref_ratio, time, split_pml_field); } } else { @@ -120,7 +119,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) m_fields.get(FieldType::Efield_cp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew); + lev, patch_type, ref_ratio, time); if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { // apply pec on split E-fields in PML region const bool split_pml_field = true; @@ -128,7 +127,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) m_fields.get_alldirs(FieldType::pml_E_cp, lev), field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew, + lev, patch_type, ref_ratio, time, split_pml_field); } } @@ -147,7 +146,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) #endif } -void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_dt_type) +void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_dt_type, amrex::Real time) { using ablastr::fields::Direction; @@ -172,7 +171,6 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d } if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { - amrex::Real const tnew = gett_new(lev); if (patch_type == PatchType::fine) { pec_insulator_boundary->ApplyPEC_InsulatortoBfield( {m_fields.get(FieldType::Bfield_fp,Direction{0},lev), @@ -180,7 +178,7 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d m_fields.get(FieldType::Bfield_fp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew); + lev, patch_type, ref_ratio, time); } else { pec_insulator_boundary->ApplyPEC_InsulatortoBfield( {m_fields.get(FieldType::Bfield_cp,Direction{0},lev), @@ -188,7 +186,7 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d m_fields.get(FieldType::Bfield_cp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), - lev, patch_type, ref_ratio, tnew); + lev, patch_type, ref_ratio, time); } } diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index e9540be3da7..163138ca572 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -390,7 +390,7 @@ WarpX::OneStep_nosub (Real cur_time) WarpX::Hybrid_QED_Push(dt); FillBoundaryE(guard_cells.ng_alloc_EB); } - PushPSATD(); + PushPSATD(cur_time); if (do_pml) { DampPML(); @@ -418,15 +418,15 @@ WarpX::OneStep_nosub (Real cur_time) FillBoundaryF(guard_cells.ng_FieldSolverF); FillBoundaryG(guard_cells.ng_FieldSolverG); - EvolveB(0.5_rt * dt[0], DtType::FirstHalf); // We now have B^{n+1/2} + EvolveB(0.5_rt * dt[0], DtType::FirstHalf, cur_time); // We now have B^{n+1/2} FillBoundaryB(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); if (WarpX::em_solver_medium == MediumForEM::Vacuum) { // vacuum medium - EvolveE(dt[0]); // We now have E^{n+1} + EvolveE(dt[0], cur_time); // 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} + MacroscopicEvolveE(dt[0], cur_time); // We now have E^{n+1} } else { WARPX_ABORT_WITH_MESSAGE("Medium for EM is unknown"); } @@ -434,7 +434,7 @@ WarpX::OneStep_nosub (Real cur_time) EvolveF(0.5_rt * dt[0], DtType::SecondHalf); EvolveG(0.5_rt * dt[0], DtType::SecondHalf); - EvolveB(0.5_rt * dt[0], DtType::SecondHalf); // We now have B^{n+1} + EvolveB(0.5_rt * dt[0], DtType::SecondHalf, cur_time + 0.5_rt * dt[0]); // We now have B^{n+1} if (do_pml) { DampPML(); @@ -808,10 +808,10 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) { pml[lev]->PushPSATD(m_fields, lev); } - ApplyEfieldBoundary(lev, PatchType::fine); - if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse); } - ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf); - if (lev > 0) { ApplyBfieldBoundary(lev, PatchType::coarse, DtType::FirstHalf); } + ApplyEfieldBoundary(lev, PatchType::fine, cur_time + dt[0]); + if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse, cur_time + dt[0]); } + ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf, cur_time + dt[0]); + if (lev > 0) { ApplyBfieldBoundary(lev, PatchType::coarse, DtType::FirstHalf, cur_time + dt[0]); } } // Damp fields in PML before exchanging guard cells @@ -886,17 +886,17 @@ WarpX::OneStep_sub1 (Real cur_time) m_fields.get_mr_levels(FieldType::rho_cp, finest_level), fine_lev, PatchType::fine, 0, 2*ncomps); - EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); + EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf, cur_time); EvolveF(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); FillBoundaryB(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); FillBoundaryF(fine_lev, PatchType::fine, guard_cells.ng_alloc_F, WarpX::sync_nodal_points); - EvolveE(fine_lev, PatchType::fine, dt[fine_lev]); + EvolveE(fine_lev, PatchType::fine, dt[fine_lev], cur_time); FillBoundaryE(fine_lev, PatchType::fine, guard_cells.ng_FieldGather); - EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf); + EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf, cur_time + 0.5_rt * dt[fine_lev]); EvolveF(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf); if (do_pml) { @@ -922,22 +922,22 @@ WarpX::OneStep_sub1 (Real cur_time) m_fields.get_mr_levels(FieldType::rho_buf, finest_level), coarse_lev, 0, ncomps); - EvolveB(fine_lev, PatchType::coarse, dt[fine_lev], DtType::FirstHalf); + EvolveB(fine_lev, PatchType::coarse, dt[fine_lev], DtType::FirstHalf, cur_time); EvolveF(fine_lev, PatchType::coarse, dt[fine_lev], DtType::FirstHalf); FillBoundaryB(fine_lev, PatchType::coarse, guard_cells.ng_FieldGather); FillBoundaryF(fine_lev, PatchType::coarse, guard_cells.ng_FieldSolverF); - EvolveE(fine_lev, PatchType::coarse, dt[fine_lev]); + EvolveE(fine_lev, PatchType::coarse, dt[fine_lev], cur_time); FillBoundaryE(fine_lev, PatchType::coarse, guard_cells.ng_FieldGather); - EvolveB(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::FirstHalf); + EvolveB(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::FirstHalf, cur_time); EvolveF(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::FirstHalf); FillBoundaryB(coarse_lev, PatchType::fine, guard_cells.ng_FieldGather, WarpX::sync_nodal_points); FillBoundaryF(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolverF, WarpX::sync_nodal_points); - EvolveE(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev]); + EvolveE(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], cur_time); FillBoundaryE(coarse_lev, PatchType::fine, guard_cells.ng_FieldGather); // TODO Remove call to FillBoundaryAux before UpdateAuxilaryData? @@ -961,16 +961,16 @@ WarpX::OneStep_sub1 (Real cur_time) m_fields.get_mr_levels(FieldType::rho_cp, finest_level), fine_lev, PatchType::fine, 0, ncomps); - EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); + EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf, cur_time + dt[fine_lev]); EvolveF(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); FillBoundaryB(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver); FillBoundaryF(fine_lev, PatchType::fine, guard_cells.ng_FieldSolverF); - EvolveE(fine_lev, PatchType::fine, dt[fine_lev]); + EvolveE(fine_lev, PatchType::fine, dt[fine_lev], cur_time + dt[fine_lev]); FillBoundaryE(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); - EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf); + EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf, cur_time + 1.5_rt*dt[fine_lev]); EvolveF(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::SecondHalf); if (do_pml) { @@ -997,11 +997,11 @@ WarpX::OneStep_sub1 (Real cur_time) m_fields.get_mr_levels(FieldType::rho_buf, finest_level), coarse_lev, ncomps, ncomps); - EvolveE(fine_lev, PatchType::coarse, dt[fine_lev]); + EvolveE(fine_lev, PatchType::coarse, dt[fine_lev], cur_time + 0.5_rt * dt[fine_lev]); FillBoundaryE(fine_lev, PatchType::coarse, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); - EvolveB(fine_lev, PatchType::coarse, dt[fine_lev], DtType::SecondHalf); + EvolveB(fine_lev, PatchType::coarse, dt[fine_lev], DtType::SecondHalf, cur_time + 0.5_rt * dt[fine_lev]); EvolveF(fine_lev, PatchType::coarse, dt[fine_lev], DtType::SecondHalf); if (do_pml) { @@ -1016,11 +1016,11 @@ WarpX::OneStep_sub1 (Real cur_time) FillBoundaryF(fine_lev, PatchType::coarse, guard_cells.ng_FieldSolverF, WarpX::sync_nodal_points); - EvolveE(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev]); + EvolveE(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], cur_time + 0.5_rt*dt[coarse_lev]); FillBoundaryE(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); - EvolveB(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::SecondHalf); + EvolveB(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::SecondHalf, cur_time + 0.5_rt*dt[coarse_lev]); EvolveF(coarse_lev, PatchType::fine, 0.5_rt*dt[coarse_lev], DtType::SecondHalf); if (do_pml) { diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp index 424f194ff37..fd6be29172b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp @@ -348,7 +348,8 @@ void HybridPICModel::HybridPICSolveE ( Efield, current_fp_plasma, Jfield, Bfield, rhofield, *electron_pressure_fp, edge_lengths, lev, this, solve_for_Faraday ); - warpx.ApplyEfieldBoundary(lev, patch_type); + amrex::Real const time = warpx.gett_old(0) + warpx.getdt(0); + warpx.ApplyEfieldBoundary(lev, patch_type, time); } void HybridPICModel::CalculateElectronPressure() const @@ -556,6 +557,7 @@ void HybridPICModel::FieldPush ( HybridPICSolveE(Efield, Jfield, Bfield, rhofield, edge_lengths, true); warpx.FillBoundaryE(ng, nodal_sync); // Push forward the B-field using Faraday's law - warpx.EvolveB(dt, dt_type); + amrex::Real t_old = warpx.gett_old(0); + warpx.EvolveB(dt, dt_type, t_old); warpx.FillBoundaryB(ng, nodal_sync); } diff --git a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp index f558b3d9756..1090fd2e60a 100644 --- a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp @@ -71,7 +71,7 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, m_Eold.Copy( FieldType::Efield_fp ); // Advance WarpX owned Bfield_fp from t_{n} to t_{n+1/2} - m_WarpX->EvolveB(0.5_rt*m_dt, DtType::FirstHalf); + m_WarpX->EvolveB(0.5_rt*m_dt, DtType::FirstHalf, a_time); m_WarpX->FillBoundaryB(m_WarpX->getngEB(), true); const amrex::Real half_time = a_time + 0.5_rt*m_dt; @@ -82,7 +82,7 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, m_nlsolver->Solve( m_E, m_Eold, half_time, 0.5_rt*m_dt ); // Update WarpX owned Efield_fp to t_{n+1/2} - m_WarpX->SetElectricFieldAndApplyBCs( m_E ); + m_WarpX->SetElectricFieldAndApplyBCs( m_E, half_time ); // Advance particles from time n+1/2 to time n+1 m_WarpX->FinishImplicitParticleUpdate(); @@ -90,10 +90,11 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, // Advance Eg from time n+1/2 to time n+1 // Eg^{n+1} = 2.0*Eg^{n+1/2} - Eg^n m_E.linComb( 2._rt, m_E, -1._rt, m_Eold ); - m_WarpX->SetElectricFieldAndApplyBCs( m_E ); + const amrex::Real new_time = a_time + m_dt; + m_WarpX->SetElectricFieldAndApplyBCs( m_E, new_time ); // Advance WarpX owned Bfield_fp from t_{n+1/2} to t_{n+1} - m_WarpX->EvolveB(0.5_rt*m_dt, DtType::SecondHalf); + m_WarpX->EvolveB(0.5_rt*m_dt, DtType::SecondHalf, half_time); m_WarpX->FillBoundaryB(m_WarpX->getngEB(), true); } @@ -106,7 +107,7 @@ void SemiImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, { // Update WarpX-owned Efield_fp using current state of Eg from // the nonlinear solver at time n+theta - m_WarpX->SetElectricFieldAndApplyBCs( a_E ); + m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); // Update particle positions and velocities using the current state // of Eg and Bg. Deposit current density at time n+1/2 diff --git a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp index 501cbed10eb..1d129eaedad 100644 --- a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp @@ -70,7 +70,7 @@ void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, m_WarpX->SaveParticlesAtImplicitStepStart(); // Advance the fields to time n+1/2 source free - m_WarpX->SpectralSourceFreeFieldAdvance(); + m_WarpX->SpectralSourceFreeFieldAdvance(a_time); // Save the fields at the start of the step m_Eold.Copy( FieldType::Efield_fp ); @@ -93,7 +93,7 @@ void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, FinishFieldUpdate( new_time ); // Advance the fields to time n+1 source free - m_WarpX->SpectralSourceFreeFieldAdvance(); + m_WarpX->SpectralSourceFreeFieldAdvance(half_time); } @@ -120,20 +120,20 @@ void StrangImplicitSpectralEM::ComputeRHS ( WarpXSolverVec& a_RHS, } void StrangImplicitSpectralEM::UpdateWarpXFields (WarpXSolverVec const & a_E, - amrex::Real /*a_time*/ ) + amrex::Real a_time ) { // Update Efield_fp owned by WarpX - m_WarpX->SetElectricFieldAndApplyBCs( a_E ); + m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); } -void StrangImplicitSpectralEM::FinishFieldUpdate ( amrex::Real /*a_new_time*/ ) +void StrangImplicitSpectralEM::FinishFieldUpdate ( amrex::Real a_new_time ) { // Eg^{n+1} = 2*E_g^{n+1/2} - E_g^n amrex::Real const c0 = 1._rt/0.5_rt; amrex::Real const c1 = 1._rt - c0; m_E.linComb( c0, m_E, c1, m_Eold ); - m_WarpX->SetElectricFieldAndApplyBCs( m_E ); + m_WarpX->SetElectricFieldAndApplyBCs( m_E, a_new_time ); } diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp index 8ca592517ac..d8d1de69fe7 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp @@ -142,20 +142,18 @@ void ThetaImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, void ThetaImplicitEM::UpdateWarpXFields ( const WarpXSolverVec& a_E, amrex::Real a_time ) { - amrex::ignore_unused(a_time); // Update Efield_fp owned by WarpX - m_WarpX->SetElectricFieldAndApplyBCs( a_E ); + m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); // Update Bfield_fp owned by WarpX ablastr::fields::MultiLevelVectorField const& B_old = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::B_old, 0); - m_WarpX->UpdateMagneticFieldAndApplyBCs( B_old, m_theta*m_dt ); + m_WarpX->UpdateMagneticFieldAndApplyBCs( B_old, m_theta*m_dt, a_time ); } void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time ) { - amrex::ignore_unused(a_new_time); // Eg^{n+1} = (1/theta)*Eg^{n+theta} + (1-1/theta)*Eg^n // Bg^{n+1} = (1/theta)*Bg^{n+theta} + (1-1/theta)*Bg^n @@ -163,8 +161,8 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time ) const amrex::Real c0 = 1._rt/m_theta; const amrex::Real c1 = 1._rt - c0; m_E.linComb( c0, m_E, c1, m_Eold ); - m_WarpX->SetElectricFieldAndApplyBCs( m_E ); + m_WarpX->SetElectricFieldAndApplyBCs( m_E, a_new_time ); ablastr::fields::MultiLevelVectorField const & B_old = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::B_old, 0); - m_WarpX->FinishMagneticFieldAndApplyBCs( B_old, m_theta ); + m_WarpX->FinishMagneticFieldAndApplyBCs( B_old, m_theta, a_new_time ); } diff --git a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp index b1872ab7dba..ec1b0abda25 100644 --- a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp +++ b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp @@ -70,7 +70,7 @@ WarpX::ImplicitPreRHSOp ( amrex::Real a_cur_time, } void -WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E ) +WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( a_E.getArrayVecType()==warpx::fields::FieldType::Efield_fp, @@ -84,12 +84,12 @@ WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E ) amrex::MultiFab::Copy(*Efield_fp[0][1], *Evec[0][1], 0, 0, ncomps, Evec[0][1]->nGrowVect()); amrex::MultiFab::Copy(*Efield_fp[0][2], *Evec[0][2], 0, 0, ncomps, Evec[0][2]->nGrowVect()); FillBoundaryE(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points); - ApplyEfieldBoundary(0, PatchType::fine); + ApplyEfieldBoundary(0, PatchType::fine, a_time); } void WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_thetadt ) + amrex::Real a_thetadt, amrex::Real a_time ) { using ablastr::fields::Direction; using warpx::fields::FieldType; @@ -100,23 +100,23 @@ WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField co amrex::MultiFab::Copy(*Bfp[1], *a_Bn[lev][1], 0, 0, ncomps, a_Bn[lev][1]->nGrowVect()); amrex::MultiFab::Copy(*Bfp[2], *a_Bn[lev][2], 0, 0, ncomps, a_Bn[lev][2]->nGrowVect()); } - EvolveB(a_thetadt, DtType::Full); + EvolveB(a_thetadt, DtType::Full, a_time); FillBoundaryB(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points); } void WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_theta ) + amrex::Real a_theta, amrex::Real a_time ) { using warpx::fields::FieldType; FinishImplicitField(m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, 0), a_Bn, a_theta); - ApplyBfieldBoundary(0, PatchType::fine, DtType::Full); + ApplyBfieldBoundary(0, PatchType::fine, DtType::Full, a_time); FillBoundaryB(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points); } void -WarpX::SpectralSourceFreeFieldAdvance () +WarpX::SpectralSourceFreeFieldAdvance (amrex::Real cur_time) { using namespace amrex::literals; using warpx::fields::FieldType; @@ -142,7 +142,7 @@ WarpX::SpectralSourceFreeFieldAdvance () current_fp[1]->setVal(0._rt); current_fp[2]->setVal(0._rt); if (rho_fp) { rho_fp->setVal(0._rt); } - PushPSATD(); // Note that this does dt/2 + PushPSATD(cur_time); // 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); diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolver.H b/Source/FieldSolver/SpectralSolver/SpectralSolver.H index bcd80e421a8..a298b64ff95 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolver.H +++ b/Source/FieldSolver/SpectralSolver/SpectralSolver.H @@ -198,6 +198,9 @@ class SpectralSolver SpectralFieldIndex m_spectral_index; + // Solve time step size + amrex::Real m_dt; + protected: amrex::IntVect m_fill_guards; diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp index fcd52597e07..59f7c2d6d38 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp @@ -42,6 +42,7 @@ SpectralSolver::SpectralSolver ( const RhoInTime rho_in_time, const bool dive_cleaning, const bool divb_cleaning) + : m_dt(dt) { // Initialize all structures using the same distribution mapping dm diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H index 61cf64036eb..7e1a4f970d2 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H @@ -152,6 +152,9 @@ class SpectralSolverRZ SpectralFieldIndex m_spectral_index; + // Solve time step size + amrex::Real m_dt; + private: SpectralKSpaceRZ k_space; // Save the instance to initialize filtering diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp index 9a8cff9f1f3..36b6ae8d18f 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp @@ -40,7 +40,7 @@ SpectralSolverRZ::SpectralSolverRZ (const int lev, const RhoInTime rho_in_time, const bool dive_cleaning, const bool divb_cleaning) - : k_space(realspace_ba, dm, dx) + : k_space(realspace_ba, dm, dx), m_dt(dt) { // Initialize all structures using the same distribution mapping dm diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index fd786dc65ba..278694a2da0 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -714,7 +714,7 @@ WarpX::PSATDScaleAverageFields (const amrex::Real scale_factor) #endif // WARPX_USE_FFT void -WarpX::PushPSATD () +WarpX::PushPSATD (amrex::Real cur_time) { #ifndef WARPX_USE_FFT WARPX_ABORT_WITH_MESSAGE( @@ -859,26 +859,28 @@ WarpX::PushPSATD () if (WarpX::do_dive_cleaning) { PSATDBackwardTransformF(); } if (WarpX::do_divb_cleaning) { PSATDBackwardTransformG(); } - // Evolve the fields in the PML boxes for (int lev = 0; lev <= finest_level; ++lev) { + // Evolve the fields in the PML boxes if (pml[lev] && pml[lev]->ok()) { pml[lev]->PushPSATD(m_fields, lev); } - ApplyEfieldBoundary(lev, PatchType::fine); - if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse); } - ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf); - if (lev > 0) { ApplyBfieldBoundary(lev, PatchType::coarse, DtType::FirstHalf); } + + amrex::Real const new_time = cur_time + spectral_solver_fp[lev].get_dt(); + ApplyEfieldBoundary(lev, PatchType::fine, new_time); + if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse, new_time); } + ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf, new_time); + if (lev > 0) { ApplyBfieldBoundary(lev, PatchType::coarse, DtType::FirstHalf, new_time); } } #endif } void -WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type) +WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) { for (int lev = 0; lev <= finest_level; ++lev) { - EvolveB(lev, a_dt, a_dt_type); + EvolveB(lev, a_dt, a_dt_type, cur_time); } // Allow execution of Python callback after B-field push @@ -886,18 +888,18 @@ WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type) } void -WarpX::EvolveB (int lev, amrex::Real a_dt, DtType a_dt_type) +WarpX::EvolveB (int lev, amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) { WARPX_PROFILE("WarpX::EvolveB()"); - EvolveB(lev, PatchType::fine, a_dt, a_dt_type); + EvolveB(lev, PatchType::fine, a_dt, a_dt_type, cur_time); if (lev > 0) { - EvolveB(lev, PatchType::coarse, a_dt, a_dt_type); + EvolveB(lev, PatchType::coarse, a_dt, a_dt_type, cur_time); } } void -WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_type) +WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) { // Evolve B field in regular cells if (patch_type == PatchType::fine) { @@ -923,16 +925,17 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_typ } } - ApplyBfieldBoundary(lev, patch_type, a_dt_type); + amrex::Real const new_time = cur_time + a_dt; + ApplyBfieldBoundary(lev, patch_type, a_dt_type, new_time); } void -WarpX::EvolveE (amrex::Real a_dt) +WarpX::EvolveE (amrex::Real a_dt, amrex::Real cur_time) { for (int lev = 0; lev <= finest_level; ++lev) { - EvolveE(lev, a_dt); + EvolveE(lev, a_dt, cur_time); } // Allow execution of Python callback after E-field push @@ -940,18 +943,18 @@ WarpX::EvolveE (amrex::Real a_dt) } void -WarpX::EvolveE (int lev, amrex::Real a_dt) +WarpX::EvolveE (int lev, amrex::Real a_dt, amrex::Real cur_time) { WARPX_PROFILE("WarpX::EvolveE()"); - EvolveE(lev, PatchType::fine, a_dt); + EvolveE(lev, PatchType::fine, a_dt, cur_time); if (lev > 0) { - EvolveE(lev, PatchType::coarse, a_dt); + EvolveE(lev, PatchType::coarse, a_dt, cur_time); } } void -WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) +WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real cur_time) { // Evolve E field in regular cells if (patch_type == PatchType::fine) { @@ -987,7 +990,8 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) } } - ApplyEfieldBoundary(lev, patch_type); + amrex::Real const new_time = cur_time + a_dt; + ApplyEfieldBoundary(lev, patch_type, new_time); // ECTRhofield must be recomputed at the very end of the Efield update to ensure // that ECTRhofield is consistent with Efield @@ -1118,15 +1122,15 @@ WarpX::EvolveG (int lev, PatchType patch_type, amrex::Real a_dt, DtType /*a_dt_t } void -WarpX::MacroscopicEvolveE (amrex::Real a_dt) +WarpX::MacroscopicEvolveE (amrex::Real a_dt, amrex::Real cur_time) { for (int lev = 0; lev <= finest_level; ++lev ) { - MacroscopicEvolveE(lev, a_dt); + MacroscopicEvolveE(lev, a_dt, cur_time); } } void -WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt) { +WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt, amrex::Real cur_time) { WARPX_PROFILE("WarpX::MacroscopicEvolveE()"); @@ -1135,11 +1139,11 @@ WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt) { "Macroscopic EvolveE is not implemented for lev>0, yet." ); - MacroscopicEvolveE(lev, PatchType::fine, a_dt); + MacroscopicEvolveE(lev, PatchType::fine, a_dt, cur_time); } void -WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt) { +WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real cur_time) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( patch_type == PatchType::fine, @@ -1171,7 +1175,8 @@ WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt) { } } - ApplyEfieldBoundary(lev, patch_type); + amrex::Real const new_time = cur_time + a_dt; + ApplyEfieldBoundary(lev, patch_type, new_time); } void diff --git a/Source/WarpX.H b/Source/WarpX.H index 574478f4774..1a33331ba25 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -142,12 +142,12 @@ public: bool a_from_jacobian ); void SaveParticlesAtImplicitStepStart (); void FinishImplicitParticleUpdate (); - void SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E ); + void SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ); void UpdateMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_thetadt ); - void SpectralSourceFreeFieldAdvance (); + amrex::Real a_thetadt, amrex::Real a_time ); + void SpectralSourceFreeFieldAdvance ( amrex::Real a_time); void FinishMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_theta ); + amrex::Real a_theta, amrex::Real a_time ); void FinishImplicitField ( const ablastr::fields::MultiLevelVectorField& Field_fp, const ablastr::fields::MultiLevelVectorField& Field_n, amrex::Real theta ); @@ -542,22 +542,22 @@ public: void UpdateInjectionPosition (amrex::Real dt); void ResetProbDomain (const amrex::RealBox& rb); - void EvolveE ( amrex::Real dt); - void EvolveE (int lev, amrex::Real dt); - void EvolveB ( amrex::Real dt, DtType dt_type); - void EvolveB (int lev, amrex::Real dt, DtType dt_type); + void EvolveE ( amrex::Real dt, amrex::Real cur_time); + void EvolveE (int lev, amrex::Real dt, amrex::Real cur_time); + void EvolveB ( amrex::Real dt, DtType dt_type, amrex::Real cur_time); + void EvolveB (int lev, amrex::Real dt, DtType dt_type, amrex::Real cur_time); void EvolveF ( amrex::Real dt, DtType dt_type); void EvolveF (int lev, amrex::Real dt, DtType dt_type); void EvolveG ( amrex::Real dt, DtType dt_type); void EvolveG (int lev, amrex::Real dt, DtType dt_type); - void EvolveB (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); - void EvolveE (int lev, PatchType patch_type, amrex::Real dt); + void EvolveB (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type, amrex::Real cur_time); + void EvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real cur_time); void EvolveF (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); void EvolveG (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); - void MacroscopicEvolveE ( amrex::Real dt); - void MacroscopicEvolveE (int lev, amrex::Real dt); - void MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real dt); + void MacroscopicEvolveE ( amrex::Real dt, amrex::Real cur_time); + void MacroscopicEvolveE (int lev, amrex::Real dt, amrex::Real cur_time); + void MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real cur_time); /** * \brief Hybrid-PIC field evolve function. @@ -672,8 +672,8 @@ public: amrex::MultiFab* Jy, amrex::MultiFab* Jz, PatchType patch_type); - void ApplyEfieldBoundary (int lev, PatchType patch_type); - void ApplyBfieldBoundary (int lev, PatchType patch_type, DtType dt_type); + void ApplyEfieldBoundary (int lev, PatchType patch_type, amrex::Real cur_time); + void ApplyBfieldBoundary (int lev, PatchType patch_type, DtType dt_type, amrex::Real cur_time); #ifdef WARPX_DIM_RZ // Applies the boundary conditions that are specific to the axis when in RZ. @@ -1606,7 +1606,7 @@ private: */ void ExplicitFillBoundaryEBUpdateAux (); - void PushPSATD (); + void PushPSATD (amrex::Real cur_time); #ifdef WARPX_USE_FFT From 7214cd828215c35a2e6b9773661fa4f5a3a05739 Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 26 Nov 2024 12:47:29 -0800 Subject: [PATCH 02/11] Fix use of m_dt for spectral solver --- Source/FieldSolver/WarpXPushFieldsEM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index 278694a2da0..5fe2b39f167 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -867,7 +867,7 @@ WarpX::PushPSATD (amrex::Real cur_time) pml[lev]->PushPSATD(m_fields, lev); } - amrex::Real const new_time = cur_time + spectral_solver_fp[lev].get_dt(); + amrex::Real const new_time = cur_time + spectral_solver_fp[lev]->m_dt; ApplyEfieldBoundary(lev, PatchType::fine, new_time); if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse, new_time); } ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf, new_time); From a129cc301fb36756f3bff069b9f1d3396d52a600 Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 26 Nov 2024 12:54:15 -0800 Subject: [PATCH 03/11] Fix unused variable --- Source/FieldSolver/WarpXPushFieldsEM.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index 5fe2b39f167..f25f708bafb 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -717,6 +717,7 @@ void WarpX::PushPSATD (amrex::Real cur_time) { #ifndef WARPX_USE_FFT + amrex::ignore_unused(cur_time); WARPX_ABORT_WITH_MESSAGE( "PushFieldsEM: PSATD solver selected but not built"); #else From 8761d94c07d69546413e72e467dbd08150e44241 Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 2 Dec 2024 09:17:41 -0800 Subject: [PATCH 04/11] Fix initialization order in SpectralSolverRZ --- Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp index 36b6ae8d18f..7672b646b2e 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp @@ -40,7 +40,7 @@ SpectralSolverRZ::SpectralSolverRZ (const int lev, const RhoInTime rho_in_time, const bool dive_cleaning, const bool divb_cleaning) - : k_space(realspace_ba, dm, dx), m_dt(dt) + : m_dt(dt), k_space(realspace_ba, dm, dx) { // Initialize all structures using the same distribution mapping dm From 8ac2710f76eaf5632d11bbfd5f843eff348e2976 Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 2 Dec 2024 09:20:31 -0800 Subject: [PATCH 05/11] Uodate test_2d_pec_field_insulator.json --- .../benchmarks_json/test_2d_pec_field_insulator.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Regression/Checksum/benchmarks_json/test_2d_pec_field_insulator.json b/Regression/Checksum/benchmarks_json/test_2d_pec_field_insulator.json index 622cb5e5d30..b389856e66b 100644 --- a/Regression/Checksum/benchmarks_json/test_2d_pec_field_insulator.json +++ b/Regression/Checksum/benchmarks_json/test_2d_pec_field_insulator.json @@ -1,11 +1,11 @@ { "lev=0": { "Bx": 0.0, - "By": 0.33065279639752304, + "By": 0.3605690508580849, "Bz": 0.0, - "Ex": 31873416.396984838, + "Ex": 37101418.32484252, "Ey": 0.0, - "Ez": 99285542.27022335, + "Ez": 108228802.9434361, "jx": 0.0, "jy": 0.0, "jz": 0.0 From 08c1b13e2ec5b597a05cb16591669bfe9f1fd344 Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 2 Dec 2024 11:55:30 -0800 Subject: [PATCH 06/11] Fix const --- .../FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp index fd6be29172b..20989cbeca9 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp @@ -557,7 +557,7 @@ void HybridPICModel::FieldPush ( HybridPICSolveE(Efield, Jfield, Bfield, rhofield, edge_lengths, true); warpx.FillBoundaryE(ng, nodal_sync); // Push forward the B-field using Faraday's law - amrex::Real t_old = warpx.gett_old(0); + amrex::Real const t_old = warpx.gett_old(0); warpx.EvolveB(dt, dt_type, t_old); warpx.FillBoundaryB(ng, nodal_sync); } From d9afee247db0216c20361e18a94ee04753cf050c Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 2 Dec 2024 11:56:42 -0800 Subject: [PATCH 07/11] Fix routine parameter name --- Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp index ec1b0abda25..068cffd9f75 100644 --- a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp +++ b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp @@ -116,7 +116,7 @@ WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField co } void -WarpX::SpectralSourceFreeFieldAdvance (amrex::Real cur_time) +WarpX::SpectralSourceFreeFieldAdvance (amrex::Real a_time) { using namespace amrex::literals; using warpx::fields::FieldType; @@ -142,7 +142,7 @@ WarpX::SpectralSourceFreeFieldAdvance (amrex::Real cur_time) current_fp[1]->setVal(0._rt); current_fp[2]->setVal(0._rt); if (rho_fp) { rho_fp->setVal(0._rt); } - PushPSATD(cur_time); // Note that this does dt/2 + PushPSATD(a_time); // 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); From 2c45815bb7cd2e1e8b7edb6403a3a21eac264750 Mon Sep 17 00:00:00 2001 From: David Grote Date: Fri, 6 Dec 2024 10:50:09 -0800 Subject: [PATCH 08/11] Fix times in ThetaImplicitEM.H --- .../FieldSolver/ImplicitSolvers/ThetaImplicitEM.H | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H index 7461b77fb51..ea1f227f17f 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H @@ -67,13 +67,20 @@ public: void PrintParameters () const override; - void OneStep ( amrex::Real a_time, + /** + * \brief Advances the simulation one time step + * + * \param[in] start_time The time at the start of the time step + * \param[in] a_dt The time step size + * \param[in] a_step The time step number + */ + void OneStep ( amrex::Real start_time, amrex::Real a_dt, int a_step ) override; void ComputeRHS ( WarpXSolverVec& a_RHS, const WarpXSolverVec& a_E, - amrex::Real a_time, + amrex::Real start_time, int a_nl_iter, bool a_from_jacobian ) override; @@ -98,7 +105,7 @@ private: * \brief Update the E and B fields owned by WarpX */ void UpdateWarpXFields ( const WarpXSolverVec& a_E, - amrex::Real a_time ); + amrex::Real start_time ); /** * \brief Nonlinear solver is for the time-centered values of E. After From 793059bb956b72350dda0a0bdb4e51c82301a495 Mon Sep 17 00:00:00 2001 From: David Grote Date: Fri, 6 Dec 2024 11:14:39 -0800 Subject: [PATCH 09/11] Multiple fixes Get the timing correct in ThetaImplicitEM.cpp Update variable names to be more precise in the time notation --- .../ImplicitSolvers/SemiImplicitEM.H | 4 +- .../ImplicitSolvers/SemiImplicitEM.cpp | 14 +++--- .../StrangImplicitSpectralEM.H | 6 +-- .../StrangImplicitSpectralEM.cpp | 18 ++++---- .../ImplicitSolvers/ThetaImplicitEM.cpp | 32 ++++++------- .../ImplicitSolvers/WarpXImplicitOps.cpp | 24 +++++----- Source/FieldSolver/WarpXPushFieldsEM.cpp | 46 +++++++++---------- Source/WarpX.H | 44 +++++++++--------- 8 files changed, 94 insertions(+), 94 deletions(-) diff --git a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.H b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.H index b6c808e0ab9..62401d7b48f 100644 --- a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.H +++ b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.H @@ -57,13 +57,13 @@ public: void PrintParameters () const override; - void OneStep ( amrex::Real a_time, + void OneStep ( amrex::Real start_time, amrex::Real a_dt, int a_step ) override; void ComputeRHS ( WarpXSolverVec& a_RHS, const WarpXSolverVec& a_E, - amrex::Real a_time, + amrex::Real half_time, int a_nl_iter, bool a_from_jacobian ) override; diff --git a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp index 1090fd2e60a..41fdf515581 100644 --- a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp @@ -52,7 +52,7 @@ void SemiImplicitEM::PrintParameters () const amrex::Print() << "-----------------------------------------------------------\n\n"; } -void SemiImplicitEM::OneStep ( amrex::Real a_time, +void SemiImplicitEM::OneStep ( amrex::Real start_time, amrex::Real a_dt, int a_step ) { @@ -71,10 +71,10 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, m_Eold.Copy( FieldType::Efield_fp ); // Advance WarpX owned Bfield_fp from t_{n} to t_{n+1/2} - m_WarpX->EvolveB(0.5_rt*m_dt, DtType::FirstHalf, a_time); + m_WarpX->EvolveB(0.5_rt*m_dt, DtType::FirstHalf, start_time); m_WarpX->FillBoundaryB(m_WarpX->getngEB(), true); - const amrex::Real half_time = a_time + 0.5_rt*m_dt; + const amrex::Real half_time = start_time + 0.5_rt*m_dt; // Solve nonlinear system for Eg at t_{n+1/2} // Particles will be advanced to t_{n+1/2} @@ -90,7 +90,7 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, // Advance Eg from time n+1/2 to time n+1 // Eg^{n+1} = 2.0*Eg^{n+1/2} - Eg^n m_E.linComb( 2._rt, m_E, -1._rt, m_Eold ); - const amrex::Real new_time = a_time + m_dt; + const amrex::Real new_time = start_time + m_dt; m_WarpX->SetElectricFieldAndApplyBCs( m_E, new_time ); // Advance WarpX owned Bfield_fp from t_{n+1/2} to t_{n+1} @@ -101,17 +101,17 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, void SemiImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, const WarpXSolverVec& a_E, - amrex::Real a_time, + amrex::Real half_time, int a_nl_iter, bool a_from_jacobian ) { // Update WarpX-owned Efield_fp using current state of Eg from // the nonlinear solver at time n+theta - m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); + m_WarpX->SetElectricFieldAndApplyBCs( a_E, half_time ); // Update particle positions and velocities using the current state // of Eg and Bg. Deposit current density at time n+1/2 - m_WarpX->ImplicitPreRHSOp( a_time, m_dt, a_nl_iter, a_from_jacobian ); + m_WarpX->ImplicitPreRHSOp( half_time, m_dt, a_nl_iter, a_from_jacobian ); // RHS = cvac^2*0.5*dt*( curl(Bg^{n+1/2}) - mu0*Jg^{n+1/2} ) m_WarpX->ImplicitComputeRHSE(0.5_rt*m_dt, a_RHS); diff --git a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.H b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.H index d1587cfb9d1..fcfcb9821a7 100644 --- a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.H +++ b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.H @@ -58,13 +58,13 @@ public: void PrintParameters () const override; - void OneStep ( amrex::Real a_time, + void OneStep ( amrex::Real start_time, amrex::Real a_dt, int a_step ) override; void ComputeRHS ( WarpXSolverVec& a_RHS, const WarpXSolverVec& a_E, - amrex::Real a_time, + amrex::Real half_time, int a_nl_iter, bool a_from_jacobian ) override; @@ -92,7 +92,7 @@ private: * \brief Update the E and B fields owned by WarpX */ void UpdateWarpXFields ( WarpXSolverVec const& a_E, - amrex::Real a_time ); + amrex::Real half_time ); /** * \brief Nonlinear solver is for the time-centered values of E. After diff --git a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp index 1d129eaedad..cd672f18f98 100644 --- a/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/StrangImplicitSpectralEM.cpp @@ -54,7 +54,7 @@ void StrangImplicitSpectralEM::PrintParameters () const amrex::Print() << "-----------------------------------------------------------\n\n"; } -void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, +void StrangImplicitSpectralEM::OneStep ( amrex::Real start_time, amrex::Real a_dt, int a_step ) { @@ -70,13 +70,13 @@ void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, m_WarpX->SaveParticlesAtImplicitStepStart(); // Advance the fields to time n+1/2 source free - m_WarpX->SpectralSourceFreeFieldAdvance(a_time); + m_WarpX->SpectralSourceFreeFieldAdvance(start_time); // Save the fields at the start of the step m_Eold.Copy( FieldType::Efield_fp ); m_E.Copy(m_Eold); // initial guess for E - amrex::Real const half_time = a_time + 0.5_rt*m_dt; + amrex::Real const half_time = start_time + 0.5_rt*m_dt; // Solve nonlinear system for E at t_{n+1/2} // Particles will be advanced to t_{n+1/2} @@ -89,7 +89,7 @@ void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, m_WarpX->FinishImplicitParticleUpdate(); // Advance E and B fields from time n+1/2 to time n+1 - amrex::Real const new_time = a_time + m_dt; + amrex::Real const new_time = start_time + m_dt; FinishFieldUpdate( new_time ); // Advance the fields to time n+1 source free @@ -99,17 +99,17 @@ void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time, void StrangImplicitSpectralEM::ComputeRHS ( WarpXSolverVec& a_RHS, WarpXSolverVec const & a_E, - amrex::Real a_time, + amrex::Real half_time, int a_nl_iter, bool a_from_jacobian ) { // Update WarpX-owned Efield_fp and Bfield_fp using current state of // E from the nonlinear solver at time n+1/2 - UpdateWarpXFields( a_E, a_time ); + UpdateWarpXFields( a_E, half_time ); // Self consistently update particle positions and velocities using the // current state of the fields E and B. Deposit current density at time n+1/2. - m_WarpX->ImplicitPreRHSOp( a_time, m_dt, a_nl_iter, a_from_jacobian ); + m_WarpX->ImplicitPreRHSOp( half_time, m_dt, a_nl_iter, a_from_jacobian ); // For Strang split implicit PSATD, the RHS = -dt*mu*c**2*J bool const allow_type_mismatch = true; @@ -120,11 +120,11 @@ void StrangImplicitSpectralEM::ComputeRHS ( WarpXSolverVec& a_RHS, } void StrangImplicitSpectralEM::UpdateWarpXFields (WarpXSolverVec const & a_E, - amrex::Real a_time ) + amrex::Real half_time ) { // Update Efield_fp owned by WarpX - m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); + m_WarpX->SetElectricFieldAndApplyBCs( a_E, half_time ); } diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp index d8d1de69fe7..aa6ee63f7df 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp @@ -74,7 +74,7 @@ void ThetaImplicitEM::PrintParameters () const amrex::Print() << "-----------------------------------------------------------\n\n"; } -void ThetaImplicitEM::OneStep ( const amrex::Real a_time, +void ThetaImplicitEM::OneStep ( const amrex::Real start_time, const amrex::Real a_dt, const int a_step ) { @@ -102,57 +102,57 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time, } } - const amrex::Real theta_time = a_time + m_theta*m_dt; - // Solve nonlinear system for Eg at t_{n+theta} // Particles will be advanced to t_{n+1/2} m_E.Copy(m_Eold); // initial guess for Eg^{n+theta} - m_nlsolver->Solve( m_E, m_Eold, theta_time, m_theta*m_dt ); + m_nlsolver->Solve( m_E, m_Eold, start_time, m_theta*m_dt ); // Update WarpX owned Efield_fp and Bfield_fp to t_{n+theta} - UpdateWarpXFields( m_E, theta_time ); + UpdateWarpXFields( m_E, start_time ); // Advance particles from time n+1/2 to time n+1 m_WarpX->FinishImplicitParticleUpdate(); // Advance Eg and Bg from time n+theta to time n+1 - const amrex::Real new_time = a_time + m_dt; - FinishFieldUpdate( new_time ); + const amrex::Real end_time = start_time + m_dt; + FinishFieldUpdate( end_time ); } void ThetaImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, const WarpXSolverVec& a_E, - amrex::Real a_time, + amrex::Real start_time, int a_nl_iter, bool a_from_jacobian ) { // Update WarpX-owned Efield_fp and Bfield_fp using current state of // Eg from the nonlinear solver at time n+theta - UpdateWarpXFields( a_E, a_time ); + UpdateWarpXFields( a_E, start_time ); // Update particle positions and velocities using the current state // of Eg and Bg. Deposit current density at time n+1/2 - m_WarpX->ImplicitPreRHSOp( a_time, m_dt, a_nl_iter, a_from_jacobian ); + const amrex::Real theta_time = start_time + m_theta*m_dt; + m_WarpX->ImplicitPreRHSOp( theta_time, m_dt, a_nl_iter, a_from_jacobian ); // RHS = cvac^2*m_theta*dt*( curl(Bg^{n+theta}) - mu0*Jg^{n+1/2} ) m_WarpX->ImplicitComputeRHSE( m_theta*m_dt, a_RHS); } void ThetaImplicitEM::UpdateWarpXFields ( const WarpXSolverVec& a_E, - amrex::Real a_time ) + amrex::Real start_time ) { // Update Efield_fp owned by WarpX - m_WarpX->SetElectricFieldAndApplyBCs( a_E, a_time ); + const amrex::Real theta_time = start_time + m_theta*m_dt; + m_WarpX->SetElectricFieldAndApplyBCs( a_E, theta_time ); // Update Bfield_fp owned by WarpX ablastr::fields::MultiLevelVectorField const& B_old = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::B_old, 0); - m_WarpX->UpdateMagneticFieldAndApplyBCs( B_old, m_theta*m_dt, a_time ); + m_WarpX->UpdateMagneticFieldAndApplyBCs( B_old, m_theta*m_dt, start_time ); } -void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time ) +void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real end_time ) { // Eg^{n+1} = (1/theta)*Eg^{n+theta} + (1-1/theta)*Eg^n @@ -161,8 +161,8 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time ) const amrex::Real c0 = 1._rt/m_theta; const amrex::Real c1 = 1._rt - c0; m_E.linComb( c0, m_E, c1, m_Eold ); - m_WarpX->SetElectricFieldAndApplyBCs( m_E, a_new_time ); + m_WarpX->SetElectricFieldAndApplyBCs( m_E, end_time ); ablastr::fields::MultiLevelVectorField const & B_old = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::B_old, 0); - m_WarpX->FinishMagneticFieldAndApplyBCs( B_old, m_theta, a_new_time ); + m_WarpX->FinishMagneticFieldAndApplyBCs( B_old, m_theta, end_time ); } diff --git a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp index 068cffd9f75..eaf96cf77ec 100644 --- a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp +++ b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp @@ -70,7 +70,7 @@ WarpX::ImplicitPreRHSOp ( amrex::Real a_cur_time, } void -WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ) +WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( a_E.getArrayVecType()==warpx::fields::FieldType::Efield_fp, @@ -88,8 +88,8 @@ WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_t } void -WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_thetadt, amrex::Real a_time ) +WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, + amrex::Real a_thetadt, amrex::Real start_time ) { using ablastr::fields::Direction; using warpx::fields::FieldType; @@ -100,12 +100,12 @@ WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField co amrex::MultiFab::Copy(*Bfp[1], *a_Bn[lev][1], 0, 0, ncomps, a_Bn[lev][1]->nGrowVect()); amrex::MultiFab::Copy(*Bfp[2], *a_Bn[lev][2], 0, 0, ncomps, a_Bn[lev][2]->nGrowVect()); } - EvolveB(a_thetadt, DtType::Full, a_time); + EvolveB(a_thetadt, DtType::Full, start_time); FillBoundaryB(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points); } void -WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, +WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, amrex::Real a_theta, amrex::Real a_time ) { using warpx::fields::FieldType; @@ -116,7 +116,7 @@ WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField co } void -WarpX::SpectralSourceFreeFieldAdvance (amrex::Real a_time) +WarpX::SpectralSourceFreeFieldAdvance (amrex::Real start_time) { using namespace amrex::literals; using warpx::fields::FieldType; @@ -142,7 +142,7 @@ WarpX::SpectralSourceFreeFieldAdvance (amrex::Real a_time) current_fp[1]->setVal(0._rt); current_fp[2]->setVal(0._rt); if (rho_fp) { rho_fp->setVal(0._rt); } - PushPSATD(a_time); // Note that this does dt/2 + PushPSATD(start_time); // 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); @@ -294,8 +294,8 @@ WarpX::FinishImplicitParticleUpdate () } void -WarpX::FinishImplicitField( ablastr::fields::MultiLevelVectorField const& Field_fp, - ablastr::fields::MultiLevelVectorField const& Field_n, +WarpX::FinishImplicitField( ablastr::fields::MultiLevelVectorField const& Field_fp, + ablastr::fields::MultiLevelVectorField const& Field_n, amrex::Real theta ) { using namespace amrex::literals; @@ -345,7 +345,7 @@ WarpX::FinishImplicitField( ablastr::fields::MultiLevelVectorField const& Field } void -WarpX::ImplicitComputeRHSE (amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) +WarpX::ImplicitComputeRHSE (amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) { for (int lev = 0; lev <= finest_level; ++lev) { @@ -354,7 +354,7 @@ WarpX::ImplicitComputeRHSE (amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) } void -WarpX::ImplicitComputeRHSE (int lev, amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) +WarpX::ImplicitComputeRHSE (int lev, amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) { WARPX_PROFILE("WarpX::ImplicitComputeRHSE()"); ImplicitComputeRHSE(lev, PatchType::fine, a_dt, a_Erhs_vec); @@ -365,7 +365,7 @@ WarpX::ImplicitComputeRHSE (int lev, amrex::Real a_dt, WarpXSolverVec& a_Erhs_v } void -WarpX::ImplicitComputeRHSE (int lev, PatchType patch_type, amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) +WarpX::ImplicitComputeRHSE (int lev, PatchType patch_type, amrex::Real a_dt, WarpXSolverVec& a_Erhs_vec) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( a_Erhs_vec.getArrayVecType()==warpx::fields::FieldType::Efield_fp, diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index f25f708bafb..24640fc63c7 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -714,10 +714,10 @@ WarpX::PSATDScaleAverageFields (const amrex::Real scale_factor) #endif // WARPX_USE_FFT void -WarpX::PushPSATD (amrex::Real cur_time) +WarpX::PushPSATD (amrex::Real start_time) { #ifndef WARPX_USE_FFT - amrex::ignore_unused(cur_time); + amrex::ignore_unused(start_time); WARPX_ABORT_WITH_MESSAGE( "PushFieldsEM: PSATD solver selected but not built"); #else @@ -868,7 +868,7 @@ WarpX::PushPSATD (amrex::Real cur_time) pml[lev]->PushPSATD(m_fields, lev); } - amrex::Real const new_time = cur_time + spectral_solver_fp[lev]->m_dt; + amrex::Real const new_time = start_time + spectral_solver_fp[lev]->m_dt; ApplyEfieldBoundary(lev, PatchType::fine, new_time); if (lev > 0) { ApplyEfieldBoundary(lev, PatchType::coarse, new_time); } ApplyBfieldBoundary(lev, PatchType::fine, DtType::FirstHalf, new_time); @@ -878,10 +878,10 @@ WarpX::PushPSATD (amrex::Real cur_time) } void -WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) +WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type, amrex::Real start_time) { for (int lev = 0; lev <= finest_level; ++lev) { - EvolveB(lev, a_dt, a_dt_type, cur_time); + EvolveB(lev, a_dt, a_dt_type, start_time); } // Allow execution of Python callback after B-field push @@ -889,18 +889,18 @@ WarpX::EvolveB (amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) } void -WarpX::EvolveB (int lev, amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) +WarpX::EvolveB (int lev, amrex::Real a_dt, DtType a_dt_type, amrex::Real start_time) { WARPX_PROFILE("WarpX::EvolveB()"); - EvolveB(lev, PatchType::fine, a_dt, a_dt_type, cur_time); + EvolveB(lev, PatchType::fine, a_dt, a_dt_type, start_time); if (lev > 0) { - EvolveB(lev, PatchType::coarse, a_dt, a_dt_type, cur_time); + EvolveB(lev, PatchType::coarse, a_dt, a_dt_type, start_time); } } void -WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_type, amrex::Real cur_time) +WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_type, amrex::Real start_time) { // Evolve B field in regular cells if (patch_type == PatchType::fine) { @@ -926,17 +926,17 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_typ } } - amrex::Real const new_time = cur_time + a_dt; + amrex::Real const new_time = start_time + a_dt; ApplyBfieldBoundary(lev, patch_type, a_dt_type, new_time); } void -WarpX::EvolveE (amrex::Real a_dt, amrex::Real cur_time) +WarpX::EvolveE (amrex::Real a_dt, amrex::Real start_time) { for (int lev = 0; lev <= finest_level; ++lev) { - EvolveE(lev, a_dt, cur_time); + EvolveE(lev, a_dt, start_time); } // Allow execution of Python callback after E-field push @@ -944,18 +944,18 @@ WarpX::EvolveE (amrex::Real a_dt, amrex::Real cur_time) } void -WarpX::EvolveE (int lev, amrex::Real a_dt, amrex::Real cur_time) +WarpX::EvolveE (int lev, amrex::Real a_dt, amrex::Real start_time) { WARPX_PROFILE("WarpX::EvolveE()"); - EvolveE(lev, PatchType::fine, a_dt, cur_time); + EvolveE(lev, PatchType::fine, a_dt, start_time); if (lev > 0) { - EvolveE(lev, PatchType::coarse, a_dt, cur_time); + EvolveE(lev, PatchType::coarse, a_dt, start_time); } } void -WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real cur_time) +WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real start_time) { // Evolve E field in regular cells if (patch_type == PatchType::fine) { @@ -991,7 +991,7 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real cur } } - amrex::Real const new_time = cur_time + a_dt; + amrex::Real const new_time = start_time + a_dt; ApplyEfieldBoundary(lev, patch_type, new_time); // ECTRhofield must be recomputed at the very end of the Efield update to ensure @@ -1123,15 +1123,15 @@ WarpX::EvolveG (int lev, PatchType patch_type, amrex::Real a_dt, DtType /*a_dt_t } void -WarpX::MacroscopicEvolveE (amrex::Real a_dt, amrex::Real cur_time) +WarpX::MacroscopicEvolveE (amrex::Real a_dt, amrex::Real start_time) { for (int lev = 0; lev <= finest_level; ++lev ) { - MacroscopicEvolveE(lev, a_dt, cur_time); + MacroscopicEvolveE(lev, a_dt, start_time); } } void -WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt, amrex::Real cur_time) { +WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt, amrex::Real start_time) { WARPX_PROFILE("WarpX::MacroscopicEvolveE()"); @@ -1140,11 +1140,11 @@ WarpX::MacroscopicEvolveE (int lev, amrex::Real a_dt, amrex::Real cur_time) { "Macroscopic EvolveE is not implemented for lev>0, yet." ); - MacroscopicEvolveE(lev, PatchType::fine, a_dt, cur_time); + MacroscopicEvolveE(lev, PatchType::fine, a_dt, start_time); } void -WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real cur_time) { +WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amrex::Real start_time) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( patch_type == PatchType::fine, @@ -1176,7 +1176,7 @@ WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amre } } - amrex::Real const new_time = cur_time + a_dt; + amrex::Real const new_time = start_time + a_dt; ApplyEfieldBoundary(lev, patch_type, new_time); } diff --git a/Source/WarpX.H b/Source/WarpX.H index 1a33331ba25..41e93bcee84 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -136,21 +136,21 @@ public: // // Functions used by implicit solvers // - void ImplicitPreRHSOp ( amrex::Real cur_time, - amrex::Real a_full_dt, - int a_nl_iter, - bool a_from_jacobian ); + void ImplicitPreRHSOp ( amrex::Real cur_time, + amrex::Real a_full_dt, + int a_nl_iter, + bool a_from_jacobian ); void SaveParticlesAtImplicitStepStart (); void FinishImplicitParticleUpdate (); - void SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ); - void UpdateMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_thetadt, amrex::Real a_time ); - void SpectralSourceFreeFieldAdvance ( amrex::Real a_time); - void FinishMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, - amrex::Real a_theta, amrex::Real a_time ); - void FinishImplicitField ( const ablastr::fields::MultiLevelVectorField& Field_fp, - const ablastr::fields::MultiLevelVectorField& Field_n, - amrex::Real theta ); + void SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E, amrex::Real a_time ); + void UpdateMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, + amrex::Real a_thetadt, amrex::Real start_time ); + void SpectralSourceFreeFieldAdvance ( amrex::Real start_time); + void FinishMagneticFieldAndApplyBCs ( ablastr::fields::MultiLevelVectorField const& a_Bn, + amrex::Real a_theta, amrex::Real a_time ); + void FinishImplicitField ( const ablastr::fields::MultiLevelVectorField& Field_fp, + const ablastr::fields::MultiLevelVectorField& Field_n, + amrex::Real theta ); void ImplicitComputeRHSE ( amrex::Real dt, WarpXSolverVec& a_Erhs_vec); void ImplicitComputeRHSE (int lev, amrex::Real dt, WarpXSolverVec& a_Erhs_vec); void ImplicitComputeRHSE (int lev, PatchType patch_type, amrex::Real dt, WarpXSolverVec& a_Erhs_vec); @@ -542,22 +542,22 @@ public: void UpdateInjectionPosition (amrex::Real dt); void ResetProbDomain (const amrex::RealBox& rb); - void EvolveE ( amrex::Real dt, amrex::Real cur_time); - void EvolveE (int lev, amrex::Real dt, amrex::Real cur_time); - void EvolveB ( amrex::Real dt, DtType dt_type, amrex::Real cur_time); - void EvolveB (int lev, amrex::Real dt, DtType dt_type, amrex::Real cur_time); + void EvolveE ( amrex::Real dt, amrex::Real start_time); + void EvolveE (int lev, amrex::Real dt, amrex::Real start_time); + void EvolveB ( amrex::Real dt, DtType dt_type, amrex::Real start_time); + void EvolveB (int lev, amrex::Real dt, DtType dt_type, amrex::Real start_time); void EvolveF ( amrex::Real dt, DtType dt_type); void EvolveF (int lev, amrex::Real dt, DtType dt_type); void EvolveG ( amrex::Real dt, DtType dt_type); void EvolveG (int lev, amrex::Real dt, DtType dt_type); - void EvolveB (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type, amrex::Real cur_time); - void EvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real cur_time); + void EvolveB (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type, amrex::Real start_time); + void EvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real start_time); void EvolveF (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); void EvolveG (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); - void MacroscopicEvolveE ( amrex::Real dt, amrex::Real cur_time); - void MacroscopicEvolveE (int lev, amrex::Real dt, amrex::Real cur_time); - void MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real cur_time); + void MacroscopicEvolveE ( amrex::Real dt, amrex::Real start_time); + void MacroscopicEvolveE (int lev, amrex::Real dt, amrex::Real start_time); + void MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real dt, amrex::Real start_time); /** * \brief Hybrid-PIC field evolve function. From 518bf979edc9599a8a30e16814f9c714bc2e22f5 Mon Sep 17 00:00:00 2001 From: David Grote Date: Fri, 6 Dec 2024 17:24:22 -0800 Subject: [PATCH 10/11] Fix argument name of PushPSATD --- Source/WarpX.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WarpX.H b/Source/WarpX.H index 461c46926e0..73998d6faf2 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -1604,7 +1604,7 @@ private: */ void ExplicitFillBoundaryEBUpdateAux (); - void PushPSATD (amrex::Real cur_time); + void PushPSATD (amrex::Real start_time); #ifdef WARPX_USE_FFT From baf5d03b809b56dd9630600459d7a5cd50db438f Mon Sep 17 00:00:00 2001 From: David Grote Date: Fri, 6 Dec 2024 17:27:00 -0800 Subject: [PATCH 11/11] Fix name of argument for ThetaImplicitEM::FinishFieldUpdate --- Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H index ea1f227f17f..c9de6b82a00 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H @@ -111,7 +111,7 @@ private: * \brief Nonlinear solver is for the time-centered values of E. After * the solver, need to use m_E and m_Eold to compute E^{n+1} */ - void FinishFieldUpdate ( amrex::Real a_new_time ); + void FinishFieldUpdate ( amrex::Real end_time ); };