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 #include "MFEMProblem.h"
14 
16 
19 {
21  params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the "
22  "iterative solution of MFEM equation systems.");
23  params.addParam<MFEMFESpaceName>("fespace", "H(curl) FESpace to use in HypreAMS setup.");
24  params.addParam<bool>("singular",
25  false,
26  "Declare that the system is singular; use when solving curl-curl problem "
27  "if mass term is zero");
28  params.addParam<int>("print_level", 2, "Set the solver verbosity.");
29 
30  return params;
31 }
32 
34  : Moose::MFEM::LinearSolverBase(parameters),
35  _mfem_fespace(getMFEMProblem().getMFEMObject<MFEMFESpace>("MFEMFESpace",
36  getParam<MFEMFESpaceName>("fespace")))
37 {
39 }
40 
41 void
43 {
44  auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get());
45  if (getParam<bool>("singular"))
46  solver->SetSingularProblem();
47 
48  solver->iterative_mode = getParam<bool>("use_initial_guess");
49  solver->SetPrintLevel(getParam<int>("print_level"));
50 
51  _solver = std::move(solver);
52 }
53 
54 void
55 MFEMHypreAMS::SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs)
56 {
57  if (_lor)
58  {
60  if (_mfem_fespace.getFESpace()->GetMesh()->GetElement(0)->GetGeometryType() !=
61  mfem::Geometry::Type::CUBE)
62  mooseError("LOR HypreAMS Solver only supports hex meshes.");
63 
64  auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs);
65  lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
66  if (getParam<bool>("singular"))
67  lor_solver->GetSolver().SetSingularProblem();
68 
69  _solver.reset(lor_solver);
70  }
71 }
72 
73 #endif
Wrapper for mfem::HypreAMS solver.
Definition: MFEMHypreAMS.h:20
registerMooseObject("MooseApp", MFEMHypreAMS)
const MFEMFESpace & _mfem_fespace
Definition: MFEMHypreAMS.h:34
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...
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
Definition: MFEMHypreAMS.C:42
static InputParameters validParams()
bool _lor
Variable defining whether to use LOR solver.
static InputParameters validParams()
Definition: MFEMHypreAMS.C:18
Constructs and stores an mfem::ParFiniteElementSpace object.
Definition: MFEMFESpace.h:20
MFEMHypreAMS(const InputParameters &)
Definition: MFEMHypreAMS.C:33
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:281
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...
void SetupLOR(mfem::ParBilinearForm &a, mfem::Array< int > &tdofs) override
Updates the solver with the bilinear form in case LOR solve is required.
Definition: MFEMHypreAMS.C:55
std::shared_ptr< mfem::ParFiniteElementSpace > getFESpace() const
Returns a shared pointer to the constructed fespace.
Definition: MFEMFESpace.h:36
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual void CheckSpectralEquivalence(mfem::ParBilinearForm &blf) const
Checks for the correct configuration of quadrature bases for LOR spectral equivalence.