https://mooseframework.inl.gov
MFEMMatrixFreeAMS.h
Go to the documentation of this file.
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 
15 
16 namespace Moose::MFEM
17 {
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 
31  void SetBilinearForm(mfem::ParBilinearForm & a) { _aform = &a; }
33  void SetBoundaryMarkers(mfem::Array<int> & ess_bdr_markers)
34  {
35  _ess_bdr_markers = ess_bdr_markers;
36  }
37  void SetOperator(const mfem::Operator & op) override;
38  void Mult(const mfem::Vector & x, mfem::Vector & y) const override
39  {
40  mooseAssert(_matrix_free_ams,
41  "MatrixFreeAMS preconditioner was not initialized with both the operator and "
42  "bilinear form before use.");
43  _matrix_free_ams->Mult(x, y);
44  }
45 
46 private:
47  std::unique_ptr<mfem::MatrixFreeAMS> _matrix_free_ams{nullptr};
48  mfem::Coefficient & _alpha_coef;
49  mfem::Coefficient & _beta_coef;
50  const int _inner_pi_its;
51  const int _inner_g_its;
52  mfem::ParBilinearForm * _aform;
53  mfem::Array<int> _ess_bdr_markers;
54 };
55 } // namespace Moose::MFEM
56 
60 class MFEMMatrixFreeAMS : public Moose::MFEM::LORLinearSolverBase<mfem::MatrixFreeAMS>
61 {
62 public:
64 
66 
67  void ConstructSolver() override;
68 
69 protected:
70  virtual void SetSolverParameters(mfem::MatrixFreeAMS &) override {}
71 
72 private:
73  mfem::Coefficient & _alpha_coef;
74  mfem::Coefficient & _beta_coef;
75  const int _inner_pi_its;
76  const int _inner_g_its;
77 };
78 
79 #endif
void SetOperator(const mfem::Operator &op) override
static InputParameters validParams()
Wrapper for mfem::MatrixFreeAMS solver.
virtual void SetSolverParameters(mfem::MatrixFreeAMS &) override
Update the wrapped MFEM solver parameters.
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
mfem::Coefficient & _beta_coef
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
mfem::Coefficient & _alpha_coef
void SetBoundaryMarkers(mfem::Array< int > &ess_bdr_markers)
Set the marker array labelling essential boundaries.
mfem::Coefficient & _beta_coef
MFEMMatrixFreeAMS(const InputParameters &)
std::unique_ptr< mfem::MatrixFreeAMS > _matrix_free_ams
mfem::ParBilinearForm * _aform
Wrapper for mfem::MatrixFreeAMS solver that creates an mfem::MatrixFreeAMS solver from the operator w...
mfem::Coefficient & _alpha_coef
void SetBilinearForm(mfem::ParBilinearForm &a)
Set the bilinear form corresponding to the curl-curl problem being preconditioned.
MatrixFreeAMS(mfem::Coefficient &alpha_coef, mfem::Coefficient &beta_coef, int inner_pi_its=0, int inner_g_its=1)
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
Base class for LOR compatible linear MFEM solvers and preconditioners.
mfem::Array< int > _ess_bdr_markers