opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
GpuJac.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_GPUJAC_HPP
20
#define OPM_GPUJAC_HPP
21
22
#include <dune/istl/preconditioner.hh>
23
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
24
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixWrapper.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
31
namespace
Opm::gpuistl
32
{
45
template
<
class
M,
class
X,
class
Y,
int
l = 1>
46
class
GpuJac
:
public
Dune::PreconditionerWithUpdate
<X, Y>
47
{
48
public
:
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
GpuJac
(
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
virtual
bool
hasPerfectUpdate()
const override
{
97
return
true
;
98
}
99
100
101
private
:
103
const
M& m_matrix;
105
const
field_type
m_relaxationFactor;
107
GpuVector<field_type> m_diagInvFlattened;
108
109
void
invertDiagonalAndFlatten();
110
111
template
<
int
blocksize>
112
void
dispatchInvertDiagonalAndFlatten();
113
};
114
}
// end namespace Opm::gpuistl
115
116
#endif
Dune::PreconditionerWithUpdate
Interface class adding the update() method to the preconditioner interface.
Definition
PreconditionerWithUpdate.hpp:32
Opm::gpuistl::GpuJac::field_type
typename X::field_type field_type
The field type of the preconditioner.
Definition
GpuJac.hpp:56
Opm::gpuistl::GpuJac::range_type
Y range_type
The range type of the preconditioner.
Definition
GpuJac.hpp:54
Opm::gpuistl::GpuJac::update
virtual void update() override
Updates the matrix data.
Definition
GpuJac.cpp:78
Opm::gpuistl::GpuJac::pre
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition
GpuJac.cpp:46
Opm::gpuistl::GpuJac::shouldCallPre
static constexpr bool shouldCallPre()
Definition
GpuJac.hpp:85
Opm::gpuistl::GpuJac::GpuJac
GpuJac(const M &A, field_type w)
Constructor.
Definition
GpuJac.cpp:34
Opm::gpuistl::GpuJac::post
virtual void post(X &x) override
Post processing.
Definition
GpuJac.cpp:65
Opm::gpuistl::GpuJac::apply
virtual void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition
GpuJac.cpp:52
Opm::gpuistl::GpuJac::category
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category).
Definition
GpuJac.cpp:71
Opm::gpuistl::GpuJac::shouldCallPost
static constexpr bool shouldCallPost()
Definition
GpuJac.hpp:91
Opm::gpuistl::GpuJac::domain_type
X domain_type
The domain type of the preconditioner.
Definition
GpuJac.hpp:52
Opm::gpuistl::GpuJac::matrix_type
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition
GpuJac.hpp:50
opm
simulators
linalg
gpuistl
GpuJac.hpp
Generated by
1.17.0