https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
16namespace Moose::MFEM
17{
21class SolverBase : public MFEMObject
22{
23public:
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
43protected:
47
50 virtual void SetOperatorImpl(mfem::Operator & op) { GetSolver().SetOperator(op); }
51
53 std::unique_ptr<mfem::Solver> _solver;
54};
55
56inline 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
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition MFEMObject.h:30
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Base class for wrapping mfem::Solver-derived classes.
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.
virtual void ConstructSolver()=0
Override in derived classes to construct and set the solver options.
virtual void SetOperatorImpl(mfem::Operator &op)
Updates the solver at the operator level.
static InputParameters validParams()
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
void SetSolver(mfem::Solver *solver)
Set the wrapped MFEM solver.
void Mult(const mfem::Vector &rhs, mfem::Vector &x)
Solve the operator for the provided right-hand side and solution vector.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).