My Project
Loading...
Searching...
No Matches
openclPreconditioner.hpp
1/*
2 Copyright 2021 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_OPENCLPRECONDITIONER_HEADER_INCLUDED
21#define OPM_OPENCLPRECONDITIONER_HEADER_INCLUDED
22
23#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
24#include <opm/simulators/linalg/bda/Preconditioner.hpp>
25
26namespace Opm::Accelerator {
27
28template<class Scalar> class BlockedMatrix;
29
30template <class Scalar, unsigned int block_size>
31class openclPreconditioner : public Preconditioner<Scalar, block_size>
32{
33
34protected:
35 std::shared_ptr<cl::Context> context;
36 std::shared_ptr<cl::CommandQueue> queue;
37 std::vector<cl::Event> events;
38 cl_int err;
39
40 openclPreconditioner(int verbosity_) :
42 {};
43
44public:
45 virtual ~openclPreconditioner() = default;
46
47 static std::unique_ptr<openclPreconditioner<Scalar, block_size>> create(PreconditionerType type, int verbosity, bool opencl_ilu_parallel);
48
49 // nested Preconditioners might need to override this
50 virtual void setOpencl(std::shared_ptr<cl::Context>& context, std::shared_ptr<cl::CommandQueue>& queue);
51
52 // apply preconditioner, x = prec(y)
53 virtual void apply(const cl::Buffer& y, cl::Buffer& x) = 0;
54
55 // create/update preconditioner, probably used every linear solve
56 // the version with two params can be overloaded, if not, it will default to using the one param version
57 virtual bool create_preconditioner(BlockedMatrix<Scalar> *mat) = 0;
58 virtual bool create_preconditioner(BlockedMatrix<Scalar> *mat, BlockedMatrix<Scalar> *jacMat) = 0;
59};
60} //namespace Opm
61
62#endif
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition BlockedMatrix.hpp:29
Definition Preconditioner.hpp:41
Definition openclPreconditioner.hpp:32
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242