https://mooseframework.inl.gov
MFEMHypreAMS.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 "MFEMHypreAMS.h"
13 
15 
18 {
20  params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the "
21  "iterative solution of MFEM equation systems.");
22  params.addParam<UserObjectName>("fespace", "H(curl) FESpace to use in HypreAMS setup.");
23  params.addParam<bool>("singular",
24  false,
25  "Declare that the system is singular; use when solving curl-curl problem "
26  "if mass term is zero");
27  params.addParam<int>("print_level", 2, "Set the solver verbosity.");
28 
29  return params;
30 }
31 
33  : MFEMSolverBase(parameters), _mfem_fespace(getUserObject<MFEMFESpace>("fespace"))
34 {
36 }
37 
38 void
40 {
41  auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get());
42  if (getParam<bool>("singular"))
43  solver->SetSingularProblem();
44 
45  solver->SetPrintLevel(getParam<int>("print_level"));
46 
47  _solver = std::move(solver);
48 }
49 
50 void
51 MFEMHypreAMS::updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs)
52 {
53  if (_lor)
54  {
56  mooseError("Low-Order-Refined solver requires the FESpace closed_basis to be GaussLobatto "
57  "and the open-basis to be IntegratedGLL for ND and RT elements.");
58 
59  if (_mfem_fespace.getFESpace()->GetMesh()->GetElement(0)->GetGeometryType() !=
60  mfem::Geometry::Type::CUBE)
61  mooseError("LOR HypreAMS Solver only supports hex meshes.");
62 
63  auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs);
64  lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
65  if (getParam<bool>("singular"))
66  lor_solver->GetSolver().SetSingularProblem();
67 
68  _solver.reset(lor_solver);
69  }
70 }
71 
72 #endif
Wrapper for mfem::HypreAMS solver.
Definition: MFEMHypreAMS.h:19
registerMooseObject("MooseApp", MFEMHypreAMS)
const MFEMFESpace & _mfem_fespace
Definition: MFEMHypreAMS.h:33
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()
static InputParameters validParams()
Definition: MFEMHypreAMS.C:17
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.
void updateSolver(mfem::ParBilinearForm &a, mfem::Array< int > &tdofs) override
Updates the solver with the bilinear form in case LOR solve is required.
Definition: MFEMHypreAMS.C:51
MFEMHypreAMS(const InputParameters &)
Definition: MFEMHypreAMS.C:32
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
void constructSolver(const InputParameters &parameters) override
Override in derived classes to construct and set the solver options.
Definition: MFEMHypreAMS.C:39
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::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:38
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.