BdaSolver.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 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_BDASOLVER_BACKEND_HEADER_INCLUDED
21#define OPM_BDASOLVER_BACKEND_HEADER_INCLUDED
22
23
26
27#include <memory>
28
29namespace Opm {
30
31template<class Scalar> class WellContributions;
32
33namespace Accelerator {
34
35enum class SolverStatus {
40};
41
44template<class Scalar, unsigned int block_size>
46{
47protected:
48 // verbosity
49 // 0: print nothing during solves, only when initializing
50 // 1: print number of iterations and final norm
51 // 2: also print norm each iteration
52 // 3: also print timings of different backend functions
53 int verbosity = 0;
54
55 int maxit = 200;
56 Scalar tolerance = 1e-2;
57
58 int N; // number of rows
59 int Nb; // number of blocked rows (Nb*block_size == N)
60 int nnz; // number of nonzeroes (scalars)
61 int nnzb; // number of nonzero blocks (nnzb*block_size*block_size == nnz)
62
63 unsigned int platformID = 0; // ID of OpenCL platform to be used, only used by openclSolver now
64 unsigned int deviceID = 0; // ID of the device to be used
65
66 bool initialized = false;
67
68public:
75 BdaSolver(int linear_solver_verbosity, int max_it, Scalar tolerance_)
76 : verbosity(linear_solver_verbosity)
77 , maxit(max_it)
78 , tolerance(tolerance_)
79 {}
80 BdaSolver(int linear_solver_verbosity, int max_it,
81 Scalar tolerance_, unsigned int deviceID_)
82 : verbosity(linear_solver_verbosity)
83 , maxit(max_it)
84 , tolerance(tolerance_)
85 , deviceID(deviceID_) {};
86 BdaSolver(int linear_solver_verbosity, int max_it,
87 double tolerance_, unsigned int platformID_,
88 unsigned int deviceID_)
89 : verbosity(linear_solver_verbosity)
90 , maxit(max_it)
91 , tolerance(tolerance_)
92 , platformID(platformID_)
93 , deviceID(deviceID_)
94 {}
95
97 virtual ~BdaSolver() = default;
98
100 virtual SolverStatus solve_system(std::shared_ptr<BlockedMatrix<Scalar>> matrix,
101 Scalar* b,
102 std::shared_ptr<BlockedMatrix<Scalar>> jacMatrix,
103 WellContributions<Scalar>& wellContribs,
104 BdaResult& res) = 0;
105
106 virtual void get_result(Scalar* x) = 0;
107}; // end class BdaSolver
108
109} // namespace Accelerator
110} // namespace Opm
111
112#endif
Definition: BdaResult.hpp:31
Definition: BdaSolver.hpp:46
int maxit
Definition: BdaSolver.hpp:55
virtual SolverStatus solve_system(std::shared_ptr< BlockedMatrix< Scalar > > matrix, Scalar *b, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, WellContributions< Scalar > &wellContribs, BdaResult &res)=0
Define as pure virtual functions, so derivedclass must implement them.
int nnzb
Definition: BdaSolver.hpp:61
bool initialized
Definition: BdaSolver.hpp:66
BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_, unsigned int platformID_, unsigned int deviceID_)
Definition: BdaSolver.hpp:86
int verbosity
Definition: BdaSolver.hpp:53
unsigned int deviceID
Definition: BdaSolver.hpp:64
BdaSolver(int linear_solver_verbosity, int max_it, Scalar tolerance_, unsigned int deviceID_)
Definition: BdaSolver.hpp:80
int N
Definition: BdaSolver.hpp:58
int Nb
Definition: BdaSolver.hpp:59
virtual ~BdaSolver()=default
Define virtual destructor, so that the derivedclass destructor will be called.
int nnz
Definition: BdaSolver.hpp:60
virtual void get_result(Scalar *x)=0
BdaSolver(int linear_solver_verbosity, int max_it, Scalar tolerance_)
Definition: BdaSolver.hpp:75
Scalar tolerance
Definition: BdaSolver.hpp:56
unsigned int platformID
Definition: BdaSolver.hpp:63
Definition: BlockedMatrix.hpp:29
Definition: WellContributions.hpp:53
SolverStatus
Definition: BdaSolver.hpp:35
Definition: blackoilboundaryratevector.hh:37