Skip to content

Commit

Permalink
restoring comment change in implicit solvers. moved to separate PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinRayAngus committed Aug 26, 2024
1 parent ba587bc commit fd3a0af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ 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,
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// 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}
Expand All @@ -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 );

Expand All @@ -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);
}
10 changes: 5 additions & 5 deletions Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ 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,
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// 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<int>(m_Bold.size());
for (int lev = 0; lev < num_levels; ++lev) {
Expand All @@ -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}
Expand All @@ -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 );

Expand All @@ -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);
}

Expand Down

0 comments on commit fd3a0af

Please sign in to comment.