MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
bramble_pasciak.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// ----------------------------------------------------------
13// Bramble-Pasciak preconditioning for Darcy problem
14// ----------------------------------------------------------
15//
16// Main idea is to transform the block system
17// Ax = [ M B^T ] [u] = [f] = b
18// [ B 0 ] [p] = [g]
19// where:
20// M = \int_\Omega (k u_h) \cdot v_h dx,
21// B = -\int_\Omega (div_h u_h) q_h dx,
22// u_h, v_h \in R_h (Raviart-Thomas finite element space),
23// q_h \in W_h (piecewise discontinuous polynomials),
24// with a block transformation of the form X = A*N - Id
25// X = [ M*invQ - Id 0 ]
26// [ B*invQ -Id ]
27// where N is defined by
28// N = [ invQ 0 ]
29// [ 0 0 ]
30// and Q is constructed such that Q and M-Q are both s.p.d..
31//
32// The solution x is then obtained by solving XAx = Xb with PCG as XA is s.p.d.
33//
34// The codes allows the user to provide such Q, or to construct it from the
35// element matrices M_T. Moreover, the user can provide a block preconditioner
36// P = [ M_0 0 ]
37// [ 0 M_1 ]
38// for the transformed system XA.
39//
40// The code also allows the user to use BPCG, which is a special implementation
41// of the PCG iteration with the particular preconditioner H, defined as
42// H = [ M - Q 0 ]
43// [ 0 M_1 ]
44// BPCG is efficient as it avoids the direct application of invH and X.
45
46#ifndef MFEM_BP_SOLVER_HPP
47#define MFEM_BP_SOLVER_HPP
48
49#include "darcy_solver.hpp"
50#include <memory>
51
52namespace mfem
53{
54namespace blocksolvers
55{
56
57/// Parameters for the BramblePasciakSolver method
59{
60 bool use_bpcg = true; // whether to use BPCG
61 real_t q_scaling = 0.5; // scaling (> 0 and < 1) of the Q preconditioner
62};
63
64/// Bramble-Pasciak Conjugate Gradient
66{
67protected:
68 mutable Vector r, p, g, t, r_bar, r_red, g_red;
70 void UpdateVectors();
71
72public:
73 BPCGSolver(const Operator &ipc, const Operator &ppc) { pprec = &ppc; iprec = &ipc; }
74
75#ifdef MFEM_USE_MPI
76 BPCGSolver(MPI_Comm comm_, const Operator &ipc, const Operator &ppc)
77 : IterativeSolver(comm_) { pprec = &ppc; iprec = &ipc; }
78#endif
79
80 virtual void SetOperator(const Operator &op)
82
83 virtual void SetPreconditioner(Solver &pc)
84 { if (Mpi::Root()) { MFEM_WARNING("SetPreconditioner has no effect on BPCGSolver.\n"); } }
85
86 virtual void SetIncompletePreconditioner(const Operator &ipc)
87 { iprec = &ipc; }
88
89 virtual void SetParticularPreconditioner(const Operator &ppc)
90 { pprec = &ppc; }
91
92 virtual void Mult(const Vector &b, Vector &x) const;
93};
94
95/// Bramble-Pasciak Solver for Darcy equation.
96/** Bramble-Pasciak Solver for Darcy equation.
97
98 The basic idea is to precondition the mass matrix M with a s.p.d. matrix Q
99 such that M - Q remains s.p.d. Then we can transform the block operator into
100 a s.p.d. operator under a modified inner product. In particular, this enable
101 us to implement modified versions of CG iterations, that rely on efficient
102 applications of the required transformations.
103
104 We offer a mass preconditioner based on a rescaling of the diagonal of the
105 element mass matrices M_T.
106
107 We consider Q_T := alpha * lambda_min * D_T, where D_T := diag(M_T), and
108 lambda_min is the smallest eigenvalue of the following problem
109
110 M_T x = lambda * D_T x.
111
112 Alpha is a parameter that is strictly between 0 and 1.
113
114 For more details, see:
115
116 1. P. Vassilevski, Multilevel Block Factorization Preconditioners (Appendix
117 F.3), Springer, 2008.
118
119 2. J. Bramble and J. Pasciak. A Preconditioning Technique for Indefinite
120 Systems Resulting From Mixed Approximations of Elliptic Problems,
121 Mathematics of Computation, 50:1-17, 1988. */
123{
124 mutable bool use_bpcg;
125 std::unique_ptr<IterativeSolver> solver_;
126 BlockOperator *oop_, *ipc_;
127 ProductOperator *mop_;
128 SumOperator *map_;
129 ProductOperator *ppc_;
131 std::unique_ptr<HypreParMatrix> M_;
132 std::unique_ptr<HypreParMatrix> B_;
133 std::unique_ptr<HypreParMatrix> Q_;
134 OperatorPtr M0_;
135 OperatorPtr M1_;
136 Array<int> ess_zero_dofs_;
137
140 Solver &M0, Solver &M1,
141 const BPSParameters &param);
142public:
143 /// System and mass preconditioner are constructed from bilinear forms
145 ParBilinearForm *mVarf,
147 const BPSParameters &param);
148
149 /// System and mass preconditioner are user-provided
152 Solver &M0, Solver &M1,
153 const BPSParameters &param);
154
155 /// Assemble a preconditioner for the mass matrix
156 /** Mass preconditioner corresponds to a local re-scaling based on the
157 smallest eigenvalue of the generalized eigenvalue problem locally on each
158 element T:
159 M_T x_T = lambda_T diag(M_T) x_T.
160 We set Q_T = alpha * min(lambda_T) * diag(M_T), 0 < alpha < 1. */
162 real_t alpha = 0.5);
163
164 virtual void Mult(const Vector &x, Vector &y) const;
165 virtual void SetOperator(const Operator &op) { }
166 void SetEssZeroDofs(const Array<int>& dofs) { dofs.Copy(ess_zero_dofs_); }
167 virtual int GetNumIterations() const { return solver_->GetNumIterations(); }
168};
169
170} // namespace blocksolvers
171} // namespace mfem
172
173#endif // MFEM_BP_SOLVER_HPP
void Copy(Array &copy) const
Create a copy of the internal array to the provided copy.
Definition array.hpp:874
A class to handle Block diagonal preconditioners in a matrix-free implementation.
A class to handle Block systems in a matrix-free implementation.
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:388
A class to initialize the size of a Tensor.
Definition dtensor.hpp:55
Abstract base class for iterative solver.
Definition solvers.hpp:67
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:179
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
Pointer to an Operator of a specified type.
Definition handle.hpp:34
Abstract operator.
Definition operator.hpp:25
Class for parallel bilinear form.
Class for parallel bilinear form using different test and trial FE spaces.
General product operator: x -> (A*B)(x) = A(B(x)).
Definition operator.hpp:797
Base class for solvers.
Definition operator.hpp:683
General linear combination operator: x -> a A(x) + b B(x).
Definition operator.hpp:774
Vector data type.
Definition vector.hpp:80
Bramble-Pasciak Conjugate Gradient.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetParticularPreconditioner(const Operator &ppc)
BPCGSolver(MPI_Comm comm_, const Operator &ipc, const Operator &ppc)
virtual void SetPreconditioner(Solver &pc)
This should be called before SetOperator.
BPCGSolver(const Operator &ipc, const Operator &ppc)
virtual void SetIncompletePreconditioner(const Operator &ipc)
void UpdateVectors()
Bramble-Pasciak CG.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Bramble-Pasciak Solver for Darcy equation.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
static HypreParMatrix * ConstructMassPreconditioner(ParBilinearForm &mVarf, real_t alpha=0.5)
Assemble a preconditioner for the mass matrix.
BramblePasciakSolver(ParBilinearForm *mVarf, ParMixedBilinearForm *bVarf, const BPSParameters &param)
System and mass preconditioner are constructed from bilinear forms.
void SetEssZeroDofs(const Array< int > &dofs)
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Abstract solver class for Darcy's flow.
const real_t alpha
Definition ex15.cpp:369
real_t b
Definition lissajous.cpp:42
float real_t
Definition config.hpp:43
Parameters for the BramblePasciakSolver method.