https://mooseframework.inl.gov
MFEMMatrixFreeAMS.C
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 #include "MFEMMatrixFreeAMS.h"
13 #include "MFEMProblem.h"
14 
16 
17 namespace Moose::MFEM
18 {
19 MatrixFreeAMS::MatrixFreeAMS(mfem::Coefficient & alpha_coef,
20  mfem::Coefficient & beta_coef,
21  int inner_pi_its,
22  int inner_g_its)
23  : _alpha_coef(alpha_coef),
24  _beta_coef(beta_coef),
25  _inner_pi_its(inner_pi_its),
26  _inner_g_its(inner_g_its)
27 {
28 }
29 
30 void
31 MatrixFreeAMS::SetOperator(const mfem::Operator & op)
32 {
33  height = op.Height();
34  width = op.Width();
35  // The constructor of mfem::MatrixFreeAMS requires the target operator to be known, so this
36  // constructs the solver
37  auto matrix_free_ams = std::make_unique<mfem::MatrixFreeAMS>(*_aform,
38  const_cast<mfem::Operator &>(op),
39  *_aform->ParFESpace(),
40  &_alpha_coef,
41  &_beta_coef,
42  nullptr,
45  _inner_g_its);
46  _matrix_free_ams = std::move(matrix_free_ams);
47 }
48 } // namespace Moose::MFEM
49 
52 {
54  params.addClassDescription("MFEM matrix-free auxiliary-space Maxwell preconditioner for the "
55  "iterative solution of MFEM equation systems.");
56  params.addParam<MFEMScalarCoefficientName>(
57  "alpha_coefficient",
58  "1.",
59  "Name of scalar coefficient used in curl-curl component of target equation system.");
60  params.addParam<MFEMScalarCoefficientName>(
61  "beta_coefficient",
62  "1.",
63  "Name of scalar coefficient used in mass component of target equation system.");
64  params.addParam<unsigned int>(
65  "inner_pi_iterations", 0, "Number of CG iterations on auxiliary Pi space.");
66  params.addParam<unsigned int>(
67  "inner_g_iterations", 1, "Number of CG iterations on auxiliary G space.");
68  // mfem::MatrixFreeAMS is always an LOR solver
69  params.setParameters("low_order_refined", true);
70  params.suppressParameter<bool>("low_order_refined");
71  return params;
72 }
73 
75  : Moose::MFEM::LinearSolverBase(parameters),
76  _alpha_coef(getScalarCoefficient("alpha_coefficient")),
77  _beta_coef(getScalarCoefficient("beta_coefficient")),
78  _inner_pi_its(getParam<unsigned int>("inner_pi_iterations")),
79  _inner_g_its(getParam<unsigned int>("inner_g_iterations"))
80 {
82 }
83 
84 void
86 {
87  auto solver = std::make_unique<Moose::MFEM::MatrixFreeAMS>(
89  solver->iterative_mode = getParam<bool>("use_initial_guess");
90  _solver = std::move(solver);
91 }
92 
93 void
94 MFEMMatrixFreeAMS::SetupLOR(mfem::ParBilinearForm & a, mfem::Array<int> & ess_bdr_markers)
95 {
96  // update the pointer to the bilinear form representing the curl-curl problem being preconditioned
97  auto & matrix_free_ams = static_cast<Moose::MFEM::MatrixFreeAMS &>(*_solver);
98  matrix_free_ams.SetBilinearForm(a);
99  matrix_free_ams.SetBoundaryMarkers(ess_bdr_markers);
100 }
101 
102 #endif
void SetOperator(const mfem::Operator &op) override
static InputParameters validParams()
Wrapper for mfem::MatrixFreeAMS solver.
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
mfem::Coefficient & _beta_coef
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void SetupLOR(mfem::ParBilinearForm &a, mfem::Array< int > &ess_bdr_markers) override
Updates the solver with the bilinear form, as MFEMMatrixFreeAMS is an LOR-based solver.
mfem::Coefficient & _alpha_coef
registerMooseObject("MooseApp", MFEMMatrixFreeAMS)
static InputParameters validParams()
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
mfem::Array< int > _ess_bdr_markers
void ErrorVector unsigned int
void setParameters(const std::string &name, const T &value, Ts... extra_input_parameters)
Given a series of parameters names and values, sets each name to the corresponding value...