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#include <string>
29
30namespace Opm {
31
32class WellContributions;
33
34namespace Accelerator {
35 enum class SolverStatus {
40 };
41
44 template <unsigned int block_size>
46 {
47
48 protected:
49
50 // verbosity
51 // 0: print nothing during solves, only when initializing
52 // 1: print number of iterations and final norm
53 // 2: also print norm each iteration
54 // 3: also print timings of different backend functions
55
56 int verbosity = 0;
57
58 int maxit = 200;
59 double tolerance = 1e-2;
60
61 int N; // number of rows
62 int Nb; // number of blocked rows (Nb*block_size == N)
63 int nnz; // number of nonzeroes (scalars)
64 int nnzb; // number of nonzero blocks (nnzb*block_size*block_size == nnz)
65
66 unsigned int platformID = 0; // ID of OpenCL platform to be used, only used by openclSolver now
67 unsigned int deviceID = 0; // ID of the device to be used
68
69 bool initialized = false;
70
71 public:
78 BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_) : verbosity(linear_solver_verbosity), maxit(max_it), tolerance(tolerance_) {};
79 BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_, unsigned int deviceID_) : verbosity(linear_solver_verbosity), maxit(max_it), tolerance(tolerance_), deviceID(deviceID_) {};
80 BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_, unsigned int platformID_, unsigned int deviceID_) : verbosity(linear_solver_verbosity), maxit(max_it), tolerance(tolerance_), platformID(platformID_), deviceID(deviceID_) {};
81
83 virtual ~BdaSolver() {};
84
86 virtual SolverStatus solve_system(std::shared_ptr<BlockedMatrix> matrix, double *b,
87 std::shared_ptr<BlockedMatrix> jacMatrix, WellContributions& wellContribs, BdaResult &res) = 0;
88
89 virtual void get_result(double *x) = 0;
90
91 }; // end class BdaSolver
92
93} // namespace Accelerator
94} // namespace Opm
95
96#endif
Definition: BdaResult.hpp:31
Definition: BdaSolver.hpp:46
virtual SolverStatus solve_system(std::shared_ptr< BlockedMatrix > matrix, double *b, std::shared_ptr< BlockedMatrix > jacMatrix, WellContributions &wellContribs, BdaResult &res)=0
Define as pure virtual functions, so derivedclass must implement them.
int nnz
Definition: BdaSolver.hpp:63
int verbosity
Definition: BdaSolver.hpp:56
int maxit
Definition: BdaSolver.hpp:58
double tolerance
Definition: BdaSolver.hpp:59
virtual void get_result(double *x)=0
int N
Definition: BdaSolver.hpp:61
int Nb
Definition: BdaSolver.hpp:62
int nnzb
Definition: BdaSolver.hpp:64
virtual ~BdaSolver()
Define virtual destructor, so that the derivedclass destructor will be called.
Definition: BdaSolver.hpp:83
BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_, unsigned int deviceID_)
Definition: BdaSolver.hpp:79
BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_)
Definition: BdaSolver.hpp:78
bool initialized
Definition: BdaSolver.hpp:69
unsigned int deviceID
Definition: BdaSolver.hpp:67
unsigned int platformID
Definition: BdaSolver.hpp:66
BdaSolver(int linear_solver_verbosity, int max_it, double tolerance_, unsigned int platformID_, unsigned int deviceID_)
Definition: BdaSolver.hpp:80
Definition: WellContributions.hpp:52
SolverStatus
Definition: BdaSolver.hpp:35
Definition: BlackoilPhases.hpp:27