21 #include "libmesh/nonlinear_solver.h" 22 #include "libmesh/petsc_nonlinear_solver.h" 23 #include "libmesh/trilinos_nox_nonlinear_solver.h" 24 #include "libmesh/solver_configuration.h" 25 #include "libmesh/enum_solver_package.h" 37 #if defined(LIBMESH_HAVE_PETSC) || defined(LIBMESH_TRILINOS_HAVE_NOX) 39 std::unique_ptr<NonlinearSolver<T>>
43 switch (solver_package)
46 #ifdef LIBMESH_HAVE_PETSC 48 return std::make_unique<PetscNonlinearSolver<T>>(s);
49 #endif // LIBMESH_HAVE_PETSC 51 #if defined(LIBMESH_TRILINOS_HAVE_NOX) && defined(LIBMESH_TRILINOS_HAVE_EPETRA) 53 return std::make_unique<NoxNonlinearSolver<T>>(s);
57 libmesh_error_msg(
"ERROR: Unrecognized solver package: " << solver_package);
61 #else // LIBMESH_HAVE_PETSC || LIBMESH_TRILINOS_HAVE_NOX 64 std::unique_ptr<NonlinearSolver<T>>
67 libmesh_not_implemented_msg(
"ERROR: libMesh was compiled without nonlinear solver support");
76 libmesh_error_msg_if(this->
_is_initialized,
"Preconditioner must be attached before the solver is initialized!");
78 _preconditioner = preconditioner;
84 _solver_configuration = &solver_configuration;
90 libmesh_not_implemented();
96 _reuse_preconditioner = reuse;
102 libmesh_not_implemented();
105 template <
typename T>
108 _reuse_preconditioner_max_linear_its = i;
virtual bool reuse_preconditioner() const
Get the reuse_preconditioner flag.
void attach_preconditioner(Preconditioner< T > *preconditioner)
Attaches a Preconditioner object to be used during the linear solves.
The libMesh namespace provides an interface to certain functionality in the library.
virtual void set_reuse_preconditioner_max_linear_its(unsigned int i)
Set the reuse_preconditioner_max_linear_its parameter.
void set_solver_configuration(SolverConfiguration &solver_configuration)
Set the solver configuration object.
This class provides a uniform interface for preconditioners.
bool _is_initialized
Flag that tells if init() has been called.
virtual unsigned int reuse_preconditioner_max_linear_its() const
Get the reuse_preconditioner_max_linear_its parameter.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
This class stores solver configuration data, e.g.
virtual void set_reuse_preconditioner(bool reuse)
Set the reuse preconditioner flag.
static std::unique_ptr< NonlinearSolver< T > > build(sys_type &s, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NonlinearSolver using the nonlinear solver package specified by solver_package.
SolverPackage
Defines an enum for various linear solver packages.