LCOV - code coverage report
Current view: top level - src/mfem/solvers - MFEMMatrixFreeAMS.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33187 (5aa0b2) with base d7c4bd Lines: 46 50 92.0 %
Date: 2026-06-30 12:18:20 Functions: 6 6 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             : #include "MFEMMatrixFreeAMS.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMMatrixFreeAMS);
      16             : 
      17             : namespace Moose::MFEM
      18             : {
      19          53 : MatrixFreeAMS::MatrixFreeAMS(mfem::Coefficient & alpha_coef,
      20             :                              mfem::Coefficient & beta_coef,
      21             :                              int inner_pi_its,
      22          53 :                              int inner_g_its)
      23          53 :   : _alpha_coef(alpha_coef),
      24          53 :     _beta_coef(beta_coef),
      25          53 :     _inner_pi_its(inner_pi_its),
      26          53 :     _inner_g_its(inner_g_its)
      27             : {
      28          53 : }
      29             : 
      30             : void
      31           7 : MatrixFreeAMS::SetOperator(const mfem::Operator & op)
      32             : {
      33           7 :   height = op.Height();
      34           7 :   width = op.Width();
      35             :   // The constructor of mfem::MatrixFreeAMS requires the target operator to be known, so this
      36             :   // constructs the solver
      37           7 :   auto matrix_free_ams = std::make_unique<mfem::MatrixFreeAMS>(*_aform,
      38             :                                                                const_cast<mfem::Operator &>(op),
      39           7 :                                                                *_aform->ParFESpace(),
      40           0 :                                                                &_alpha_coef,
      41           0 :                                                                &_beta_coef,
      42           0 :                                                                nullptr,
      43           7 :                                                                _ess_bdr_markers,
      44           7 :                                                                _inner_pi_its,
      45           7 :                                                                _inner_g_its);
      46           7 :   _matrix_free_ams = std::move(matrix_free_ams);
      47           7 : }
      48             : } // namespace Moose::MFEM
      49             : 
      50             : InputParameters
      51        2204 : MFEMMatrixFreeAMS::validParams()
      52             : {
      53        2204 :   InputParameters params = Moose::MFEM::LinearSolverBase::validParams();
      54        4408 :   params.addClassDescription("MFEM matrix-free auxiliary-space Maxwell preconditioner for the "
      55             :                              "iterative solution of MFEM equation systems.");
      56        8816 :   params.addParam<MFEMScalarCoefficientName>(
      57             :       "alpha_coefficient",
      58             :       "1.",
      59             :       "Name of scalar coefficient used in curl-curl component of target equation system.");
      60        8816 :   params.addParam<MFEMScalarCoefficientName>(
      61             :       "beta_coefficient",
      62             :       "1.",
      63             :       "Name of scalar coefficient used in mass component of target equation system.");
      64        6612 :   params.addParam<unsigned int>(
      65        4408 :       "inner_pi_iterations", 0, "Number of CG iterations on auxiliary Pi space.");
      66        4408 :   params.addParam<unsigned int>(
      67        4408 :       "inner_g_iterations", 1, "Number of CG iterations on auxiliary G space.");
      68             :   // mfem::MatrixFreeAMS is always an LOR solver
      69        6612 :   params.setParameters("low_order_refined", true);
      70        2204 :   params.suppressParameter<bool>("low_order_refined");
      71        2204 :   return params;
      72           0 : }
      73             : 
      74          53 : MFEMMatrixFreeAMS::MFEMMatrixFreeAMS(const InputParameters & parameters)
      75             :   : Moose::MFEM::LinearSolverBase(parameters),
      76          53 :     _alpha_coef(getScalarCoefficient("alpha_coefficient")),
      77         106 :     _beta_coef(getScalarCoefficient("beta_coefficient")),
      78         106 :     _inner_pi_its(getParam<unsigned int>("inner_pi_iterations")),
      79         159 :     _inner_g_its(getParam<unsigned int>("inner_g_iterations"))
      80             : {
      81          53 :   ConstructSolver();
      82          53 : }
      83             : 
      84             : void
      85          53 : MFEMMatrixFreeAMS::ConstructSolver()
      86             : {
      87             :   auto solver = std::make_unique<Moose::MFEM::MatrixFreeAMS>(
      88          53 :       _alpha_coef, _beta_coef, _inner_pi_its, _inner_g_its);
      89         106 :   solver->iterative_mode = getParam<bool>("use_initial_guess");
      90          53 :   _solver = std::move(solver);
      91          53 : }
      92             : 
      93             : void
      94           7 : MFEMMatrixFreeAMS::SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & ess_bdr_markers)
      95             : {
      96             :   // update the pointer to the bilinear form representing the curl-curl problem being preconditioned
      97           7 :   auto & matrix_free_ams = static_cast<Moose::MFEM::MatrixFreeAMS &>(*_solver);
      98           7 :   matrix_free_ams.SetBilinearForm(a);
      99           7 :   matrix_free_ams.SetBoundaryMarkers(ess_bdr_markers);
     100           7 : }
     101             : 
     102             : #endif

Generated by: LCOV version 1.14