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 
51 {
52 public:
54 
56 
58  void ConstructSolver() override;
59 
60 protected:
62  void SetOperatorImpl(mfem::Operator & op) override;
63 
64 private:
67  mfem::AssemblyLevel ParseAssemblyLevel(const std::string & s) const;
68 
70  void BuildMultigrid(const mfem::Operator & op);
71 
80  class MGProxy : public mfem::Solver
81  {
82  public:
85 
87  void SetMG(mfem::GeometricMultigrid & mg);
88 
90  void SetOperator(const mfem::Operator & op) override;
91 
93  void Mult(const mfem::Vector & x, mfem::Vector & y) const override;
94 
95  private:
98 
100  mfem::GeometricMultigrid * _mg = nullptr;
101  };
102 
104  const std::string _var_name;
105 
107  std::shared_ptr<mfem::ParFiniteElementSpaceHierarchy> _hierarchy;
108 
110  const std::vector<MFEMSolverName> _smoother_names;
111 
113  const MFEMSolverName _coarse_solver_name;
114 
116  std::vector<mfem::AssemblyLevel> _assembly_levels;
117 
119  MGProxy * _mg_proxy = nullptr;
120 
122  std::vector<std::shared_ptr<mfem::ParBilinearForm>> _level_blfs;
123 
125  std::vector<std::unique_ptr<mfem::OperatorHandle>> _level_ops;
126 
128  std::unique_ptr<mfem::GeometricMultigrid> _mg;
129 };
130 
131 #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.
void SetOperatorImpl(mfem::Operator &op) override
Rebuilds the multigrid hierarchy for the supplied finest-level operator.
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 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:...
void SetMG(mfem::GeometricMultigrid &mg)
Updates the concrete MFEM multigrid object used by Mult().
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.
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.