GEOSX
BlockPreconditioner.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
20 #define GEOSX_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
21 
23 #include "linearAlgebra/solvers/PreconditionerBase.hpp"
26 
27 namespace geosx
28 {
29 
36 {
37  None,
41 };
42 
47 {
48  None,
51 };
52 
56 enum class BlockShapeOption
57 {
58  Diagonal,
61 };
62 
63 /*
64  * Since formulas in Doxygen are broken with 1.8.13 and certain versions of ghostscript,
65  * keeping this documentation in a separate comment block for now. Should be moved into
66  * documentation of BlockPreconditioner class.
67  *
68  * This class implements a 2x2 block preconditioner of the form:
69  * @f$
70  * M^{-1} =
71  * \begin{bmatrix}
72  * I_{1} & -M_{1}^{-1}A_{12} \\
73  * & I_{2}
74  * \end{bmatrix}
75  * \begin{bmatrix}
76  * M_{1}^{-1} & \\
77  * & M_{2}^{-1}
78  * \end{bmatrix}
79  * \begin{bmatrix}
80  * I_{1} & \\
81  * -A_{21}M_{1}^{-1} & I_{2}
82  * \end{bmatrix}
83  * @f$
84  * with
85  * @f$ M_1^{-1} ~= A_{11}^{-1} @f$, @f$ M_2^{-1} ~= S_{22}^{-1} @f$, and
86  * @f$ S_{22} ~= A_{22} - A_{21} A_{11}^{-1} A_{12} @f$ being the (optional) approximate Schur complement.
87  *
88  * The first step (predictor solve with @f$ M_{1} @f$) is optional. Enabling it results in a more powerful
89  * preconditioner, but involves two applications of @f$ M_{1}^{-1} @f$ instead of just one on each solve.
90  *
91  * The user provides individual block solvers @f$ M_{1} @f$ and @f$ M_{2} @f$ as well as
92  * a description of the block split of monolithic matrix in terms of DOF components.
93  */
94 
99 template< typename LAI >
101 {
102 public:
103 
106 
108  using Vector = typename Base::Vector;
109 
111  using Matrix = typename Base::Matrix;
112 
119  explicit BlockPreconditioner( BlockShapeOption const shapeOption,
120  SchurComplementOption const schurOption,
121  BlockScalingOption const scalingOption );
122 
126  virtual ~BlockPreconditioner() override;
127 
139  void setupBlock( localIndex const blockIndex,
140  std::vector< DofManager::SubComponent > blockDofs,
141  std::unique_ptr< PreconditionerBase< LAI > > solver,
142  real64 const scaling = 1.0 );
143 
147 
150 
156  virtual void compute( Matrix const & mat,
157  DofManager const & dofManager ) override;
158 
166  virtual void apply( Vector const & src, Vector & dst ) const override;
167 
168  virtual void clear() override;
169 
171 
172 private:
173 
179  void reinitialize( Matrix const & mat, DofManager const & dofManager );
180 
184  void applyBlockScaling();
185 
189  void computeSchurComplement();
190 
192  BlockShapeOption m_shapeOption;
193 
195  SchurComplementOption m_schurOption;
196 
198  BlockScalingOption m_scalingOption;
199 
201  std::array< std::vector< DofManager::SubComponent >, 2 > m_blockDofs;
202 
204  std::array< Matrix, 2 > m_restrictors;
205 
207  std::array< Matrix, 2 > m_prolongators;
208 
211 
213  std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solvers;
214 
216  std::array< real64, 2 > m_scaling;
217 
219  mutable BlockVector< Vector > m_rhs;
220 
222  mutable BlockVector< Vector > m_sol;
223 };
224 
225 } //namespace geosx
226 
227 #endif //GEOSX_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
BlockScalingOption
Type of block row scaling to apply.
Rowsum-preserving diagonal approximation constructed with probing.
Common interface for preconditioning operators.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns, and generally simplifying the interaction between PhysicsSolvers and linear algebra operations.
Definition: DofManager.hpp:42
SchurComplementOption
Type of Schur complement approximation used.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
User defined preconditioner for the first block.
typename Base::Vector Vector
Alias for the vector type.
typename Base::Matrix Matrix
Alias for the matrix type.
Approximate first block with its diagonal.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
BlockShapeOption
Shape of the block preconditioner.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
General 2x2 block preconditioner.
Equilibrate Frobenius norm of the diagonal blocks.
typename Base::Vector Vector
Alias for vector type.
No Schur complement - just block-GS/block-Jacobi preconditioner.