10#ifdef MOOSE_MFEM_ENABLED
21 params.
addClassDescription(
"Hypre solver for the iterative solution of MFEM equation systems "
22 "using the preconditioned conjugate gradient method.");
24 params.
addParam<mfem::real_t>(
"l_tol", 1e-5,
"Set the relative tolerance.");
25 params.
addParam<mfem::real_t>(
"l_abs_tol", 1e-50,
"Set the absolute tolerance.");
26 params.
addParam<
int>(
"l_max_its", 10000,
"Set the maximum number of iterations.");
27 params.
addParam<
int>(
"print_level", 2,
"Set the solver verbosity.");
28 params.
addParam<MFEMSolverName>(
"preconditioner",
"Optional choice of preconditioner to use.");
34 :
Moose::MFEM::LORLinearSolverBase<
mfem::HyprePCG>(parameters)
42 auto solver = std::make_unique<mfem::HyprePCG>(
getMFEMProblem().getComm());
50 solver.iterative_mode = getParam<bool>(
"use_initial_guess");
51 solver.SetTol(getParam<mfem::real_t>(
"l_tol"));
52 solver.SetAbsTol(getParam<mfem::real_t>(
"l_abs_tol"));
53 solver.SetMaxIter(getParam<int>(
"l_max_its"));
54 solver.SetPrintLevel(getParam<int>(
"print_level"));
60 if (
auto * prec =
dynamic_cast<mfem::HypreSolver *
>(&
_preconditioner->GetSolver()))
61 cast_ref<mfem::HyprePCG &>(
GetSolver()).SetPreconditioner(*prec);
63 paramError(
"preconditioner",
"MFEMHyprePCG requires a hypre solver as its preconditioner");
registerMooseObject("MooseApp", MFEMHyprePCG)
Wrapper for mfem::HyprePCG solver.
virtual void SetPreconditionerImpl() override
Override in solvers that accept a preconditioner.
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
virtual void SetSolverParameters(mfem::HyprePCG &solver) override
Update the wrapped MFEM solver parameters.
static InputParameters validParams()
MFEMHyprePCG(const InputParameters ¶meters)
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
static InputParameters validParams()
std::shared_ptr< LinearSolverBase > _preconditioner
Preconditioner to be used for the problem.
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...