LCOV - code coverage report
Current view: top level - include/mfem/solvers - MFEMSolverBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 3 4 75.0 %
Date: 2026-05-29 20:35:17 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          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             : class MFEMProblemSolve;
      17             : 
      18             : /**
      19             :  * Base class for wrapping mfem::Solver-derived classes.
      20             :  */
      21             : class MFEMSolverBase : public MFEMObject
      22             : {
      23             : public:
      24             :   static InputParameters validParams();
      25             : 
      26             :   MFEMSolverBase(const InputParameters & parameters);
      27             : 
      28             :   /// Retrieves the preconditioner userobject if present, sets the member pointer to
      29             :   /// said object if still unset, and sets the solver to use this preconditioner.
      30             :   template <typename T>
      31             :   void setPreconditioner(T & solver);
      32             : 
      33             :   /// Returns the wrapped MFEM solver
      34             :   mfem::Solver & getSolver();
      35             : 
      36             :   /// Updates the solver with the given bilinear form and essential dof list, in case an LOR or algebraic solver is needed.
      37             :   virtual void updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs) = 0;
      38             : 
      39             :   /// Sets an already-assembled operator on the wrapped solver. Used by callers that
      40             :   /// manage operator assembly themselves (e.g. the eigenproblem operator), bypassing
      41             :   /// the bilinear-form-based updateSolver() path.
      42             :   virtual void setOperator(mfem::OperatorHandle & op);
      43             : 
      44             :   /// Returns whether or not this solver (or its preconditioner) uses LOR
      45        3214 :   bool isLOR() const { return _lor || (_preconditioner && _preconditioner->isLOR()); }
      46             : 
      47             :   /// For eigensolvers, this method calls the underlying Solve method
      48           0 :   virtual void solve() { mooseError("'solve' method not used in this solver type."); }
      49             : 
      50             : protected:
      51             :   /// Override in derived classes to construct and set the solver options.
      52             :   virtual void constructSolver() = 0;
      53             : 
      54             :   /// Checks for the correct configuration of quadrature bases for LOR spectral equivalence
      55             :   virtual void checkSpectralEquivalence(mfem::ParBilinearForm & blf) const;
      56             : 
      57             :   /// Variable defining whether to use LOR solver
      58             :   bool _lor;
      59             : 
      60             :   /// Solver to be used for the problem
      61             :   std::unique_ptr<mfem::Solver> _solver;
      62             : 
      63             :   /// Preconditioner to be used for the problem
      64             :   std::shared_ptr<MFEMSolverBase> _preconditioner;
      65             : 
      66             : private:
      67             :   friend class MFEMProblemSolve;
      68             : };
      69             : 
      70             : inline mfem::Solver &
      71        4082 : MFEMSolverBase::getSolver()
      72             : {
      73             :   mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed");
      74        4082 :   return *_solver;
      75             : }
      76             : 
      77             : #endif

Generated by: LCOV version 1.14