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 9424 : MFEMHypreAMS::validParams() 18 : { 19 9424 : InputParameters params = MFEMSolverBase::validParams(); 20 18848 : params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the " 21 : "iterative solution of MFEM equation systems."); 22 37696 : params.addParam<UserObjectName>("fespace", "H(curl) FESpace to use in HypreAMS setup."); 23 28272 : params.addParam<bool>("singular", 24 18848 : false, 25 : "Declare that the system is singular; use when solving curl-curl problem " 26 : "if mass term is zero"); 27 28272 : params.addParam<int>("print_level", 2, "Set the solver verbosity."); 28 : 29 9424 : return params; 30 0 : } 31 : 32 36 : MFEMHypreAMS::MFEMHypreAMS(const InputParameters & parameters) 33 72 : : MFEMSolverBase(parameters), _mfem_fespace(getUserObject<MFEMFESpace>("fespace")) 34 : { 35 36 : constructSolver(parameters); 36 36 : } 37 : 38 : void 39 36 : MFEMHypreAMS::constructSolver(const InputParameters &) 40 : { 41 36 : auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get()); 42 108 : if (getParam<bool>("singular")) 43 5 : solver->SetSingularProblem(); 44 : 45 72 : solver->SetPrintLevel(getParam<int>("print_level")); 46 : 47 36 : _solver = std::move(solver); 48 36 : } 49 : 50 : void 51 55 : MFEMHypreAMS::updateSolver(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs) 52 : { 53 55 : if (_lor) 54 : { 55 9 : checkSpectralEquivalence(a); 56 9 : if (_mfem_fespace.getFESpace()->GetMesh()->GetElement(0)->GetGeometryType() != 57 : mfem::Geometry::Type::CUBE) 58 0 : mooseError("LOR HypreAMS Solver only supports hex meshes."); 59 : 60 9 : auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs); 61 18 : lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level")); 62 27 : if (getParam<bool>("singular")) 63 0 : lor_solver->GetSolver().SetSingularProblem(); 64 : 65 9 : _solver.reset(lor_solver); 66 : } 67 55 : } 68 : 69 : #endif