MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
auxiliary.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_AUXILIARY
13#define MFEM_AUXILIARY
14
15#include "../config/config.hpp"
16
17#ifdef MFEM_USE_MPI
18
19#include "solvers.hpp"
20
21namespace mfem
22{
23
24// forward declarations
25class Coefficient;
26class MatrixCoefficient;
27class ParMesh;
28class ParBilinearForm;
29class ParDiscreteLinearOperator;
30
31/** @brief Auxiliary space solvers for MatrixFreeAMS preconditioner
32
33 Given an operator A and a transfer G, create a solver that approximates
34 (G^T A G)^{-1}. Used for two different auxiliary spaces in the AMS cycle.
35
36 The produced solver is based on a low-order refined discretization for the
37 high-order H1 problem. */
39{
40public:
41 /** @brief Pi space constructor
42
43 In the AMS framework this auxiliary space has two coefficients.
44
45 @param mesh_lor Low-order refined auxiliary mesh
46 @param alpha_coeff Coefficient on curl-curl term (1 if null)
47 @param beta_coeff Coefficient on mass term (1 if null)
48 @param beta_mcoeff Matrix coefficient on mass term
49 @param ess_bdr Attributes for essential boundaries
50 @param curlcurl_oper High-order operator for the system
51 @param pi Identity interpolation operator
52 @param useAmgX_ Use AmgX instead of hypre for auxiliary solves
53 @param cg_iterations Number of CG iterations used to invert auxiliary
54 system, choosing 0 means to use a single V-cycle
55 */
57 ParMesh& mesh_lor, Coefficient* alpha_coeff,
58 Coefficient* beta_coeff, MatrixCoefficient* beta_mcoeff,
59 Array<int>& ess_bdr, Operator& curlcurl_oper, Operator& pi,
60#ifdef MFEM_USE_AMGX
61 bool useAmgX_,
62#endif
63 int cg_iterations = 0);
64
65 /** @brief G space constructor
66
67 This has one coefficient in the AMS framework.
68
69 @param mesh_lor Low-order refined auxiliary mesh
70 @param beta_coeff Coefficient on mass term (1 if null)
71 @param beta_mcoeff Matrix coefficient on mass term
72 @param ess_bdr Attributes for essential boundaries
73 @param curlcurl_oper High-order operator for the system
74 @param g Gradient interpolation operator
75 @param useAmgX_ Use AmgX instead of hypre for auxiliary solves
76 @param cg_iterations Number of CG iterations used to invert auxiliary
77 system, choosing 0 means to use a single V-cycle
78 */
80 ParMesh& mesh_lor, Coefficient* beta_coeff,
81 MatrixCoefficient* beta_mcoeff, Array<int>& ess_bdr,
82 Operator& curlcurl_oper, Operator& g,
83#ifdef MFEM_USE_AMGX
84 bool useAmgX_,
85#endif
86 int cg_iterations = 1);
87
89
90 void Mult(const Vector& x, Vector& y) const;
91
92 void SetOperator(const Operator& op) {}
93
94private:
95 /** @brief Helper routine for constructors.
96
97 @param system_dimension is passed to HypreBoomerAMG::SetSystemsOptions
98 */
99 void SetupAMG(int system_dimension);
100 void SetupVCycle();
101
102 /// inner_cg_iterations > 99 applies an exact solve here
103 void SetupCG(Operator& curlcurl_oper, Operator& conn,
104 int inner_cg_iterations);
105
106 MPI_Comm comm;
107 Array<int> ess_tdof_list;
108 HypreParMatrix * lor_matrix;
109 Solver * lor_pc;
110 Operator* matfree;
111 CGSolver* cg;
112 Operator* aspacewrapper;
113#ifdef MFEM_USE_AMGX
114 const bool useAmgX;
115#endif
116 mutable int inner_aux_iterations;
117};
118
119
120/** @brief Perform AMS cycle with generic Operator objects.
121
122 Most users should use MatrixFreeAMS, which wraps this. */
123class GeneralAMS : public Solver
124{
125public:
126 /** @brief Constructor.
127
128 Most of these arguments just need a Mult() operation, but pi and g also
129 require MultTranspose() */
130 GeneralAMS(const Operator& curlcurl_op_,
131 const Operator& pi_,
132 const Operator& gradient_,
133 const Operator& pispacesolver_,
134 const Operator& gspacesolver_,
135 const Operator& smoother_,
136 const Array<int>& ess_tdof_list_);
137 virtual ~GeneralAMS();
138
139 /// in principle this should set A_ = op;
140 void SetOperator(const Operator &op) {}
141
142 virtual void Mult(const Vector& x, Vector& y) const;
143
144private:
145 const Operator& curlcurl_op;
146 const Operator& pi;
147 const Operator& gradient;
148 const Operator& pispacesolver;
149 const Operator& gspacesolver;
150 const Operator& smoother;
151 const Array<int> ess_tdof_list;
152
153 void FormResidual(const Vector& rhs, const Vector& x,
154 Vector& residual) const;
155};
156
157
158/** @brief An auxiliary Maxwell solver for a high-order curl-curl system without
159 high-order assembly.
160
161 The auxiliary space solves are done using a low-order refined approach, but
162 all the interpolation operators, residuals, etc. are done in a matrix-free
163 manner.
164
165 See Barker and Kolev, Matrix-free preconditioning for high-order H(curl)
166 discretizations (https://doi.org/10.1002/nla.2348) */
167class MatrixFreeAMS : public Solver
168{
169public:
170 /** @brief Construct matrix-free AMS preconditioner
171
172 @param aform BilinearForm for curl-curl problem, generally will
173 have a CurlCurlIntegrator and possibly a
174 VectorFEMassIntegrator.
175 @param oper Operator to precondition.
176 @param nd_fespace Underlying Nedelec finite element space.
177 @param alpha_coeff Coefficient on curl-curl term in Maxwell problem
178 (can be null, in which case constant 1 is assumed)
179 @param beta_coeff (scalar) coefficient on mass term in Maxwell problem
180 @param beta_mcoeff (matrix) coefficient on mass term
181 @param ess_bdr Boundary *attributes* that are marked essential. In
182 contrast to other MFEM cases, these are *attributes*
183 not dofs, because we need to apply these boundary
184 conditions to different bilinear forms.
185 @param useAmgX Use AmgX (instead of hypre) for LOR problems
186 @param inner_pi_its Number of CG iterations on auxiliary pi space,
187 may need more for difficult coefficients
188 @param inner_g_its Number of CG iterations on auxiliary g space,
189 may need more for difficult coefficients
190 @param nd_smoother Optional user-provided smoother for Nedelec space,
191 this object takes ownership and will delete.
192 */
194 ParFiniteElementSpace& nd_fespace, Coefficient* alpha_coeff,
195 Coefficient* beta_coeff, MatrixCoefficient* beta_mcoeff,
196 Array<int>& ess_bdr,
197#ifdef MFEM_USE_AMGX
198 bool useAmgX = false,
199#endif
200 int inner_pi_its = 0, int inner_g_its = 1,
201 Solver* nd_smoother = NULL);
202
204
205 void SetOperator(const Operator &op) {}
206
207 void Mult(const Vector& x, Vector& y) const { general_ams->Mult(x, y); }
208
209private:
210 GeneralAMS * general_ams;
211
212 Solver * smoother;
214 OperatorPtr Gradient;
215 ParDiscreteLinearOperator * pa_interp;
216 OperatorPtr Pi;
217
218 Solver * Gspacesolver;
219 Solver * Pispacesolver;
220
221 ParFiniteElementSpace * h1_fespace;
222 ParFiniteElementSpace * h1_fespace_d;
223};
224
225} // namespace mfem
226
227#endif // MFEM_USE_MPI
228
229#endif
Conjugate gradient method.
Definition solvers.hpp:513
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Perform AMS cycle with generic Operator objects.
void SetOperator(const Operator &op)
in principle this should set A_ = op;
virtual ~GeneralAMS()
Definition auxiliary.cpp:42
GeneralAMS(const Operator &curlcurl_op_, const Operator &pi_, const Operator &gradient_, const Operator &pispacesolver_, const Operator &gspacesolver_, const Operator &smoother_, const Array< int > &ess_tdof_list_)
Constructor.
Definition auxiliary.cpp:23
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Definition auxiliary.cpp:70
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:388
Base class for Matrix Coefficients that optionally depend on time and space.
An auxiliary Maxwell solver for a high-order curl-curl system without high-order assembly.
void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
MatrixFreeAMS(ParBilinearForm &aform, Operator &oper, ParFiniteElementSpace &nd_fespace, Coefficient *alpha_coeff, Coefficient *beta_coeff, MatrixCoefficient *beta_mcoeff, Array< int > &ess_bdr, #ifdef MFEM_USE_AMGX bool useAmgX=false, #endif int inner_pi_its=0, int inner_g_its=1, Solver *nd_smoother=NULL)
Construct matrix-free AMS preconditioner.
Auxiliary space solvers for MatrixFreeAMS preconditioner.
Definition auxiliary.hpp:39
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
MatrixFreeAuxiliarySpace(ParMesh &mesh_lor, Coefficient *alpha_coeff, Coefficient *beta_coeff, MatrixCoefficient *beta_mcoeff, Array< int > &ess_bdr, Operator &curlcurl_oper, Operator &pi, #ifdef MFEM_USE_AMGX bool useAmgX_, #endif int cg_iterations=0)
Pi space constructor.
void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition auxiliary.hpp:92
Pointer to an Operator of a specified type.
Definition handle.hpp:34
Abstract operator.
Definition operator.hpp:25
Class for parallel bilinear form.
Abstract parallel finite element space.
Definition pfespace.hpp:29
Class for parallel meshes.
Definition pmesh.hpp:34
Base class for solvers.
Definition operator.hpp:683
Vector data type.
Definition vector.hpp:80