From fd3a0af43e8c4ff8513dc72854cf95929a365f1d Mon Sep 17 00:00:00 2001 From: Justin Angus Date: Mon, 26 Aug 2024 08:32:01 -0700 Subject: [PATCH] restoring comment change in implicit solvers. moved to separate PR. --- .../FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp | 14 +++++++------- .../ImplicitSolvers/ThetaImplicitEM.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp index d612061b1c9..47237b76768 100644 --- a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp @@ -59,7 +59,7 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, { amrex::ignore_unused(a_step); - // Fields have Eg^{n}, Bg^{n-1/2} + // Fields have E^{n}, B^{n-1/2} // Particles have p^{n} and x^{n}. // Save the values at the start of the time step, @@ -67,16 +67,16 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, // Save electric field at the start of the step m_Eold.Copy( FieldType::Efield_fp ); + m_E.Copy( m_Eold ); // initial guess for E - // Advance WarpX owned Bfield_fp to t_{n+1/2} + // Compute Bfield at time n+1/2 m_WarpX->EvolveB(a_dt, DtType::Full); m_WarpX->ApplyMagneticFieldBCs(); const amrex::Real half_time = a_time + 0.5_rt*a_dt; - // Solve nonlinear system for Eg at t_{n+1/2} + // Solve nonlinear system for E at t_{n+1/2} // Particles will be advanced to t_{n+1/2} - m_E.Copy( m_Eold ); // initial guess for Eg^{n+1/2} m_nlsolver->Solve( m_E, m_Eold, half_time, a_dt ); // Update WarpX owned Efield_fp to t_{n+1/2} @@ -85,8 +85,8 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time, // Advance particles from time n+1/2 to time n+1 m_WarpX->FinishImplicitParticleUpdate(); - // Advance Eg from time n+1/2 to time n+1 - // Eg^{n+1} = 2.0*Eg^{n+1/2} - Eg^n + // Advance E fields from time n+1/2 to time n+1 + // Eg^{n+1} = 2.0*E_g^{n+1/2} - E_g^n m_E.linComb( 2._rt, m_E, -1._rt, m_Eold ); m_WarpX->SetElectricFieldAndApplyBCs( m_E ); @@ -107,6 +107,6 @@ void SemiImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, // current state of the fields E and B. Deposit current density at time n+1/2. m_WarpX->ImplicitPreRHSOp( a_time, a_dt, a_nl_iter, a_from_jacobian ); - // RHS = cvac^2*0.5*dt*( curl(Bg^{n+1/2}) - mu0*Jg^{n+1/2} ) + // RHS = cvac^2*0.5*dt*( curl(B^{n+1/2}) - mu0*J^{n+1/2} ) m_WarpX->ImplicitComputeRHSE(0.5_rt*a_dt, a_RHS); } diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp index f50894ecb46..dca796fd133 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp @@ -80,7 +80,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time, { amrex::ignore_unused(a_step); - // Fields have Eg^{n} and Bg^{n} + // Fields have E^{n} and B^{n} // Particles have p^{n} and x^{n}. // Save the values at the start of the time step, @@ -88,6 +88,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time, // Save electric field at the start of the step m_Eold.Copy( FieldType::Efield_fp ); + m_E.Copy( m_Eold ); // initial guess for E const int num_levels = static_cast(m_Bold.size()); for (int lev = 0; lev < num_levels; ++lev) { @@ -100,9 +101,8 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time, const amrex::Real theta_time = a_time + m_theta*a_dt; - // Solve nonlinear system for Eg at t_{n+theta} + // Solve nonlinear system for E 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, a_dt ); // Update WarpX owned Efield_fp and Bfield_fp to t_{n+theta} @@ -111,7 +111,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_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 + // Advance E and B fields from time n+theta to time n+1 const amrex::Real new_time = a_time + a_dt; FinishFieldUpdate( new_time ); @@ -132,7 +132,7 @@ void ThetaImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS, // current state of the fields E and B. Deposit current density at time n+1/2. m_WarpX->ImplicitPreRHSOp( a_time, a_dt, a_nl_iter, a_from_jacobian ); - // RHS = cvac^2*m_theta*dt*( curl(Bg^{n+theta}) - mu0*Jg^{n+1/2} ) + // RHS = cvac^2*m_theta*dt*( curl(B^{n+theta}) - mu0*J^{n+1/2} ) m_WarpX->ImplicitComputeRHSE(m_theta*a_dt, a_RHS); }