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 : #pragma once 13 : 14 : #include "MFEMLinearSolverBase.h" 15 : 16 : namespace Moose::MFEM 17 : { 18 : /** 19 : * Wrapper for mfem::MatrixFreeAMS solver that creates an mfem::MatrixFreeAMS solver from the 20 : * operator when set. 21 : */ 22 : class MatrixFreeAMS : public mfem::Solver 23 : { 24 : public: 25 : MatrixFreeAMS(mfem::Coefficient & alpha_coef, 26 : mfem::Coefficient & beta_coef, 27 : int inner_pi_its = 0, 28 : int inner_g_its = 1); 29 : 30 : /// Set the bilinear form corresponding to the curl-curl problem being preconditioned 31 7 : void SetBilinearForm(mfem::ParBilinearForm & a) { _aform = &a; } 32 : /// Set the marker array labelling essential boundaries 33 7 : void SetBoundaryMarkers(mfem::Array<int> & ess_bdr_markers) 34 : { 35 7 : _ess_bdr_markers = ess_bdr_markers; 36 7 : } 37 : void SetOperator(const mfem::Operator & op) override; 38 858 : void Mult(const mfem::Vector & x, mfem::Vector & y) const override 39 : { 40 858 : _matrix_free_ams->Mult(x, y); 41 858 : } 42 : 43 : private: 44 : std::unique_ptr<mfem::MatrixFreeAMS> _matrix_free_ams{nullptr}; 45 : mfem::Coefficient & _alpha_coef; 46 : mfem::Coefficient & _beta_coef; 47 : const int _inner_pi_its; 48 : const int _inner_g_its; 49 : mfem::ParBilinearForm * _aform; 50 : mfem::Array<int> _ess_bdr_markers; 51 : }; 52 : } // namespace Moose::MFEM 53 : 54 : /** 55 : * Wrapper for mfem::MatrixFreeAMS solver. 56 : */ 57 : class MFEMMatrixFreeAMS : public Moose::MFEM::LinearSolverBase 58 : { 59 : public: 60 : static InputParameters validParams(); 61 : 62 : MFEMMatrixFreeAMS(const InputParameters &); 63 : 64 : /// Updates the solver with the bilinear form, as MFEMMatrixFreeAMS is an LOR-based solver 65 : void SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & ess_bdr_markers) override; 66 : 67 : protected: 68 : void ConstructSolver() override; 69 : 70 : private: 71 : mfem::Coefficient & _alpha_coef; 72 : mfem::Coefficient & _beta_coef; 73 : const int _inner_pi_its; 74 : const int _inner_g_its; 75 : }; 76 : 77 : #endif