CuSeqILU0.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022-2023 SINTEF AS
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef OPM_CUSEQILU0_HPP
20#define OPM_CUSEQILU0_HPP
21
22#include <dune/istl/preconditioner.hh>
28
29
30
31namespace Opm::cuistl
32{
48template <class M, class X, class Y, int l = 1>
50{
51public:
53 using matrix_type = typename std::remove_const<M>::type ;
55 using domain_type = X;
57 using range_type = Y;
59 using field_type = typename X::field_type;
60
67 CuSeqILU0(const M& A, field_type w);
68
71 virtual void pre(X& x, Y& b) override;
72
74 virtual void apply(X& v, const Y& d) override;
75
78 virtual void post(X& x) override;
79
81 virtual Dune::SolverCategory::Category category() const override;
82
84 virtual void update() override;
85
86
88 static constexpr bool shouldCallPre()
89 {
90 return false;
91 }
92
94 static constexpr bool shouldCallPost()
95 {
96 return false;
97 }
98
99
100private:
102 const M& m_underlyingMatrix;
104 field_type m_w;
105
110
111 CuVector<field_type> m_temporaryStorage;
112
113
119
120 std::unique_ptr<CuVector<field_type>> m_buffer;
121 detail::CuSparseHandle& m_cuSparseHandle;
122
123 bool m_analysisDone = false;
124
125 void analyzeMatrix();
126 size_t findBufferSize();
127
128 void createILU();
129
130 void updateILUConfiguration();
131};
132} // end namespace Opm::cuistl
133
134#endif
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:32
Sequential ILU0 preconditioner on the GPU through the CuSparse library.
Definition: CuSeqILU0.hpp:50
virtual void update() override
Updates the matrix data.
CuSeqILU0(const M &A, field_type w)
Constructor.
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
typename X::field_type field_type
The field type of the preconditioner.
Definition: CuSeqILU0.hpp:59
static constexpr bool shouldCallPre()
Definition: CuSeqILU0.hpp:88
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: CuSeqILU0.hpp:53
virtual void post(X &x) override
Post processing.
static constexpr bool shouldCallPost()
Definition: CuSeqILU0.hpp:94
virtual void apply(X &v, const Y &d) override
Apply the preconditoner.
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Y range_type
The range type of the preconditioner.
Definition: CuSeqILU0.hpp:57
X domain_type
The domain type of the preconditioner.
Definition: CuSeqILU0.hpp:55
The CuSparseHandle class provides a singleton for the simulator universal cuSparseHandle.
Definition: CuSparseHandle.hpp:41
std::shared_ptr< CuSparseResource< cusparseMatDescr_t > > CuSparseMatrixDescriptionPtr
Definition: CuMatrixDescription.hpp:35
Definition: CuBlockPreconditioner.hpp:29