LCOV - code coverage report
Current view: top level - src/mfem/solvers - MFEMHypreAMS.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 32 84.4 %
Date: 2025-07-17 01:28:37 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 MFEM_ENABLED
      11             : 
      12             : #include "MFEMHypreAMS.h"
      13             : 
      14             : registerMooseObject("MooseApp", MFEMHypreAMS);
      15             : 
      16             : InputParameters
      17        8648 : MFEMHypreAMS::validParams()
      18             : {
      19        8648 :   InputParameters params = MFEMSolverBase::validParams();
      20        8648 :   params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the "
      21             :                              "iterative solution of MFEM equation systems.");
      22        8648 :   params.addParam<UserObjectName>("fespace", "H(curl) FESpace to use in HypreAMS setup.");
      23       25944 :   params.addParam<bool>("singular",
      24       17296 :                         false,
      25             :                         "Declare that the system is singular; use when solving curl-curl problem "
      26             :                         "if mass term is zero");
      27        8648 :   params.addParam<int>("print_level", 2, "Set the solver verbosity.");
      28             : 
      29        8648 :   return params;
      30           0 : }
      31             : 
      32           9 : MFEMHypreAMS::MFEMHypreAMS(const InputParameters & parameters)
      33           9 :   : MFEMSolverBase(parameters), _mfem_fespace(getUserObject<MFEMFESpace>("fespace"))
      34             : {
      35           9 :   constructSolver(parameters);
      36           9 : }
      37             : 
      38             : void
      39           9 : MFEMHypreAMS::constructSolver(const InputParameters &)
      40             : {
      41           9 :   auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get());
      42           9 :   if (getParam<bool>("singular"))
      43           0 :     solver->SetSingularProblem();
      44             : 
      45           9 :   solver->SetPrintLevel(getParam<int>("print_level"));
      46             : 
      47           9 :   _solver = std::move(solver);
      48           9 : }
      49             : 
      50             : void
      51           8 : MFEMHypreAMS::updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs)
      52             : {
      53           8 :   if (_lor)
      54             :   {
      55           4 :     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           4 :     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           4 :     auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs);
      64           4 :     lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level"));
      65           4 :     if (getParam<bool>("singular"))
      66           0 :       lor_solver->GetSolver().SetSingularProblem();
      67             : 
      68           4 :     _solver.reset(lor_solver);
      69             :   }
      70           8 : }
      71             : 
      72             : #endif

Generated by: LCOV version 1.14