Skip to content

Commit

Permalink
minor adjustments to comments in implicit solver classes (ECP-WarpX#5170
Browse files Browse the repository at this point in the history
)

* minor comment update implicit solver classes.

* additional comment updates.
  • Loading branch information
JustinRayAngus authored Aug 26, 2024
1 parent e01e42f commit efeb03c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
26 changes: 13 additions & 13 deletions Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time,
{
amrex::ignore_unused(a_step);

// Fields have E^{n}, B^{n-1/2}
// Particles have p^{n} and x^{n}.
// Fields have Eg^{n}, Bg^{n-1/2}
// Particles have up^{n} and xp^{n}.

// Save the values at the start of the time step,
// Save up and xp at the start of the time step
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// Save the fields at the start of the step
// Save Eg at the start of the time step
m_Eold.Copy( m_WarpX->getMultiLevelField(FieldType::Efield_fp) );
m_E.Copy(m_Eold); // initial guess for E

// Compute Bfield at time n+1/2
// Advance WarpX owned Bfield_fp to t_{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 E at t_{n+1/2}
// Solve nonlinear system for Eg 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 @@ -90,8 +90,8 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time,
// Advance particles from time n+1/2 to time n+1
m_WarpX->FinishImplicitParticleUpdate();

// 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
// 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 );

Expand All @@ -104,14 +104,14 @@ void SemiImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS,
int a_nl_iter,
bool a_from_jacobian )
{
// update WarpX-owned Efield_fp using current state of E from
// Update WarpX-owned Efield_fp using current state of Eg from
// the nonlinear solver at time n+theta
m_WarpX->SetElectricFieldAndApplyBCs( a_E );

// 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.
// 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, a_dt, a_nl_iter, a_from_jacobian );

// RHS = cvac^2*0.5*dt*( curl(B^{n+1/2}) - mu0*J^{n+1/2} )
// RHS = cvac^2*0.5*dt*( curl(Bg^{n+1/2}) - mu0*Jg^{n+1/2} )
m_WarpX->ImplicitComputeRHSE(0.5_rt*a_dt, a_RHS);
}
28 changes: 14 additions & 14 deletions Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,
{
amrex::ignore_unused(a_step);

// Fields have E^{n} and B^{n}
// Particles have p^{n} and x^{n}.
// Fields have Eg^{n} and Bg^{n}
// Particles have up^{n} and xp^{n}.

// Save the values at the start of the time step,
// Save up and xp at the start of the time step
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// Save the fields at the start of the step
// Save Eg at the start of the time step
m_Eold.Copy( m_WarpX->getMultiLevelField(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 @@ -106,8 +105,9 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,

const amrex::Real theta_time = a_time + m_theta*a_dt;

// Solve nonlinear system for E at t_{n+theta}
// 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, a_dt );

// Update WarpX owned Efield_fp and Bfield_fp to t_{n+theta}
Expand All @@ -116,7 +116,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,
// Advance particles from time n+1/2 to time n+1
m_WarpX->FinishImplicitParticleUpdate();

// Advance E and B fields from time n+theta to time n+1
// Advance Eg and Bg from time n+theta to time n+1
const amrex::Real new_time = a_time + a_dt;
FinishFieldUpdate( new_time );

Expand All @@ -129,15 +129,15 @@ void ThetaImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS,
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+theta
// 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, a_dt );

// 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.
// 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, a_dt, a_nl_iter, a_from_jacobian );

// RHS = cvac^2*m_theta*dt*( curl(B^{n+theta}) - mu0*J^{n+1/2} )
// RHS = cvac^2*m_theta*dt*( curl(Bg^{n+theta}) - mu0*Jg^{n+1/2} )
m_WarpX->ImplicitComputeRHSE(m_theta*a_dt, a_RHS);
}

Expand All @@ -159,8 +159,8 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time )
{
amrex::ignore_unused(a_new_time);

// Eg^{n+1} = (1/theta)*E_g^{n+theta} + (1-1/theta)*E_g^n
// Bg^{n+1} = (1/theta)*B_g^{n+theta} + (1-1/theta)*B_g^n
// 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

const amrex::Real c0 = 1._rt/m_theta;
const amrex::Real c1 = 1._rt - c0;
Expand Down

0 comments on commit efeb03c

Please sign in to comment.