LCOV - code coverage report
Current view: top level - include/mfem/solvers - MFEMMatrixFreeAMS.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 7 8 87.5 %
Date: 2026-08-03 21:12:22 Functions: 3 4 75.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 "MFEMLORLinearSolverBase.h"
      15             : 
      16             : namespace Moose::MFEM
      17             : {
      18             : /**
      19             :  * Wrapper for mfem::MatrixFreeAMS solver that creates an mfem::MatrixFreeAMS solver from the
      20             :  * operator when set.
      21             :  */
      22             : class MatrixFreeAMS : public mfem::Solver
      23             : {
      24             : public:
      25             :   MatrixFreeAMS(mfem::Coefficient & alpha_coef,
      26             :                 mfem::Coefficient & beta_coef,
      27             :                 int inner_pi_its = 0,
      28             :                 int inner_g_its = 1);
      29             : 
      30             :   /// Set the bilinear form corresponding to the curl-curl problem being preconditioned
      31           7 :   void SetBilinearForm(mfem::ParBilinearForm & a) { _aform = &a; }
      32             :   /// Set the marker array labelling essential boundaries
      33           7 :   void SetBoundaryMarkers(mfem::Array<int> & ess_bdr_markers)
      34             :   {
      35           7 :     _ess_bdr_markers = ess_bdr_markers;
      36           7 :   }
      37             :   void SetOperator(const mfem::Operator & op) override;
      38         165 :   void Mult(const mfem::Vector & x, mfem::Vector & y) const override
      39             :   {
      40             :     mooseAssert(_matrix_free_ams,
      41             :                 "MatrixFreeAMS preconditioner was not initialized with both the operator and "
      42             :                 "bilinear form before use.");
      43         165 :     _matrix_free_ams->Mult(x, y);
      44         165 :   }
      45             : 
      46             : private:
      47             :   std::unique_ptr<mfem::MatrixFreeAMS> _matrix_free_ams{nullptr};
      48             :   mfem::Coefficient & _alpha_coef;
      49             :   mfem::Coefficient & _beta_coef;
      50             :   const int _inner_pi_its;
      51             :   const int _inner_g_its;
      52             :   mfem::ParBilinearForm * _aform;
      53             :   mfem::Array<int> _ess_bdr_markers;
      54             : };
      55             : } // namespace Moose::MFEM
      56             : 
      57             : /**
      58             :  * Wrapper for mfem::MatrixFreeAMS solver.
      59             :  */
      60             : class MFEMMatrixFreeAMS : public Moose::MFEM::LORLinearSolverBase<mfem::MatrixFreeAMS>
      61             : {
      62             : public:
      63             :   static InputParameters validParams();
      64             : 
      65             :   MFEMMatrixFreeAMS(const InputParameters &);
      66             : 
      67             :   void ConstructSolver() override;
      68             : 
      69             : protected:
      70           0 :   virtual void SetSolverParameters(mfem::MatrixFreeAMS &) override {}
      71             : 
      72             : private:
      73             :   mfem::Coefficient & _alpha_coef;
      74             :   mfem::Coefficient & _beta_coef;
      75             :   const int _inner_pi_its;
      76             :   const int _inner_g_its;
      77             : };
      78             : 
      79             : #endif

Generated by: LCOV version 1.14