LCOV - code coverage report
Current view: top level - src/mfem/solvers - MFEMHypreAMS.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33187 (5aa0b2) with base d7c4bd Lines: 33 36 91.7 %
Date: 2026-06-30 12:18:20 Functions: 4 4 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 "MFEMHypreAMS.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMHypreAMS);
      16             : 
      17             : InputParameters
      18        2350 : MFEMHypreAMS::validParams()
      19             : {
      20        2350 :   InputParameters params = Moose::MFEM::LinearSolverBase::validParams();
      21        4700 :   params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the "
      22             :                              "iterative solution of MFEM equation systems.");
      23        9400 :   params.addParam<MFEMFESpaceName>("fespace", "H(curl) FESpace to use in HypreAMS setup.");
      24        7050 :   params.addParam<bool>("singular",
      25        4700 :                         false,
      26             :                         "Declare that the system is singular; use when solving curl-curl problem "
      27             :                         "if mass term is zero");
      28        7050 :   params.addParam<int>("print_level", 2, "Set the solver verbosity.");
      29             : 
      30        2350 :   return params;
      31           0 : }
      32             : 
      33         126 : MFEMHypreAMS::MFEMHypreAMS(const InputParameters & parameters)
      34             :   : Moose::MFEM::LinearSolverBase(parameters),
      35         126 :     _mfem_fespace(getMFEMProblem().getMFEMObject<MFEMFESpace>("MFEMFESpace",
      36         378 :                                                               getParam<MFEMFESpaceName>("fespace")))
      37             : {
      38         126 :   ConstructSolver();
      39         126 : }
      40             : 
      41             : void
      42         126 : MFEMHypreAMS::ConstructSolver()
      43             : {
      44         126 :   auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get());
      45         378 :   if (getParam<bool>("singular"))
      46          27 :     solver->SetSingularProblem();
      47             : 
      48         252 :   solver->iterative_mode = getParam<bool>("use_initial_guess");
      49         252 :   solver->SetPrintLevel(getParam<int>("print_level"));
      50             : 
      51         126 :   _solver = std::move(solver);
      52         126 : }
      53             : 
      54             : void
      55           7 : MFEMHypreAMS::SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & ess_bdr_markers)
      56             : {
      57           7 :   if (_lor)
      58             :   {
      59           7 :     CheckSpectralEquivalence(a);
      60           7 :     if (_mfem_fespace.getFESpace()->GetMesh()->GetElement(0)->GetGeometryType() !=
      61             :         mfem::Geometry::Type::CUBE)
      62           0 :       mooseError("LOR HypreAMS Solver only supports hex meshes.");
      63             : 
      64           7 :     mfem::Array<int> ess_tdofs;
      65           7 :     a.ParFESpace()->GetEssentialTrueDofs(ess_bdr_markers, ess_tdofs);
      66           7 :     auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, ess_tdofs);
      67          14 :     lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
      68          21 :     if (getParam<bool>("singular"))
      69           0 :       lor_solver->GetSolver().SetSingularProblem();
      70             : 
      71           7 :     _solver.reset(lor_solver);
      72           7 :   }
      73           7 : }
      74             : 
      75             : #endif

Generated by: LCOV version 1.14