WarpX
Public Member Functions | Private Member Functions | Private Attributes | List of all members
NewtonSolver< Vec, Ops > Class Template Reference

Newton method to solve nonlinear equation of form: F(U) = U - b - R(U) = 0. U is the solution vector, b is a constant, and R(U) is some nonlinear function of U, which is computed in the ComputeRHS() Ops function. More...

#include <NewtonSolver.H>

Inheritance diagram for NewtonSolver< Vec, Ops >:
NonlinearSolver< Vec, Ops >

Public Member Functions

 NewtonSolver ()=default
 
 ~NewtonSolver () override=default
 
 NewtonSolver (const NewtonSolver &)=delete
 
NewtonSolveroperator= (const NewtonSolver &)=delete
 
 NewtonSolver (NewtonSolver &&) noexcept=delete
 
NewtonSolveroperator= (NewtonSolver &&) noexcept=delete
 
void Define (const Vec &a_U, Ops *a_ops) override
 Read user-provided parameters that control the nonlinear solver. Allocate intermediate data containers needed by the solver. For Newton, setup the linear solver for computing the Newton step. More...
 
void Solve (Vec &a_U, const Vec &a_b, amrex::Real a_time, amrex::Real a_dt) const override
 Solve the specified nonlinear equation for U. Picard: U = b + R(U). Newton: F(U) = U - b - R(U) = 0. More...
 
void GetSolverParams (amrex::Real &a_rtol, amrex::Real &a_atol, int &a_maxits) override
 Return the convergence parameters used by the nonlinear solver. More...
 
void CurTime (amrex::Real a_time) const
 
void CurTimeStep (amrex::Real a_dt) const
 
void PrintParams () const override
 Print parameters used by the nonlinear solver. More...
 
- Public Member Functions inherited from NonlinearSolver< Vec, Ops >
 NonlinearSolver ()=default
 
virtual ~NonlinearSolver ()=default
 
 NonlinearSolver (const NonlinearSolver &)=delete
 
NonlinearSolveroperator= (const NonlinearSolver &)=delete
 
 NonlinearSolver (NonlinearSolver &&) noexcept=delete
 
NonlinearSolveroperator= (NonlinearSolver &&) noexcept=delete
 
bool IsDefined () const
 Check if the nonlinear solver has been defined. More...
 
void Verbose (bool a_verbose)
 Allow caller to dynamically change the verbosity flag. For example, one may want to only print solver information every 100 steps. More...
 

Private Member Functions

void ParseParameters ()
 
void EvalResidual (Vec &a_F, const Vec &a_U, const Vec &a_b, amrex::Real a_time, amrex::Real a_dt, int a_iter) const
 Compute the nonlinear residual: F(U) = U - b - R(U). More...
 

Private Attributes

Vec m_dU
 Intermediate Vec containers used by the solver. More...
 
Vec m_F
 
Vec m_R
 
Ops * m_ops = nullptr
 Pointer to Ops class. More...
 
bool m_require_convergence = true
 Flag to determine whether convergence is required. More...
 
amrex::Real m_rtol = 1.0e-6
 Relative tolerance for the Newton solver. More...
 
amrex::Real m_atol = 0.
 Absolute tolerance for the Newton solver. More...
 
int m_maxits = 100
 Maximum iterations for the Newton solver. More...
 
amrex::Real m_gmres_rtol = 1.0e-4
 Relative tolerance for GMRES. More...
 
amrex::Real m_gmres_atol = 0.
 Absolute tolerance for GMRES. More...
 
int m_gmres_maxits = 1000
 Maximum iterations for GMRES. More...
 
int m_gmres_verbose_int = 2
 Verbosity flag for GMRES. More...
 
int m_gmres_restart_length = 30
 Restart iteration for GMRES. More...
 
amrex::Real m_cur_time
 
amrex::Real m_dt
 
bool m_update_pc = false
 
bool m_update_pc_init = false
 
std::unique_ptr< JacobianFunctionMF< Vec, Ops > > m_linear_function
 The linear function used by GMRES to compute A*v. In the contect of JFNK, A = dF/dU (i.e., system Jacobian) More...
 
std::unique_ptr< amrex::GMRES< Vec, JacobianFunctionMF< Vec, Ops > > > m_linear_solver
 The linear solver (GMRES) object. More...
 

Additional Inherited Members

- Protected Attributes inherited from NonlinearSolver< Vec, Ops >
bool m_is_defined = false
 
bool m_verbose = true
 

Detailed Description

template<class Vec, class Ops>
class NewtonSolver< Vec, Ops >

Newton method to solve nonlinear equation of form: F(U) = U - b - R(U) = 0. U is the solution vector, b is a constant, and R(U) is some nonlinear function of U, which is computed in the ComputeRHS() Ops function.

Constructor & Destructor Documentation

◆ NewtonSolver() [1/3]

template<class Vec , class Ops >
NewtonSolver< Vec, Ops >::NewtonSolver ( )
default

◆ ~NewtonSolver()

template<class Vec , class Ops >
NewtonSolver< Vec, Ops >::~NewtonSolver ( )
overridedefault

◆ NewtonSolver() [2/3]

template<class Vec , class Ops >
NewtonSolver< Vec, Ops >::NewtonSolver ( const NewtonSolver< Vec, Ops > &  )
delete

◆ NewtonSolver() [3/3]

template<class Vec , class Ops >
NewtonSolver< Vec, Ops >::NewtonSolver ( NewtonSolver< Vec, Ops > &&  )
deletenoexcept

Member Function Documentation

◆ CurTime()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::CurTime ( amrex::Real  a_time) const
inline

◆ CurTimeStep()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::CurTimeStep ( amrex::Real  a_dt) const
inline

◆ Define()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::Define ( const Vec &  ,
Ops *   
)
overridevirtual

Read user-provided parameters that control the nonlinear solver. Allocate intermediate data containers needed by the solver. For Newton, setup the linear solver for computing the Newton step.

Implements NonlinearSolver< Vec, Ops >.

◆ EvalResidual()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::EvalResidual ( Vec &  a_F,
const Vec &  a_U,
const Vec &  a_b,
amrex::Real  a_time,
amrex::Real  a_dt,
int  a_iter 
) const
private

Compute the nonlinear residual: F(U) = U - b - R(U).

◆ GetSolverParams()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::GetSolverParams ( amrex::Real &  ,
amrex::Real &  ,
int  
)
inlineoverridevirtual

Return the convergence parameters used by the nonlinear solver.

Implements NonlinearSolver< Vec, Ops >.

◆ operator=() [1/2]

template<class Vec , class Ops >
NewtonSolver& NewtonSolver< Vec, Ops >::operator= ( const NewtonSolver< Vec, Ops > &  )
delete

◆ operator=() [2/2]

template<class Vec , class Ops >
NewtonSolver& NewtonSolver< Vec, Ops >::operator= ( NewtonSolver< Vec, Ops > &&  )
deletenoexcept

◆ ParseParameters()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::ParseParameters
private

◆ PrintParams()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::PrintParams ( ) const
inlineoverridevirtual

Print parameters used by the nonlinear solver.

Implements NonlinearSolver< Vec, Ops >.

◆ Solve()

template<class Vec , class Ops >
void NewtonSolver< Vec, Ops >::Solve ( Vec &  ,
const Vec &  ,
amrex::Real  ,
amrex::Real   
) const
overridevirtual

Solve the specified nonlinear equation for U. Picard: U = b + R(U). Newton: F(U) = U - b - R(U) = 0.

Implements NonlinearSolver< Vec, Ops >.

Member Data Documentation

◆ m_atol

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_atol = 0.
private

Absolute tolerance for the Newton solver.

◆ m_cur_time

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_cur_time
mutableprivate

◆ m_dt

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_dt
private

◆ m_dU

template<class Vec , class Ops >
Vec NewtonSolver< Vec, Ops >::m_dU
mutableprivate

Intermediate Vec containers used by the solver.

◆ m_F

template<class Vec , class Ops >
Vec NewtonSolver< Vec, Ops >::m_F
private

◆ m_gmres_atol

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_gmres_atol = 0.
private

Absolute tolerance for GMRES.

◆ m_gmres_maxits

template<class Vec , class Ops >
int NewtonSolver< Vec, Ops >::m_gmres_maxits = 1000
private

Maximum iterations for GMRES.

◆ m_gmres_restart_length

template<class Vec , class Ops >
int NewtonSolver< Vec, Ops >::m_gmres_restart_length = 30
private

Restart iteration for GMRES.

◆ m_gmres_rtol

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_gmres_rtol = 1.0e-4
private

Relative tolerance for GMRES.

◆ m_gmres_verbose_int

template<class Vec , class Ops >
int NewtonSolver< Vec, Ops >::m_gmres_verbose_int = 2
private

Verbosity flag for GMRES.

◆ m_linear_function

template<class Vec , class Ops >
std::unique_ptr<JacobianFunctionMF<Vec,Ops> > NewtonSolver< Vec, Ops >::m_linear_function
private

The linear function used by GMRES to compute A*v. In the contect of JFNK, A = dF/dU (i.e., system Jacobian)

◆ m_linear_solver

template<class Vec , class Ops >
std::unique_ptr<amrex::GMRES<Vec,JacobianFunctionMF<Vec,Ops> > > NewtonSolver< Vec, Ops >::m_linear_solver
private

The linear solver (GMRES) object.

◆ m_maxits

template<class Vec , class Ops >
int NewtonSolver< Vec, Ops >::m_maxits = 100
private

Maximum iterations for the Newton solver.

◆ m_ops

template<class Vec , class Ops >
Ops* NewtonSolver< Vec, Ops >::m_ops = nullptr
private

Pointer to Ops class.

◆ m_R

template<class Vec , class Ops >
Vec NewtonSolver< Vec, Ops >::m_R
private

◆ m_require_convergence

template<class Vec , class Ops >
bool NewtonSolver< Vec, Ops >::m_require_convergence = true
private

Flag to determine whether convergence is required.

◆ m_rtol

template<class Vec , class Ops >
amrex::Real NewtonSolver< Vec, Ops >::m_rtol = 1.0e-6
private

Relative tolerance for the Newton solver.

◆ m_update_pc

template<class Vec , class Ops >
bool NewtonSolver< Vec, Ops >::m_update_pc = false
mutableprivate

◆ m_update_pc_init

template<class Vec , class Ops >
bool NewtonSolver< Vec, Ops >::m_update_pc_init = false
mutableprivate

The documentation for this class was generated from the following file: