Line data Source code
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 : { 18 : /** 19 : * Base class for wrapping mfem::Solver-derived classes. 20 : */ 21 : class SolverBase : public MFEMObject 22 : { 23 : public: 24 : static InputParameters validParams(); 25 : 26 : SolverBase(const InputParameters & parameters); 27 : 28 : /// Returns the wrapped MFEM solver 29 : mfem::Solver & GetSolver(); 30 : 31 : /// Override in derived classes to construct and set the solver options. 32 : virtual void ConstructSolver() = 0; 33 : 34 : protected: 35 : /// Solver to be used for the problem 36 : std::unique_ptr<mfem::Solver> _solver; 37 : }; 38 : 39 : inline mfem::Solver & 40 4227 : SolverBase::GetSolver() 41 : { 42 : mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed"); 43 4227 : return *_solver; 44 : } 45 : } // namespace Moose::MFEM 46 : 47 : #endif