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 MOOSE_MFEM_ENABLED
11 
12 #pragma once
13 
14 #include "MFEMObject.h"
15 
16 namespace Moose::MFEM
17 {
21 class SolverBase : public MFEMObject
22 {
23 public:
25 
27 
29  mfem::Solver & GetSolver();
30 
32  void SetSolver(mfem::Solver * solver) { _solver.reset(solver); }
33 
35  virtual void ConstructSolver() = 0;
36 
38  void SetOperator(mfem::Operator & op);
39 
41  void Mult(const mfem::Vector & rhs, mfem::Vector & x) { GetSolver().Mult(rhs, x); }
42 
43 protected:
46  virtual void UpdateEquationSystemContext() {}
47 
50  virtual void SetOperatorImpl(mfem::Operator & op) { GetSolver().SetOperator(op); }
51 
53  std::unique_ptr<mfem::Solver> _solver;
54 };
55 
56 inline mfem::Solver &
58 {
59  mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed");
60  return *_solver;
61 }
62 } // namespace Moose::MFEM
63 
64 #endif
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition: MFEMObject.h:25
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
void SetSolver(mfem::Solver *solver)
Set the wrapped MFEM solver.
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 Mult(const mfem::Vector &rhs, mfem::Vector &x)
Solve the operator for the provided right-hand side and solution vector.
SolverBase(const InputParameters &parameters)
static InputParameters validParams()
virtual void SetOperatorImpl(mfem::Operator &op)
Updates the solver at the operator level.
virtual void UpdateEquationSystemContext()
Update the solver following any changes to the weak form it is responsible for solving.
void SetOperator(mfem::Operator &op)
Updates the solver and any associated weak form context at the operator level.
Base class for wrapping mfem::Solver-derived classes.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
virtual void ConstructSolver()=0
Override in derived classes to construct and set the solver options.