CuDILU.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_CUDILU_HPP
20#define OPM_CUDILU_HPP
21
22#include <dune/istl/preconditioner.hh>
23#include <opm/grid/utility/SparseTable.hpp>
30#include <vector>
31
32
33
34namespace Opm::cuistl
35{
46template <class M, class X, class Y, int l = 1>
48{
49public:
51 using matrix_type = typename std::remove_const<M>::type;
53 using domain_type = X;
55 using range_type = Y;
57 using field_type = typename X::field_type;
58
65 explicit CuDILU(const M& A);
66
69 void pre(X& x, Y& b) override;
70
72 void apply(X& v, const Y& d) override;
73
76 void post(X& x) override;
77
79 Dune::SolverCategory::Category category() const override;
80
82 void update() final;
83
84
86 static constexpr bool shouldCallPre()
87 {
88 return false;
89 }
90
92 static constexpr bool shouldCallPost()
93 {
94 return false;
95 }
96
97
98private:
100 const M& m_cpuMatrix;
102 static constexpr const size_t blocksize_ = matrix_type::block_type::cols;
104 Opm::SparseTable<size_t> m_levelSets;
106 std::vector<int> m_reorderedToNatural;
108 std::vector<int> m_naturalToReordered;
110 CuSparseMatrix<field_type> m_gpuMatrix;
111 CuSparseMatrix<field_type> m_gpuMatrixReordered;
113 CuVector<int> m_gpuNaturalToReorder;
115 CuVector<int> m_gpuReorderToNatural;
117 CuVector<field_type> m_gpuDInv;
118};
119} // end namespace Opm::cuistl
120
121#endif
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:32
DILU preconditioner on the GPU.
Definition: CuDILU.hpp:48
void pre(X &x, Y &b) override
Prepare the preconditioner.
Y range_type
The range type of the preconditioner.
Definition: CuDILU.hpp:55
void update() final
Updates the matrix data.
typename X::field_type field_type
The field type of the preconditioner.
Definition: CuDILU.hpp:57
void apply(X &v, const Y &d) override
Apply the preconditoner.
void post(X &x) override
Post processing.
X domain_type
The domain type of the preconditioner.
Definition: CuDILU.hpp:53
static constexpr bool shouldCallPre()
Definition: CuDILU.hpp:86
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: CuDILU.hpp:51
Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
CuDILU(const M &A)
Constructor.
static constexpr bool shouldCallPost()
Definition: CuDILU.hpp:92
Definition: CuBlockPreconditioner.hpp:29