My Project
Loading...
Searching...
No Matches
GpuSeqILU0.hpp
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_GPUSEQILU0_HPP
20#define OPM_GPUSEQILU0_HPP
21
22#include <dune/istl/preconditioner.hh>
23#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
24#include <opm/simulators/linalg/gpuistl/GpuSparseMatrix.hpp>
25#include <opm/simulators/linalg/gpuistl/detail/CuMatrixDescription.hpp>
26#include <opm/simulators/linalg/gpuistl/detail/CuSparseHandle.hpp>
27#include <opm/simulators/linalg/gpuistl/detail/CuSparseResource.hpp>
28
29
30
31namespace Opm::gpuistl
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 GpuSeqILU0(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 virtual bool hasPerfectUpdate() const override {
100 return true;
101 }
102
103
104private:
106 const M& m_underlyingMatrix;
108 field_type m_w;
109
113 GpuSparseMatrix<field_type> m_LU;
114
115 GpuVector<field_type> m_temporaryStorage;
116
117
120 detail::CuSparseResource<bsrsv2Info_t> m_infoL;
121 detail::CuSparseResource<bsrsv2Info_t> m_infoU;
122 detail::CuSparseResource<bsrilu02Info_t> m_infoM;
123
124 std::unique_ptr<GpuVector<field_type>> m_buffer;
125 detail::CuSparseHandle& m_cuSparseHandle;
126
127 bool m_analysisDone = false;
128
129 void analyzeMatrix();
130 size_t findBufferSize();
131
132 void createILU();
133
134 void updateILUConfiguration();
135};
136} // end namespace Opm::gpuistl
137
138#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 GpuSeqILU0.hpp:50
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition GpuSeqILU0.hpp:53
virtual void update() override
Updates the matrix data.
Definition GpuSeqILU0.cpp:149
Y range_type
The range type of the preconditioner.
Definition GpuSeqILU0.hpp:57
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition GpuSeqILU0.cpp:73
typename X::field_type field_type
The field type of the preconditioner.
Definition GpuSeqILU0.hpp:59
virtual void post(X &x) override
Post processing.
Definition GpuSeqILU0.cpp:136
virtual void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition GpuSeqILU0.cpp:79
X domain_type
The domain type of the preconditioner.
Definition GpuSeqILU0.hpp:55
static constexpr bool shouldCallPost()
Definition GpuSeqILU0.hpp:94
static constexpr bool shouldCallPre()
Definition GpuSeqILU0.hpp:88
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition GpuSeqILU0.cpp:142
std::shared_ptr< CuSparseResource< cusparseMatDescr_t > > GpuSparseMatrixDescriptionPtr
Pointer to GpuSparseMatrixDescription holder.
Definition CuMatrixDescription.hpp:35
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242