https://mooseframework.inl.gov
MFEMHypreFGMRES.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #ifdef MOOSE_MFEM_ENABLED
11 
12 #include "MFEMHypreFGMRES.h"
13 #include "MFEMProblem.h"
14 
16 
19 {
21  params.addClassDescription("Hypre solver for the iterative solution of MFEM equation systems "
22  "using the flexible generalized minimal residual method.");
23  params.addParam<mfem::real_t>("l_tol", 1e-5, "Set the relative tolerance.");
24  params.addParam<int>("l_max_its", 10000, "Set the maximum number of iterations.");
25  params.addParam<int>("kdim", 10, "Set the k-dimension.");
26  params.addParam<int>("print_level", 2, "Set the solver verbosity.");
27  params.addParam<MFEMSolverName>("preconditioner", "Optional choice of preconditioner to use.");
28 
29  return params;
30 }
31 
33  : Moose::MFEM::LORLinearSolverBase<mfem::HypreFGMRES>(parameters)
34 {
36 }
37 
38 void
40 {
41  auto solver = std::make_unique<mfem::HypreFGMRES>(getMFEMProblem().getComm());
42  SetSolverParameters(*solver);
43  SetPreconditioner(*solver);
44  _solver = std::move(solver);
45 }
46 
47 void
48 MFEMHypreFGMRES::SetSolverParameters(mfem::HypreFGMRES & solver)
49 {
50  solver.iterative_mode = getParam<bool>("use_initial_guess");
51  solver.SetTol(getParam<mfem::real_t>("l_tol"));
52  solver.SetMaxIter(getParam<int>("l_max_its"));
53  solver.SetKDim(getParam<int>("kdim"));
54  solver.SetPrintLevel(getParam<int>("print_level"));
55 }
56 
57 #endif
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
Definition: MFEMObject.h:45
MFEMHypreFGMRES(const InputParameters &parameters)
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void SetSolverParameters(mfem::HypreFGMRES &solver) override
Update the wrapped MFEM solver parameters.
registerMooseObject("MooseApp", MFEMHypreFGMRES)
static InputParameters validParams()
MPI_Comm getComm()
Return the MPI communicator associated with this FE problem&#39;s mesh.
Definition: MFEMProblem.h:281
void SetPreconditioner(T &solver)
Retrieves the preconditioner userobject if present, sets the member pointer to said object if still u...
Wrapper for mfem::HypreFGMRES solver.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...