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"
28 
29 namespace geos
30 {
31 
32 /*
33  * Since formulas in Doxygen are broken with 1.8.13 and certain versions of ghostscript,
34  * keeping this documentation in a separate comment block for now. Should be moved into
35  * documentation of BlockPreconditioner class.
36  *
37  * This class implements a 2x2 block preconditioner of the form:
38  * @f$
39  * M^{-1} =
40  * \begin{bmatrix}
41  * I_{1} & -M_{1}^{-1}A_{12} \\
42  * & I_{2}
43  * \end{bmatrix}
44  * \begin{bmatrix}
45  * M_{1}^{-1} & \\
46  * & M_{2}^{-1}
47  * \end{bmatrix}
48  * \begin{bmatrix}
49  * I_{1} & \\
50  * -A_{21}M_{1}^{-1} & I_{2}
51  * \end{bmatrix}
52  * @f$
53  * with
54  * @f$ M_1^{-1} ~= A_{11}^{-1} @f$, @f$ M_2^{-1} ~= S_{22}^{-1} @f$, and
55  * @f$ S_{22} ~= A_{22} - A_{21} A_{11}^{-1} A_{12} @f$ being the (optional) approximate Schur complement.
56  *
57  * The first step (predictor solve with @f$ M_{1} @f$) is optional. Enabling it results in a more powerful
58  * preconditioner, but involves two applications of @f$ M_{1}^{-1} @f$ instead of just one on each solve.
59  *
60  * The user provides individual block solvers @f$ M_{1} @f$ and @f$ M_{2} @f$ as well as
61  * a description of the block split of monolithic matrix in terms of DOF components.
62  */
63 
68 template< typename LAI >
70 {
71 public:
72 
75 
77  using Vector = typename Base::Vector;
78 
80  using Matrix = typename Base::Matrix;
81 
87 
99  void setupBlock( localIndex const blockIndex,
101  std::unique_ptr< PreconditionerBase< LAI > > solver,
102  real64 const scaling = 1.0 );
103 
117  void setupBlock( localIndex const blockIndex,
118  std::vector< DofManager::SubComponent > blockDofs,
119  PreconditionerBase< LAI > * const solver,
120  real64 const scaling = 1.0 );
121 
127  void setProlongation( localIndex const blockIndex,
128  Matrix const & P );
129 
134 
139  virtual void setup( Matrix const & mat ) override;
140 
148  virtual void apply( Vector const & src, Vector & dst ) const override;
149 
150  virtual void clear() override;
151 
153 
158  {
159  return m_matBlocks;
160  }
161 
162 private:
163 
168  void reinitialize( Matrix const & mat );
169 
173  void applyBlockScaling();
174 
178  void computeSchurComplement();
179 
182 
184  std::array< stdVector< DofManager::SubComponent >, 2 > m_blockDofs{};
185 
187  std::array< Matrix const *, 2 > m_prolongators{};
188 
190  std::array< Matrix, 2 > m_prolongatorsOwned{};
191 
194 
196  std::array< PreconditionerBase< LAI > *, 2 > m_solvers{};
197 
199  std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solversOwned{};
200 
202  std::array< real64, 2 > m_scaling{};
203 
205  mutable BlockVector< Vector > m_rhs;
206 
208  mutable BlockVector< Vector > m_sol;
209 };
210 
211 } //namespace geos
212 
213 #endif //GEOS_LINEARALGEBRA_SOLVERS_BLOCKPRECONDITIONER_HPP_
General 2x2 block preconditioner.
void setupBlock(localIndex const blockIndex, std::vector< DofManager::SubComponent > blockDofs, PreconditionerBase< LAI > *const solver, real64 const scaling=1.0)
Setup data for one of the two blocks.
void setProlongation(localIndex const blockIndex, Matrix const &P)
Set user-provided prolongation operator for a block.
BlockPreconditioner(LinearSolverParameters::Block params)
Constructor.
void setupBlock(localIndex const blockIndex, stdVector< DofManager::SubComponent > blockDofs, std::unique_ptr< PreconditionerBase< LAI > > solver, real64 const scaling=1.0)
Setup data for one of the two blocks.
virtual void clear() override
Clean up the preconditioner setup.
typename Base::Vector Vector
Alias for the vector type.
BlockOperator< Vector, Matrix > const & blocks() const
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.
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.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
internal::StdVectorWrapper< T, Allocator, USE_STD_CONTAINER_BOUNDS_CHECKING > stdVector
Block preconditioner parameters.