My Project
openclWellContributions.hpp
1 /*
2  Copyright 2020 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 WELLCONTRIBUTIONS_OPENCL_HEADER_INCLUDED
21 #define WELLCONTRIBUTIONS_OPENCL_HEADER_INCLUDED
22 
23 #include <opm/simulators/linalg/bda/WellContributions.hpp>
24 
25 #include <opm/simulators/linalg/bda/opencl/opencl.hpp>
26 #include <opm/simulators/linalg/bda/opencl/openclKernels.hpp>
27 
28 #include <memory>
29 #include <vector>
30 
31 
32 namespace Opm
33 {
34 
36 {
37 public:
38  void setKernel(Opm::Accelerator::stdwell_apply_kernel_type *kernel_,
39  Opm::Accelerator::stdwell_apply_no_reorder_kernel_type *kernel_no_reorder_);
40  void setOpenCLEnv(cl::Context *context_, cl::CommandQueue *queue_);
41 
46  void setReordering(int* toOrder, bool reorder);
47  void apply_stdwells(cl::Buffer d_x, cl::Buffer d_y, cl::Buffer d_toOrder);
48  void apply_mswells(cl::Buffer d_x, cl::Buffer d_y);
49  void apply(cl::Buffer d_x, cl::Buffer d_y, cl::Buffer d_toOrder);
50 
51 protected:
53  void APIalloc() override;
54 
55  void APIaddMatrix(MatrixType type, int *colIndices, double *values, unsigned int val_size) override;
56 
57  cl::Context* context;
58  cl::CommandQueue* queue;
59  Opm::Accelerator::stdwell_apply_kernel_type* kernel;
60  Opm::Accelerator::stdwell_apply_no_reorder_kernel_type* kernel_no_reorder;
61  std::vector<cl::Event> events;
62 
63  std::unique_ptr<cl::Buffer> d_Cnnzs_ocl, d_Dnnzs_ocl, d_Bnnzs_ocl;
64  std::unique_ptr<cl::Buffer> d_Ccols_ocl, d_Bcols_ocl;
65  std::unique_ptr<cl::Buffer> d_val_pointers_ocl;
66 
67  bool reorder = false;
68  int *h_toOrder = nullptr;
69  std::vector<double> h_x;
70  std::vector<double> h_y;
71 };
72 
73 } //namespace Opm
74 
75 #endif
Definition: openclWellContributions.hpp:36
void APIalloc() override
Allocate memory for the StandardWells.
Definition: openclWellContributions.cpp:144
void APIaddMatrix(MatrixType type, int *colIndices, double *values, unsigned int val_size) override
Api specific upload of matrix.
Definition: openclWellContributions.cpp:97
void setReordering(int *toOrder, bool reorder)
Since the rows of the matrix are reordered, the columnindices of the matrixdata is incorrect Those in...
Definition: openclWellContributions.cpp:46
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition: WellContributions.hpp:53
MatrixType
StandardWell has C, D and B matrices that need to be copied.
Definition: WellContributions.hpp:63
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27