WarpX
Loading...
Searching...
No Matches
NonlinearSolver.H
Go to the documentation of this file.
1#ifndef WARPX_NONLINEAR_SOLVER_H_
2#define WARPX_NONLINEAR_SOLVER_H_
3
5
7#include <AMReX_REAL.H>
8
9#include <AMReX_BaseFwd.H>
10
11#include <string>
12#include <array>
13#include <memory>
14
27
28template<class Vec, class Ops>
30{
31public:
32
33 NonlinearSolver() = default;
34
35 virtual ~NonlinearSolver() = default;
36
37 // Prohibit Move and Copy operations
40 NonlinearSolver(NonlinearSolver&&) noexcept = delete;
41 NonlinearSolver& operator=(NonlinearSolver&&) noexcept = delete;
42
48 virtual void Define ( const Vec&,
49 Ops* ) = 0;
50
54 [[nodiscard]] bool IsDefined () const { return m_is_defined; }
55
61 virtual void Solve (Vec&,
62 const Vec&,
65 int) const = 0;
66
70 int GetExitStatus() const { return m_exit_status; }
71
75 virtual void PrintParams () const = 0;
76
80 virtual void GetSolverParams (amrex::Real&, amrex::Real&, int&) = 0;
81
86
91 virtual void Verbose ( bool a_verbose ) { m_verbose = a_verbose; }
92
93protected:
94
95 bool m_is_defined = false;
96 mutable bool m_verbose = true;
97 std::string m_diagnostic_file;
99 bool m_usePC = false;
100
101 mutable int m_exit_status = 0;
102
103};
104
105#endif
PreconditionerType
Types for preconditioners for field solvers.
Definition PreconditionerLibrary.H:14
@ none
Definition PreconditionerLibrary.H:14
NonlinearSolver(const NonlinearSolver &)=delete
virtual void PrintParams() const =0
Print parameters used by the nonlinear solver.
int GetExitStatus() const
Return the nonlinear solver exit status.
Definition NonlinearSolver.H:70
bool m_usePC
Definition NonlinearSolver.H:99
bool m_is_defined
Definition NonlinearSolver.H:95
std::string m_diagnostic_file
Definition NonlinearSolver.H:97
virtual ~NonlinearSolver()=default
NonlinearSolver()=default
bool IsDefined() const
Check if the nonlinear solver has been defined.
Definition NonlinearSolver.H:54
virtual void GetSolverParams(amrex::Real &, amrex::Real &, int &)=0
Return the convergence parameters used by the nonlinear solver.
virtual void Verbose(bool a_verbose)
Allow caller to dynamically change the verbosity flag. For example, one may want to only print solver...
Definition NonlinearSolver.H:91
int m_diagnostic_interval
Definition NonlinearSolver.H:98
NonlinearSolver & operator=(const NonlinearSolver &)=delete
virtual void Define(const Vec &, Ops *)=0
Read user-provided parameters that control the nonlinear solver. Allocate intermediate data container...
virtual void Solve(Vec &, const Vec &, amrex::Real, amrex::Real, int) const =0
Solve the specified nonlinear equation for U. Picard: U = b + R(U). Newton: F(U) = U - b - R(U) = 0.
virtual PreconditionerType GetPreconditionerType() const
Return preconditioner type.
Definition NonlinearSolver.H:85
NonlinearSolver(NonlinearSolver &&) noexcept=delete
bool m_verbose
Definition NonlinearSolver.H:96
int m_exit_status
Definition NonlinearSolver.H:101
amrex_real Real