Skip to content

Commit

Permalink
dt passed to m_nlsolver->Solve() and eventually used by the PC is now…
Browse files Browse the repository at this point in the history
… the appropriate fractional time step. Removed theta() function from ImplicitSolver.H.
  • Loading branch information
JustinRayAngus committed Nov 5, 2024
1 parent 259059b commit d48ff80
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
4 changes: 1 addition & 3 deletions Source/FieldSolver/ImplicitSolvers/ImplicitSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public:
int a_nl_iter,
bool a_from_jacobian ) = 0;

[[nodiscard]] virtual amrex::Real theta () const { return 1.0; }

[[nodiscard]] int numAMRLevels () const { return m_num_amr_levels; }

[[nodiscard]] const amrex::Geometry& GetGeometry (int) const;
Expand All @@ -113,7 +111,7 @@ protected:
/**
* \brief Time step
*/
mutable amrex::Real m_dt = DBL_MAX;
mutable amrex::Real m_dt = 0.0;

/**
* \brief Nonlinear solver type and object
Expand Down
2 changes: 1 addition & 1 deletion Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time,
// 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, m_dt );
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 );
Expand Down
2 changes: 0 additions & 2 deletions Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.H
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public:
int a_nl_iter,
bool a_from_jacobian ) override;

[[nodiscard]] amrex::Real theta () const override { return m_theta; }

private:

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,
// 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_dt );
m_nlsolver->Solve( m_E, m_Eold, theta_time, m_theta*m_dt );

// Update WarpX owned Efield_fp and Bfield_fp to t_{n+theta}
UpdateWarpXFields( m_E, theta_time );
Expand Down
5 changes: 3 additions & 2 deletions Source/NonlinearSolvers/CurlCurlMLMGPC.H
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)
amrex::ignore_unused(a_U);

// set the coefficients alpha and beta for curl-curl op
const RT alpha = (m_ops->theta()*this->m_dt*PhysConst::c) * (m_ops->theta()*this->m_dt*PhysConst::c);
// (m_dt here is actually theta<=0.5 times simulation dt)
const RT alpha = (this->m_dt*PhysConst::c) * (this->m_dt*PhysConst::c);
const RT beta = RT(1.0);

// currently not implemented in 1D
Expand All @@ -282,7 +283,7 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)

if (m_verbose) {
amrex::Print() << "Updating " << amrex::getEnumNameString(PreconditionerType::pc_curl_curl_mlmg)
<< ": dt = " << this->m_dt << ", "
<< ": theta*dt = " << this->m_dt << ", "
<< " coefficients: "
<< "alpha = " << alpha << ", "
<< "beta = " << beta << "\n";
Expand Down

0 comments on commit d48ff80

Please sign in to comment.