https://mooseframework.inl.gov
MFEMGeometricMultigridSolver.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 
14 #include "MFEMLinearSolverBase.h"
15 #include "MFEMFESpaceHierarchy.h"
16 #include "libmesh/ignore_warnings.h"
17 #include "mfem/fem/multigrid.hpp"
18 #include "libmesh/restore_warnings.h"
19 
54 {
55 public:
57 
59 
61  void ConstructSolver() override;
62 
64  void SetOperator(mfem::Operator & op) override;
65 
66 private:
69  mfem::AssemblyLevel ParseAssemblyLevel(const std::string & s) const;
70 
72  void BuildMultigrid(const mfem::Operator & op);
73 
82  class MGProxy : public mfem::Solver
83  {
84  public:
87 
89  void setMG(mfem::GeometricMultigrid & mg);
90 
92  void SetOperator(const mfem::Operator & op) override;
93 
95  void Mult(const mfem::Vector & x, mfem::Vector & y) const override;
96 
97  private:
100 
102  mfem::GeometricMultigrid * _mg = nullptr;
103  };
104 
106  const std::string _var_name;
107 
109  std::shared_ptr<mfem::ParFiniteElementSpaceHierarchy> _hierarchy;
110 
112  const std::vector<MFEMSolverName> _smoother_names;
113 
115  const MFEMSolverName _coarse_solver_name;
116 
118  std::vector<mfem::AssemblyLevel> _assembly_levels;
119 
121  MGProxy * _mg_proxy = nullptr;
122 
124  std::vector<std::shared_ptr<mfem::ParBilinearForm>> _level_blfs;
125 
127  std::vector<std::unique_ptr<mfem::OperatorHandle>> _level_ops;
128 
130  std::unique_ptr<mfem::GeometricMultigrid> _mg;
131 };
132 
133 #endif
void ConstructSolver() override
Creates a stable proxy solver; the real multigrid is built when the proxy gets an operator...
std::shared_ptr< mfem::ParFiniteElementSpaceHierarchy > _hierarchy
Finite element space hierarchy defining the multigrid levels.
MFEMGeometricMultigridSolver(const InputParameters &parameters)
void BuildMultigrid(const mfem::Operator &op)
Rebuild the multigrid object and per-level operators for the supplied finest-level operator...
const std::string _var_name
Trial variable whose operator is preconditioned by this solver.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
mfem::GeometricMultigrid * _mg
Non-owning pointer to the currently active concrete MFEM multigrid object.
MGProxy(MFEMGeometricMultigridSolver &owner)
Constructs a proxy that delegates multigrid rebuilding to the owning MOOSE solver.
std::vector< mfem::AssemblyLevel > _assembly_levels
Assembly level requested for each multigrid level after optional single-value expansion.
const MFEMSolverName _coarse_solver_name
Name of the solver used on the coarsest multigrid level.
Base class for linear MFEM solvers and preconditioners.
void SetOperator(mfem::Operator &op) override
Rebuilds the multigrid hierarchy for the supplied finest-level operator.
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Applies the current concrete MFEM multigrid preconditioner.
std::vector< std::shared_ptr< mfem::ParBilinearForm > > _level_blfs
Rediscretized bilinear forms kept alive for the active linear coarse-level operators.
const std::vector< MFEMSolverName > _smoother_names
Names of solvers used as smoothers on interior multigrid levels.
Stable preconditioner object seen by outer MFEM solvers.
std::unique_ptr< mfem::GeometricMultigrid > _mg
Concrete MFEM multigrid preconditioner rebuilt on each SetOperator() call.
mfem::AssemblyLevel ParseAssemblyLevel(const std::string &s) const
Map assembly-level string ("legacy", "full", "element", "partial", "none") to the corresponding mfem:...
MGProxy * _mg_proxy
Non-owning pointer to the proxy solver stored in _solver.
P-multigrid / geometric multigrid preconditioner backed by mfem::GeometricMultigrid.
MFEMGeometricMultigridSolver & _owner
Solver object that owns the concrete multigrid and level data.
void setMG(mfem::GeometricMultigrid &mg)
Updates the concrete MFEM multigrid object used by Mult().
std::vector< std::unique_ptr< mfem::OperatorHandle > > _level_ops
Constrained linear coarse-level operators; destroyed before the forms that own their data...
void SetOperator(const mfem::Operator &op) override
Rebuilds the owner&#39;s multigrid hierarchy for the new outer-solver operator.