MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
bramble_pasciak.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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::blocksolvers
53{
54
55/// Parameters for the BramblePasciakSolver method
57{
58 bool use_bpcg = true; // whether to use BPCG
59 real_t q_scaling = 0.5; // scaling (> 0 and < 1) of the Q preconditioner
60};
61
62/// Bramble-Pasciak Conjugate Gradient
64{
65protected:
66 mutable Vector r, p, g, t, r_bar, r_red, g_red;
68 void UpdateVectors();
69
70public:
71 BPCGSolver(const Operator *ipc, const Operator *ppc): iprec(ipc), pprec(ppc) {}
72
73#ifdef MFEM_USE_MPI
74 BPCGSolver(MPI_Comm comm_, const Operator *ipc, const Operator *ppc)
75 : IterativeSolver(comm_), iprec(ipc), pprec(ppc) { }
76#endif
77
78 void SetOperator(const Operator &op) override
80
81 void SetPreconditioner(Solver &pc) override
82 { if (Mpi::Root()) { MFEM_WARNING("SetPreconditioner has no effect on BPCGSolver.\n"); } }
83
84 virtual void SetIncompletePreconditioner(const Operator *ipc) { iprec = ipc; }
85
86 virtual void SetParticularPreconditioner(const Operator *ppc) { pprec = ppc; }
87
88 void Mult(const Vector &b, Vector &x) const override;
89};
90
91/// Bramble-Pasciak Solver for Darcy equation.
92/** Bramble-Pasciak Solver for Darcy equation.
93
94 The basic idea is to precondition the mass matrix M with a s.p.d. matrix Q
95 such that M - Q remains s.p.d. Then we can transform the block operator into
96 a s.p.d. operator under a modified inner product. In particular, this enable
97 us to implement modified versions of CG iterations, that rely on efficient
98 applications of the required transformations.
99
100 We offer a mass preconditioner based on a rescaling of the diagonal of the
101 element mass matrices M_T.
102
103 We consider Q_T := alpha * lambda_min * D_T, where D_T := diag(M_T), and
104 lambda_min is the smallest eigenvalue of the following problem
105
106 M_T x = lambda * D_T x.
107
108 Alpha is a parameter that is strictly between 0 and 1.
109
110 For more details, see:
111
112 1. P. Vassilevski, Multilevel Block Factorization Preconditioners (Appendix
113 F.3), Springer, 2008.
114
115 2. J. Bramble and J. Pasciak. A Preconditioning Technique for Indefinite
116 Systems Resulting From Mixed Approximations of Elliptic Problems,
117 Mathematics of Computation, 50:1-17, 1988. */
119{
120 mutable bool use_bpcg;
121 std::unique_ptr<IterativeSolver> solver_;
122 std::unique_ptr<BlockOperator> oop_, ipc_;
123 std::unique_ptr<ProductOperator> mop_, ppc_;
124 std::unique_ptr<SumOperator> map_;
125 std::unique_ptr<BlockDiagonalPreconditioner> cpc_;
126 std::unique_ptr<HypreParMatrix> M_, B_, Q_, S_;
127 std::unique_ptr<TransposeOperator> Bt_;
128 OperatorPtr M0_, M1_;
129 Array<int> ess_zero_dofs_;
130
133 Solver &M0, Solver &M1,
134 const BPSParameters &param);
135public:
136 /// System and mass preconditioner are constructed from bilinear forms
138 ParBilinearForm &mVarf,
140 const BPSParameters &param);
141
142 /// System and mass preconditioner are user-provided
145 Solver &M0, Solver &M1,
146 const BPSParameters &param);
147
148 /// Assemble a preconditioner for the mass matrix
149 /** Mass preconditioner corresponds to a local re-scaling based on the
150 smallest eigenvalue of the generalized eigenvalue problem locally on each
151 element T:
152 M_T x_T = lambda_T diag(M_T) x_T.
153 We set Q_T = alpha * min(lambda_T) * diag(M_T), 0 < alpha < 1. */
155 const real_t alpha = 0.5);
156
157 void Mult(const Vector &x, Vector &y) const override;
158 void SetOperator(const Operator &op) override { }
159 void SetEssZeroDofs(const Array<int>& dofs) { dofs.Copy(ess_zero_dofs_); }
160 int GetNumIterations() const override { return solver_->GetNumIterations(); }
161};
162
163} // namespace mfem::blocksolvers
164
165#endif // MFEM_BP_SOLVER_HPP
void Copy(Array &copy) const
Create a copy of the internal array to the provided copy.
Definition array.hpp:1042
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:419
A class to initialize the size of a Tensor.
Definition dtensor.hpp:57
Abstract base class for iterative solver.
Definition solvers.hpp:91
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:184
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.
Base class for solvers.
Definition operator.hpp:792
Vector data type.
Definition vector.hpp:82
Bramble-Pasciak Conjugate Gradient.
void SetPreconditioner(Solver &pc) override
This should be called before SetOperator.
BPCGSolver(MPI_Comm comm_, const Operator *ipc, const Operator *ppc)
void Mult(const Vector &b, Vector &x) const override
Operator application: y=A(x).
virtual void SetIncompletePreconditioner(const Operator *ipc)
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void UpdateVectors()
Bramble-Pasciak CG.
BPCGSolver(const Operator *ipc, const Operator *ppc)
virtual void SetParticularPreconditioner(const Operator *ppc)
Bramble-Pasciak Solver for Darcy equation.
BramblePasciakSolver(ParBilinearForm &mVarf, ParMixedBilinearForm &bVarf, const BPSParameters &param)
System and mass preconditioner are constructed from bilinear forms.
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
static HypreParMatrix * ConstructMassPreconditioner(const ParBilinearForm &mVarf, const real_t alpha=0.5)
Assemble a preconditioner for the mass matrix.
void SetEssZeroDofs(const Array< int > &dofs)
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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:46
Parameters for the BramblePasciakSolver method.