16 #ifndef dealii_solver_selector_h 17 #define dealii_solver_selector_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/smartpointer.h> 24 #include <deal.II/lac/precondition.h> 25 #include <deal.II/lac/solver.h> 26 #include <deal.II/lac/solver_bicgstab.h> 27 #include <deal.II/lac/solver_cg.h> 28 #include <deal.II/lac/solver_control.h> 29 #include <deal.II/lac/solver_gmres.h> 30 #include <deal.II/lac/solver_minres.h> 31 #include <deal.II/lac/solver_richardson.h> 32 #include <deal.II/lac/vector.h> 34 DEAL_II_NAMESPACE_OPEN
90 template <
typename VectorType = Vector<
double>>
120 template <
class Matrix,
class Preconditioner>
122 solve(
const Matrix & A,
124 const VectorType & b,
125 const Preconditioner &precond)
const;
132 select(
const std::string &name);
196 <<
"Solver " << arg1 <<
" does not exist. Use one of " 250 template <
typename VectorType>
254 , control(&solver_control)
259 template <
typename VectorType>
268 template <
typename VectorType>
269 template <
class Matrix,
class Preconditioner>
273 const VectorType & b,
274 const Preconditioner &precond)
const 276 if (solver_name ==
"richardson")
279 solver.
solve(A, x, b, precond);
281 else if (solver_name ==
"cg")
284 solver.
solve(A, x, b, precond);
286 else if (solver_name ==
"minres")
289 solver.
solve(A, x, b, precond);
291 else if (solver_name ==
"bicgstab")
294 solver.
solve(A, x, b, precond);
296 else if (solver_name ==
"gmres")
299 solver.
solve(A, x, b, precond);
301 else if (solver_name ==
"fgmres")
304 solver.
solve(A, x, b, precond);
307 Assert(
false, ExcSolverDoesNotExist(solver_name));
312 template <
typename VectorType>
321 template <
typename VectorType>
325 return "richardson|cg|bicgstab|gmres|fgmres|minres";
330 template <
typename VectorType>
340 template <
typename VectorType>
350 template <
typename VectorType>
355 richardson_data = data;
360 template <
typename VectorType>
370 template <
typename VectorType>
380 template <
typename VectorType>
385 bicgstab_data = data;
388 DEAL_II_NAMESPACE_CLOSE
void set_control(SolverControl &ctrl)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
SolverCG< VectorType >::AdditionalData cg_data
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
void solve(const Matrix &A, VectorType &x, const VectorType &b, const Preconditioner &precond) const
static ::ExceptionBase & ExcSolverDoesNotExist(std::string arg1)
SolverBicgstab< VectorType >::AdditionalData bicgstab_data
SmartPointer< SolverControl, SolverSelector< VectorType > > control
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
static std::string get_solver_names()
virtual ~SolverSelector() override=default
SolverGMRES< VectorType >::AdditionalData gmres_data
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
SolverRichardson< VectorType >::AdditionalData richardson_data
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
void set_data(const typename SolverRichardson< VectorType >::AdditionalData &data)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
void select(const std::string &name)
SolverFGMRES< VectorType >::AdditionalData fgmres_data
SolverMinRes< VectorType >::AdditionalData minres_data