https://mooseframework.inl.gov
MFEMSolverBase.h
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 MFEM_ENABLED
11 
12 #pragma once
13 #include "MFEMGeneralUserObject.h"
14 #include "libmesh/ignore_warnings.h"
15 #include <mfem.hpp>
16 #include "libmesh/restore_warnings.h"
17 #include <memory>
18 
23 {
24 public:
26 
28 
31  template <typename T>
32  void setPreconditioner(T & solver);
33 
35  mfem::Solver & getSolver();
36 
38  virtual void updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs) = 0;
39 
41  bool isLOR() const { return _lor || (_preconditioner && _preconditioner->isLOR()); }
42 
43 protected:
45  virtual void constructSolver(const InputParameters & parameters) = 0;
46 
48  virtual bool checkSpectralEquivalence(mfem::ParBilinearForm & blf) const;
49 
50  // Variable defining whether to use LOR solver
51  bool _lor;
52 
53  // Solver and preconditioner to be used for the problem
54  std::unique_ptr<mfem::Solver> _solver;
56 };
57 
58 inline mfem::Solver &
60 {
61  mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed");
62  return *_solver;
63 }
64 
65 #endif
MFEMSolverBase * _preconditioner
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
void setPreconditioner(T &solver)
Retrieves the preconditioner userobject if present, sets the member pointer to said object if still u...
MFEMSolverBase(const InputParameters &parameters)
virtual bool checkSpectralEquivalence(mfem::ParBilinearForm &blf) const
Checks for the correct configuration of quadrature bases for LOR spectral equivalence.
Base class for wrapping mfem::Solver-derived classes.
const InputParameters & parameters() const
Get the parameters of the object.
virtual void updateSolver(mfem::ParBilinearForm &a, mfem::Array< int > &tdofs)=0
Updates the solver with the given bilinear form and essential dof list, in case an LOR or algebraic s...
mfem::Solver & getSolver()
Returns the wrapped MFEM solver.
virtual void constructSolver(const InputParameters &parameters)=0
Override in derived classes to construct and set the solver options.
bool isLOR() const
Returns whether or not this solver (or its preconditioner) uses LOR.
std::unique_ptr< mfem::Solver > _solver