LCOV - code coverage report
Current view: top level - include/mfem/solvers - MFEMSolverBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 4 4 100.0 %
Date: 2026-07-23 16:15:30 Functions: 3 3 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             : 
      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             :   /// Updates the solver at the operator level. Default implementation sets the operator on the
      35             :   /// wrapped MFEM solver
      36        3215 :   virtual void SetOperator(mfem::Operator & op) { GetSolver().SetOperator(op); }
      37             : 
      38             :   /// Solve the operator for the provided right-hand side and solution vector.
      39        2509 :   void Mult(const mfem::Vector & rhs, mfem::Vector & x) { GetSolver().Mult(rhs, x); }
      40             : 
      41             : protected:
      42             :   /// Solver to be used for the problem
      43             :   std::unique_ptr<mfem::Solver> _solver;
      44             : };
      45             : 
      46             : inline mfem::Solver &
      47        8155 : SolverBase::GetSolver()
      48             : {
      49             :   mooseAssert(_solver, "Attempting to retrieve solver before it's been constructed");
      50        8155 :   return *_solver;
      51             : }
      52             : } // namespace Moose::MFEM
      53             : 
      54             : #endif

Generated by: LCOV version 1.14