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 TotalEnergies
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 GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
20 #define GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
21 
23 #include "linearAlgebra/common/PreconditionerBase.hpp"
26 
27 namespace geos
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 
148 
150 
155  virtual void setup( Matrix const & mat ) override;
156 
164  virtual void apply( Vector const & src, Vector & dst ) const override;
165 
166  virtual void clear() override;
167 
169 
170 private:
171 
177  void reinitialize( Matrix const & mat, DofManager const & dofManager );
178 
182  void applyBlockScaling();
183 
187  void computeSchurComplement();
188 
190  BlockShapeOption m_shapeOption;
191 
193  SchurComplementOption m_schurOption;
194 
196  BlockScalingOption m_scalingOption;
197 
199  std::array< std::vector< DofManager::SubComponent >, 2 > m_blockDofs;
200 
202  std::array< Matrix, 2 > m_restrictors;
203 
205  std::array< Matrix, 2 > m_prolongators;
206 
209 
211  std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solvers;
212 
214  std::array< real64, 2 > m_scaling;
215 
217  mutable BlockVector< Vector > m_rhs;
218 
220  mutable BlockVector< Vector > m_sol;
221 };
222 
223 } //namespace geos
224 
225 #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:43
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:139
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}
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125