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 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_PETSCPRECONDITIONER_HPP
20 #define GEOSX_PETSCPRECONDITIONER_HPP
21 
22 #include "linearAlgebra/solvers/PreconditionerBase.hpp"
25 
32 
35 extern "C" struct _p_PC;
36 extern "C" struct _p_MatNullSpace;
37 
39 using PC = _p_PC *;
41 using MatNullSpace = _p_MatNullSpace *;
42 
44 
45 namespace geosx
46 {
47 
51 class PetscPreconditioner final : public PreconditionerBase< PetscInterface >
52 {
53 public:
54 
57 
59  using Vector = typename Base::Vector;
60 
62  using Matrix = typename Base::Matrix;
63 
65  using Base::compute;
66 
72 
78  PetscPreconditioner( LinearSolverParameters params, array1d< Vector > const & nearNullKernel );
79 
83  virtual ~PetscPreconditioner() override;
84 
89  virtual void compute( Matrix const & mat ) override;
90 
98  virtual void apply( Vector const & src, Vector & dst ) const override;
99 
100  virtual void clear() override;
101 
106  PC const & unwrapped() const;
107 
108 private:
109 
111  LinearSolverParameters m_parameters;
112 
114  PC m_precond;
115 
117  MatNullSpace m_nullsp;
118 };
119 
120 }
121 
122 #endif //GEOSX_PETSCPRECONDITIONER_HPP
PC const & unwrapped() const
Access the underlying implementation.
typename Base::Matrix Matrix
Alias for matrix type.
Common interface for preconditioning operators.
virtual void compute(Matrix const &mat)
Compute the preconditioner from a matrix.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
Set of parameters for a linear solver or preconditioner.
virtual ~PetscPreconditioner() override
Destructor.
PetscPreconditioner(LinearSolverParameters params)
Constructor.
_p_MatNullSpace * MatNullSpace
Near null space pointer alias.
typename PetscInterface ::ParallelMatrix Matrix
Alias for matrix type.
virtual void compute(Matrix const &mat) override
Compute the preconditioner from a matrix.
typename Base::Vector Vector
Alias for vector type.
_p_PC * PC
Preconditioner pointer alias.
virtual void clear() override
Clean up the preconditioner setup.
Wrapper around PETSc-based preconditioners.
typename Base::Vector Vector
Alias for vector type.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55