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::Accelerator {
35
38template<class Scalar, unsigned int block_size>
39class rocalutionSolverBackend : public BdaSolver<Scalar,block_size>
40{
42
43 using Base::N;
44 using Base::Nb;
45 using Base::nnz;
46 using Base::nnzb;
47 using Base::verbosity;
48 using Base::platformID;
49 using Base::deviceID;
50 using Base::maxit;
51 using Base::tolerance;
53
54private:
55 std::vector<Scalar> h_x; // store solution vector on host
56 int *tmp_rowpointers; // store matrix on host, this pointer is given to and freed by rocalution
57 int *tmp_colindices; // store matrix on host, this pointer is given to and freed by rocalution
58 Scalar* tmp_nnzvalues; // store matrix on host, this pointer is given to and freed by rocalution
59
62
63 std::unique_ptr<rocalution::ILU<Mat,Vec,Scalar>> roc_prec;
64 std::unique_ptr<rocalution::BiCGStab<Mat,Vec,Scalar>> roc_solver;
65
68 void initialize(BlockedMatrix<Scalar>* matrix);
69
73 void convert_matrix(BlockedMatrix<Scalar>* matrix);
74
75public:
81 rocalutionSolverBackend(int linear_solver_verbosity,
82 int maxit, Scalar tolerance);
83
86
95 Scalar* b,
96 std::shared_ptr<BlockedMatrix<Scalar>> jacMatrix,
97 WellContributions<Scalar>& wellContribs,
98 BdaResult& res) override;
99
102 void get_result(Scalar* x) override;
103
104}; // end class rocalutionSolverBackend
105
106} // namespace Opm::Accelerator
107
108#endif
109
110
Definition: BdaResult.hpp:31
Definition: BdaSolver.hpp:46
int maxit
Definition: BdaSolver.hpp:55
int nnzb
Definition: BdaSolver.hpp:61
bool initialized
Definition: BdaSolver.hpp:66
int verbosity
Definition: BdaSolver.hpp:53
unsigned int deviceID
Definition: BdaSolver.hpp:64
int N
Definition: BdaSolver.hpp:58
int Nb
Definition: BdaSolver.hpp:59
int nnz
Definition: BdaSolver.hpp:60
Scalar tolerance
Definition: BdaSolver.hpp:56
unsigned int platformID
Definition: BdaSolver.hpp:63
Definition: BlockedMatrix.hpp:29
Definition: rocalutionSolverBackend.hpp:40
rocalutionSolverBackend(int linear_solver_verbosity, int maxit, Scalar tolerance)
SolverStatus solve_system(std::shared_ptr< BlockedMatrix< Scalar > > matrix, Scalar *b, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, WellContributions< Scalar > &wellContribs, BdaResult &res) override
~rocalutionSolverBackend()
Destroy a rocalutionSolver, and free memory.
Definition: WellContributions.hpp:53
Definition: rocalutionSolverBackend.hpp:28
Definition: rocalutionSolverBackend.hpp:29
Definition: rocalutionSolverBackend.hpp:30
Definition: rocalutionSolverBackend.hpp:31
Definition: amgclSolverBackend.hpp:44
SolverStatus
Definition: BdaSolver.hpp:35
Definition: rocalutionSolverBackend.hpp:27