GEOS
BlockPreconditioner.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
21 #define GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
22 
24 #include "linearAlgebra/common/PreconditionerBase.hpp"
27 
28 namespace geos
29 {
30 
37 {
38  None,
42 };
43 
48 {
49  None,
52 };
53 
57 enum class BlockShapeOption
58 {
59  Diagonal,
62 };
63 
64 /*
65  * Since formulas in Doxygen are broken with 1.8.13 and certain versions of ghostscript,
66  * keeping this documentation in a separate comment block for now. Should be moved into
67  * documentation of BlockPreconditioner class.
68  *
69  * This class implements a 2x2 block preconditioner of the form:
70  * @f$
71  * M^{-1} =
72  * \begin{bmatrix}
73  * I_{1} & -M_{1}^{-1}A_{12} \\
74  * & I_{2}
75  * \end{bmatrix}
76  * \begin{bmatrix}
77  * M_{1}^{-1} & \\
78  * & M_{2}^{-1}
79  * \end{bmatrix}
80  * \begin{bmatrix}
81  * I_{1} & \\
82  * -A_{21}M_{1}^{-1} & I_{2}
83  * \end{bmatrix}
84  * @f$
85  * with
86  * @f$ M_1^{-1} ~= A_{11}^{-1} @f$, @f$ M_2^{-1} ~= S_{22}^{-1} @f$, and
87  * @f$ S_{22} ~= A_{22} - A_{21} A_{11}^{-1} A_{12} @f$ being the (optional) approximate Schur complement.
88  *
89  * The first step (predictor solve with @f$ M_{1} @f$) is optional. Enabling it results in a more powerful
90  * preconditioner, but involves two applications of @f$ M_{1}^{-1} @f$ instead of just one on each solve.
91  *
92  * The user provides individual block solvers @f$ M_{1} @f$ and @f$ M_{2} @f$ as well as
93  * a description of the block split of monolithic matrix in terms of DOF components.
94  */
95 
100 template< typename LAI >
102 {
103 public:
104 
107 
109  using Vector = typename Base::Vector;
110 
112  using Matrix = typename Base::Matrix;
113 
120  explicit BlockPreconditioner( BlockShapeOption const shapeOption,
121  SchurComplementOption const schurOption,
122  BlockScalingOption const scalingOption );
123 
127  virtual ~BlockPreconditioner() override;
128 
140  void setupBlock( localIndex const blockIndex,
141  std::vector< DofManager::SubComponent > blockDofs,
142  std::unique_ptr< PreconditionerBase< LAI > > solver,
143  real64 const scaling = 1.0 );
144 
149 
151 
156  virtual void setup( Matrix const & mat ) override;
157 
165  virtual void apply( Vector const & src, Vector & dst ) const override;
166 
167  virtual void clear() override;
168 
170 
171 private:
172 
178  void reinitialize( Matrix const & mat, DofManager const & dofManager );
179 
183  void applyBlockScaling();
184 
188  void computeSchurComplement();
189 
191  BlockShapeOption m_shapeOption;
192 
194  SchurComplementOption m_schurOption;
195 
197  BlockScalingOption m_scalingOption;
198 
200  std::array< std::vector< DofManager::SubComponent >, 2 > m_blockDofs;
201 
203  std::array< Matrix, 2 > m_restrictors;
204 
206  std::array< Matrix, 2 > m_prolongators;
207 
210 
212  std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solvers;
213 
215  std::array< real64, 2 > m_scaling;
216 
218  mutable BlockVector< Vector > m_rhs;
219 
221  mutable BlockVector< Vector > m_sol;
222 };
223 
224 } //namespace geos
225 
226 #endif //GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
General 2x2 block preconditioner.
void setupBlock(localIndex const blockIndex, std::vector< DofManager::SubComponent > blockDofs, std::unique_ptr< PreconditionerBase< LAI > > solver, real64 const scaling=1.0)
Setup data for one of the two blocks.
BlockPreconditioner(BlockShapeOption const shapeOption, SchurComplementOption const schurOption, BlockScalingOption const scalingOption)
Constructor.
virtual void clear() override
Clean up the preconditioner setup.
typename Base::Vector Vector
Alias for the vector type.
typename Base::Matrix Matrix
Alias for the matrix type.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
virtual void setup(Matrix const &mat) override
Compute the preconditioner from a matrix.
virtual ~BlockPreconditioner() override
Destructor.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:44
Abstract base class for linear operators.
Common interface for preconditioning operators.
typename Base::Vector Vector
Alias for vector type.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
BlockScalingOption
Type of block row scaling to apply.
@ UserProvided
User-provided scaling.
@ FrobeniusNorm
Equilibrate Frobenius norm of the diagonal blocks.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
SchurComplementOption
Type of Schur complement approximation used.
@ FirstBlockDiagonal
Approximate first block with its diagonal.
@ None
No Schur complement - just block-GS/block-Jacobi preconditioner.
@ FirstBlockUserDefined
User defined preconditioner for the first block.
@ RowsumDiagonalProbing
Rowsum-preserving diagonal approximation constructed with probing.
BlockShapeOption
Shape of the block preconditioner.
@ LowerUpperTriangular
(LDU)^{-1}
@ UpperTriangular
(DU)^{-1}