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 "MFEMSolverBase.h" 15 : #include "EquationSystem.h" 16 : 17 : class MFEMProblemSolve; 18 : 19 : namespace Moose::MFEM 20 : { 21 : /** 22 : * Base class for linear MFEM solvers and preconditioners. 23 : */ 24 : class LinearSolverBase : public SolverBase 25 : { 26 : public: 27 : static InputParameters validParams(); 28 : 29 : LinearSolverBase(const InputParameters & parameters); 30 : 31 : /// Retrieves the preconditioner userobject if present, sets the member pointer to 32 : /// said object if still unset, and sets the solver to use this preconditioner. 33 : template <typename T> 34 : void SetPreconditioner(T & solver); 35 : 36 : /// Returns this solver's preconditioner 37 4024 : LinearSolverBase * GetPreconditioner() { return _preconditioner.get(); } 38 : 39 : /// For eigensolvers, this method calls the underlying Solve method 40 0 : virtual void Solve() { mooseError("'solve' method not used in this solver type."); } 41 : 42 : protected: 43 : /// Update the solver following any changes to the EquationSystem it is responsible for solving. 44 : virtual void UpdateEquationSystemContext() override; 45 : 46 : /// Preconditioner to be used for the problem 47 : std::shared_ptr<LinearSolverBase> _preconditioner; 48 : 49 : /// Pointer to EquationSystem used for problem-specific solver setup 50 : std::shared_ptr<EquationSystem> _equation_system; 51 : 52 : private: 53 : friend class ::MFEMProblemSolve; 54 : }; 55 : } // namespace Moose::MFEM 56 : 57 : #endif