rocalutionSolverBackend.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022 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_ROCALUTIONSOLVER_BACKEND_HEADER_INCLUDED
21#define OPM_ROCALUTIONSOLVER_BACKEND_HEADER_INCLUDED
22
26
27namespace rocalution {
28template<class Matrix, class Vector, class Scalar> class BiCGStab;
29template<class Matrix, class Vector, class Scalar> class ILU;
30template<class Scalar> class LocalMatrix;
31template<class Scalar> class LocalVector;
32}
33
34namespace Opm
35{
36namespace Accelerator
37{
38
41template <unsigned int block_size>
42class rocalutionSolverBackend : public BdaSolver<block_size>
43{
45
46 using Base::N;
47 using Base::Nb;
48 using Base::nnz;
49 using Base::nnzb;
50 using Base::verbosity;
51 using Base::platformID;
52 using Base::deviceID;
53 using Base::maxit;
54 using Base::tolerance;
56
57private:
58 std::vector<double> h_x; // store solution vector on host
59 int *tmp_rowpointers; // store matrix on host, this pointer is given to and freed by rocalution
60 int *tmp_colindices; // store matrix on host, this pointer is given to and freed by rocalution
61 double *tmp_nnzvalues; // store matrix on host, this pointer is given to and freed by rocalution
62
63 std::unique_ptr<rocalution::ILU<rocalution::LocalMatrix<double>, rocalution::LocalVector<double>, double> > roc_prec;
64 std::unique_ptr<rocalution::BiCGStab<rocalution::LocalMatrix<double>, rocalution::LocalVector<double>, double> > roc_solver;
65
68 void initialize(BlockedMatrix *matrix);
69
73 void convert_matrix(BlockedMatrix *matrix);
74
75public:
76
82 rocalutionSolverBackend(int linear_solver_verbosity, int maxit, double tolerance);
83
86
94 SolverStatus solve_system(std::shared_ptr<BlockedMatrix> matrix, double *b,
95 std::shared_ptr<BlockedMatrix> jacMatrix, WellContributions& wellContribs, BdaResult &res) override;
96
99 void get_result(double *x) override;
100
101}; // end class rocalutionSolverBackend
102
103} // namespace Accelerator
104} // namespace Opm
105
106#endif
107
108
Definition: BdaResult.hpp:31
Definition: BdaSolver.hpp:46
int nnz
Definition: BdaSolver.hpp:63
int verbosity
Definition: BdaSolver.hpp:56
int maxit
Definition: BdaSolver.hpp:58
double tolerance
Definition: BdaSolver.hpp:59
int N
Definition: BdaSolver.hpp:61
int Nb
Definition: BdaSolver.hpp:62
int nnzb
Definition: BdaSolver.hpp:64
bool initialized
Definition: BdaSolver.hpp:69
unsigned int deviceID
Definition: BdaSolver.hpp:67
unsigned int platformID
Definition: BdaSolver.hpp:66
Definition: BlockedMatrix.hpp:31
Definition: rocalutionSolverBackend.hpp:43
~rocalutionSolverBackend()
Destroy a rocalutionSolver, and free memory.
rocalutionSolverBackend(int linear_solver_verbosity, int maxit, double tolerance)
SolverStatus solve_system(std::shared_ptr< BlockedMatrix > matrix, double *b, std::shared_ptr< BlockedMatrix > jacMatrix, WellContributions &wellContribs, BdaResult &res) override
Definition: WellContributions.hpp:52
Definition: rocalutionSolverBackend.hpp:28
Definition: rocalutionSolverBackend.hpp:29
Definition: rocalutionSolverBackend.hpp:30
Definition: rocalutionSolverBackend.hpp:31
SolverStatus
Definition: BdaSolver.hpp:35
Definition: BlackoilPhases.hpp:27
Definition: rocalutionSolverBackend.hpp:27