GEOSX
PetscPreconditioner.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_INTERFACES_PETSCPRECONDITIONER_HPP_
20 #define GEOS_LINEARALGEBRA_INTERFACES_PETSCPRECONDITIONER_HPP_
21 
22 #include "common/PreconditionerBase.hpp"
25 
33 
35 extern "C" struct _p_PC;
36 extern "C" struct _p_MatNullSpace;
37 
39 
40 namespace geos
41 {
42 
46 class PetscPreconditioner final : public PreconditionerBase< PetscInterface >
47 {
48 public:
49 
52 
54  using Vector = typename Base::Vector;
55 
57  using Matrix = typename Base::Matrix;
58 
64 
71 
75  virtual ~PetscPreconditioner() override;
76 
81  virtual void setup( Matrix const & mat ) override;
82 
90  virtual void apply( Vector const & src, Vector & dst ) const override;
91 
92  virtual void clear() override;
93 
94 private:
95 
97  using PC = _p_PC *;
98 
99 public:
100 
105  PC const & unwrapped() const;
106 
107 private:
108 
110  using MatNullSpace = _p_MatNullSpace *;
111 
117  PetscMatrix const & setupPreconditioningMatrix( PetscMatrix const & mat );
118 
120  LinearSolverParameters m_params;
121 
123  PC m_precond;
124 
126  PetscMatrix m_precondMatrix;
127 
129  MatNullSpace m_nullsp;
130 };
131 
132 }
133 
134 #endif //GEOS_LINEARALGEBRA_INTERFACES_PETSCPRECONDITIONER_HPP_
This class creates and provides basic support for the Mat matrix object type used in PETSc.
Definition: PetscMatrix.hpp:50
Wrapper around PETSc-based preconditioners.
virtual void clear() override
Clean up the preconditioner setup.
typename Base::Matrix Matrix
Alias for matrix type.
typename Base::Vector Vector
Alias for vector type.
PC const & unwrapped() const
Access the underlying implementation.
PetscPreconditioner(LinearSolverParameters params)
Constructor.
virtual void setup(Matrix const &mat) override
Compute the preconditioner from a matrix.
PetscPreconditioner(LinearSolverParameters params, array1d< Vector > const &nearNullKernel)
Constructor.
virtual ~PetscPreconditioner() override
Destructor.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
Common interface for preconditioning operators.
typename Base::Vector Vector
Alias for vector type.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
Set of parameters for a linear solver or preconditioner.