LCOV - code coverage report
Current view: top level - include/mfem/solvers - MFEMSolverBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 3 3 100.0 %
Date: 2025-11-03 17:23:24 Functions: 2 2 100.0 %
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             : #include "MFEMGeneralUserObject.h"
      14             : #include "libmesh/ignore_warnings.h"
      15             : #include <mfem.hpp>
      16             : #include "libmesh/restore_warnings.h"
      17             : #include <memory>
      18             : #include "MFEMHyprePatch.h"
      19             : 
      20             : /**
      21             :  * Base class for wrapping mfem::Solver-derived classes.
      22             :  */
      23             : class MFEMSolverBase : public MFEMGeneralUserObject
      24             : {
      25             : public:
      26             :   static InputParameters validParams();
      27             : 
      28             :   MFEMSolverBase(const InputParameters & parameters);
      29             : 
      30             :   /// Retrieves the preconditioner userobject if present, sets the member pointer to
      31             :   /// said object if still unset, and sets the solver to use this preconditioner.
      32             :   template <typename T>
      33             :   void setPreconditioner(T & solver);
      34             : 
      35             :   /// Returns the wrapped MFEM solver
      36             :   mfem::Solver & getSolver();
      37             : 
      38             :   /// Updates the solver with the given bilinear form and essential dof list, in case an LOR or algebraic solver is needed.
      39             :   virtual void updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs) = 0;
      40             : 
      41             :   /// Returns whether or not this solver (or its preconditioner) uses LOR
      42        1646 :   bool isLOR() const { return _lor || (_preconditioner && _preconditioner->isLOR()); }
      43             : 
      44             : protected:
      45             :   /// Override in derived classes to construct and set the solver options.
      46             :   virtual void constructSolver(const InputParameters & parameters) = 0;
      47             : 
      48             :   /// Checks for the correct configuration of quadrature bases for LOR spectral equivalence
      49             :   virtual void checkSpectralEquivalence(mfem::ParBilinearForm & blf) const;
      50             : 
      51             :   /// Variable defining whether to use LOR solver
      52             :   bool _lor;
      53             : 
      54             :   /// Solver to be used for the problem
      55             :   std::unique_ptr<mfem::Solver> _solver;
      56             : 
      57             :   /// Preconditioner to be used for the problem
      58             :   MFEMSolverBase * _preconditioner;
      59             : };
      60             : 
      61             : inline mfem::Solver &
      62        1955 : MFEMSolverBase::getSolver()
      63             : {
      64             :   mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed");
      65        1955 :   return *_solver;
      66             : }
      67             : 
      68             : #endif

Generated by: LCOV version 1.14