CuJac.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_CUJAC_HPP
20#define OPM_CUJAC_HPP
21
22#include <dune/istl/preconditioner.hh>
28
29
30
31namespace Opm::cuistl
32{
45template <class M, class X, class Y, int l = 1>
47{
48public:
50 using matrix_type = typename std::remove_const<M>::type;
52 using domain_type = X;
54 using range_type = Y;
56 using field_type = typename X::field_type;
57
64 CuJac(const M& A, field_type w);
65
68 virtual void pre(X& x, Y& b) override;
69
71 virtual void apply(X& v, const Y& d) override;
72
75 virtual void post(X& x) override;
76
78 virtual Dune::SolverCategory::Category category() const override;
79
81 virtual void update() override;
82
83
85 static constexpr bool shouldCallPre()
86 {
87 return false;
88 }
89
91 static constexpr bool shouldCallPost()
92 {
93 return false;
94 }
95
96
97private:
99 const M& m_cpuMatrix;
101 const field_type m_relaxationFactor;
103 CuSparseMatrix<field_type> m_gpuMatrix;
105 CuVector<field_type> m_diagInvFlattened;
106};
107} // end namespace Opm::cuistl
108
109#endif
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:32
Jacobi preconditioner on the GPU.
Definition: CuJac.hpp:47
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
static constexpr bool shouldCallPost()
Definition: CuJac.hpp:91
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Y range_type
The range type of the preconditioner.
Definition: CuJac.hpp:54
virtual void apply(X &v, const Y &d) override
Apply the preconditoner.
virtual void update() override
Updates the matrix data.
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: CuJac.hpp:50
typename X::field_type field_type
The field type of the preconditioner.
Definition: CuJac.hpp:56
virtual void post(X &x) override
Post processing.
static constexpr bool shouldCallPre()
Definition: CuJac.hpp:85
X domain_type
The domain type of the preconditioner.
Definition: CuJac.hpp:52
CuJac(const M &A, field_type w)
Constructor.
Definition: CuBlockPreconditioner.hpp:29