My Project
Loading...
Searching...
No Matches
Preconditioner.hpp
1
/*
2
Copyright 2024 Equinor ASA
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
20
#ifndef OPM_PRECONDITIONER_HEADER_INCLUDED
21
#define OPM_PRECONDITIONER_HEADER_INCLUDED
22
23
#if HAVE_OPENCL
24
#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
25
#endif
26
27
#include <memory>
28
29
namespace
Opm::Accelerator {
30
31
enum
PreconditionerType {
32
BILU0,
33
CPR,
34
BISAI
35
};
36
37
template
<
class
Scalar>
class
BlockedMatrix;
38
39
template
<
class
Scalar,
unsigned
int
block_size>
40
class
Preconditioner
41
{
42
protected
:
43
int
N = 0;
// number of rows of the matrix
44
int
Nb = 0;
// number of blockrows of the matrix
45
int
nnz = 0;
// number of nonzeroes of the matrix (scalar)
46
int
nnzb = 0;
// number of blocks of the matrix
47
int
verbosity = 0;
48
49
Preconditioner
(
int
verbosity_) :
50
verbosity(verbosity_)
51
{};
52
53
public
:
54
55
virtual
~Preconditioner
() =
default
;
56
57
static
std::unique_ptr<Preconditioner> create(PreconditionerType type,
58
bool
opencl_ilu_parallel,
59
int
verbosity);
60
61
#if HAVE_OPENCL
62
// apply preconditioner, x = prec(y)
63
virtual
void
apply(
const
cl::Buffer& y, cl::Buffer& x) = 0;
64
#endif
65
66
// apply preconditioner, x = prec(y)
67
virtual
void
apply(Scalar& y, Scalar& x) = 0;
68
69
// analyze matrix, e.g. the sparsity pattern
70
// probably only called once
71
// the version with two params can be overloaded, if not, it will default to using the one param version
72
virtual
bool
analyze_matrix(
BlockedMatrix<Scalar>
* mat) = 0;
73
virtual
bool
analyze_matrix(
BlockedMatrix<Scalar>
* mat,
74
BlockedMatrix<Scalar>
* jacMat) = 0;
75
76
// create/update preconditioner, probably used every linear solve
77
// the version with two params can be overloaded, if not, it will default to using the one param version
78
virtual
bool
create_preconditioner(
BlockedMatrix<Scalar>
* mat) = 0;
79
virtual
bool
create_preconditioner(
BlockedMatrix<Scalar>
* mat,
80
BlockedMatrix<Scalar>
* jacMat) = 0;
81
};
82
83
}
// namespace Opm::Accelerator
84
85
#endif
Opm::Accelerator::BlockedMatrix
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition
rocsparsePreconditioner.hpp:29
Opm::Accelerator::Preconditioner
Definition
Preconditioner.hpp:41
opm
simulators
linalg
bda
Preconditioner.hpp
Generated by
1.12.0