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 2336 : MFEMHypreAMS::validParams() 19 : { 20 2336 : InputParameters params = Moose::MFEM::LinearSolverBase::validParams(); 21 4672 : params.addClassDescription("Hypre auxiliary-space Maxwell solver and preconditioner for the " 22 : "iterative solution of MFEM equation systems."); 23 9344 : params.addParam<MFEMFESpaceName>("fespace", "H(curl) FESpace to use in HypreAMS setup."); 24 7008 : params.addParam<bool>("singular", 25 4672 : false, 26 : "Declare that the system is singular; use when solving curl-curl problem " 27 : "if mass term is zero"); 28 7008 : params.addParam<int>("print_level", 2, "Set the solver verbosity."); 29 : 30 2336 : return params; 31 0 : } 32 : 33 119 : MFEMHypreAMS::MFEMHypreAMS(const InputParameters & parameters) 34 : : Moose::MFEM::LinearSolverBase(parameters), 35 119 : _mfem_fespace(getMFEMProblem().getMFEMObject<MFEMFESpace>("MFEMFESpace", 36 357 : getParam<MFEMFESpaceName>("fespace"))) 37 : { 38 119 : ConstructSolver(); 39 119 : } 40 : 41 : void 42 119 : MFEMHypreAMS::ConstructSolver() 43 : { 44 119 : auto solver = std::make_unique<mfem::HypreAMS>(_mfem_fespace.getFESpace().get()); 45 357 : if (getParam<bool>("singular")) 46 27 : solver->SetSingularProblem(); 47 : 48 238 : solver->iterative_mode = getParam<bool>("use_initial_guess"); 49 238 : solver->SetPrintLevel(getParam<int>("print_level")); 50 : 51 119 : _solver = std::move(solver); 52 119 : } 53 : 54 : void 55 7 : MFEMHypreAMS::SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & tdofs) 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 : auto lor_solver = new mfem::LORSolver<mfem::HypreAMS>(a, tdofs); 65 14 : lor_solver->GetSolver().SetPrintLevel(getParam<int>("print_level")); 66 21 : if (getParam<bool>("singular")) 67 0 : lor_solver->GetSolver().SetSingularProblem(); 68 : 69 7 : _solver.reset(lor_solver); 70 : } 71 7 : } 72 : 73 : #endif