https://mooseframework.inl.gov
MFEMHypreBoomerAMG.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 "MFEMHypreBoomerAMG.h"
13 #include "MFEMFESpace.h"
14 
16 
19 {
21  params.addClassDescription("Hypre BoomerAMG solver and preconditioner for the iterative solution "
22  "of MFEM equation systems.");
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>("print_level", 2, "Set the solver verbosity.");
26  params.addParam<UserObjectName>(
27  "fespace", "H1 FESpace to use in HypreBoomerAMG setup for elasticity problems.");
28  params.addParam<mfem::real_t>(
29  "strength_threshold", 0.25, "HypreBoomerAMG strong threshold. Defaults to 0.25.");
30  MooseEnum errmode("ignore=0 warn=1 abort=2", "abort", false);
31  params.addParam<MooseEnum>("error_mode", errmode, "Set the behavior for treating hypre errors.");
32  return params;
33 }
34 
36  : MFEMSolverBase(parameters),
37  _mfem_fespace(isParamSetByUser("fespace") ? getUserObject<MFEMFESpace>("fespace").getFESpace()
38  : nullptr)
39 {
41 }
42 
43 void
45 {
46  auto solver = std::make_unique<mfem::HypreBoomerAMG>();
47 
48  solver->SetTol(getParam<mfem::real_t>("l_tol"));
49  solver->SetMaxIter(getParam<int>("l_max_its"));
50  solver->SetPrintLevel(getParam<int>("print_level"));
51  solver->SetStrengthThresh(getParam<mfem::real_t>("strength_threshold"));
52  solver->SetErrorMode(mfem::HypreSolver::ErrorMode(int(getParam<MooseEnum>("error_mode"))));
53 
54  if (_mfem_fespace && !mfem::HypreUsingGPU())
55  solver->SetElasticityOptions(_mfem_fespace.get());
56 
57  _solver = std::move(solver);
58 }
59 
60 void
61 MFEMHypreBoomerAMG::updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs)
62 {
63  if (_lor)
64  {
66  mooseError("Low-Order-Refined solver requires the FESpace closed_basis to be GaussLobatto "
67  "and the open-basis to be IntegratedGLL for ND and RT elements.");
68 
69  auto lor_solver = new mfem::LORSolver<mfem::HypreBoomerAMG>(a, tdofs);
70  lor_solver->GetSolver().SetTol(getParam<mfem::real_t>("l_tol"));
71  lor_solver->GetSolver().SetMaxIter(getParam<int>("l_max_its"));
72  lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
73  lor_solver->GetSolver().SetStrengthThresh(getParam<mfem::real_t>("strength_threshold"));
74 
75  if (_mfem_fespace && !mfem::HypreUsingGPU())
76  lor_solver->GetSolver().SetElasticityOptions(_mfem_fespace.get());
77 
78  _solver.reset(lor_solver);
79  }
80 }
81 
82 #endif
MFEMHypreBoomerAMG(const InputParameters &)
void updateSolver(mfem::ParBilinearForm &a, mfem::Array< int > &tdofs) override
Updates the solver with the bilinear form in case LOR solve is required.
Wrapper for mfem::HypreBoomerAMG solver.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
registerMooseObject("MooseApp", MFEMHypreBoomerAMG)
void constructSolver(const InputParameters &parameters) override
Override in derived classes to construct and set the solver options.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:22
virtual bool checkSpectralEquivalence(mfem::ParBilinearForm &blf) const
Checks for the correct configuration of quadrature bases for LOR spectral equivalence.
std::shared_ptr< mfem::ParFiniteElementSpace > _mfem_fespace
bool _lor
Variable defining whether to use LOR solver.
Base class for wrapping mfem::Solver-derived classes.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
static InputParameters validParams()
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...
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.