LCOV - code coverage report
Current view: top level - src/mfem/solvers - MFEMHypreAMS.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 28 32 87.5 %
Date: 2025-08-29 20:01:24 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             : 
      14             : registerMooseObject("MooseApp", MFEMHypreAMS);
      15             : 
      16             : InputParameters
      17        8670 : MFEMHypreAMS::validParams()
      18             : {
      19        8670 :   InputParameters params = MFEMSolverBase::validParams();
      20       17340 :   params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the "
      21             :                              "iterative solution of MFEM equation systems.");
      22       34680 :   params.addParam<UserObjectName>("fespace", "H(curl) FESpace to use in HypreAMS setup.");
      23       26010 :   params.addParam<bool>("singular",
      24       17340 :                         false,
      25             :                         "Declare that the system is singular; use when solving curl-curl problem "
      26             :                         "if mass term is zero");
      27       26010 :   params.addParam<int>("print_level", 2, "Set the solver verbosity.");
      28             : 
      29        8670 :   return params;
      30           0 : }
      31             : 
      32          20 : MFEMHypreAMS::MFEMHypreAMS(const InputParameters & parameters)
      33          40 :   : MFEMSolverBase(parameters), _mfem_fespace(getUserObject<MFEMFESpace>("fespace"))
      34             : {
      35          20 :   constructSolver(parameters);
      36          20 : }
      37             : 
      38             : void
      39          20 : MFEMHypreAMS::constructSolver(const InputParameters &)
      40             : {
      41          20 :   auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get());
      42          60 :   if (getParam<bool>("singular"))
      43           5 :     solver->SetSingularProblem();
      44             : 
      45          40 :   solver->SetPrintLevel(getParam<int>("print_level"));
      46             : 
      47          20 :   _solver = std::move(solver);
      48          20 : }
      49             : 
      50             : void
      51          19 : MFEMHypreAMS::updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs)
      52             : {
      53          19 :   if (_lor)
      54             :   {
      55           9 :     if (!checkSpectralEquivalence(a))
      56           0 :       mooseError("Low-Order-Refined solver requires the FESpace closed_basis to be GaussLobatto "
      57             :                  "and the open-basis to be IntegratedGLL for ND and RT elements.");
      58             : 
      59           9 :     if (_mfem_fespace.getFESpace()->GetMesh()->GetElement(0)->GetGeometryType() !=
      60             :         mfem::Geometry::Type::CUBE)
      61           0 :       mooseError("LOR HypreAMS Solver only supports hex meshes.");
      62             : 
      63           9 :     auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs);
      64          18 :     lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
      65          27 :     if (getParam<bool>("singular"))
      66           0 :       lor_solver->GetSolver().SetSingularProblem();
      67             : 
      68           9 :     _solver.reset(lor_solver);
      69             :   }
      70          19 : }
      71             : 
      72             : #endif

Generated by: LCOV version 1.14