My Project
Matrix.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 OPM_MATRIX_HEADER_INCLUDED
21 #define OPM_MATRIX_HEADER_INCLUDED
22 
23 #include <vector>
24 
25 namespace Opm
26 {
27 namespace Accelerator
28 {
29 
32 class Matrix {
33 
34 public:
35 
39  Matrix(int N_, int nnzs_)
40  : N(N_),
41  M(N_),
42  nnzs(nnzs_)
43  {
44  nnzValues.resize(nnzs);
45  colIndices.resize(nnzs);
46  rowPointers.resize(N+1);
47  }
48 
53  Matrix(int N_, int M_, int nnzs_)
54  : Matrix(N_, nnzs_)
55  {
56  M = M_;
57  }
58 
59 #if HAVE_FPGA
76  int toRDF(int numColors, std::vector<int>& nodesPerColor,
77  std::vector<std::vector<int> >& colIndicesInColor, int nnzsPerRowLimit,
78  std::vector<std::vector<double> >& ubNnzValues, short int *ubColIndices, int *nnzValsSizes, unsigned char *NROffsets, int *colorSizes);
79 #endif
80 
81  std::vector<double> nnzValues;
82  std::vector<int> colIndices;
83  std::vector<int> rowPointers;
84  int N, M;
85  int nnzs;
86 };
87 
88 void sortRow(int *colIndices, double *data, int left, int right);
89 
90 } // namespace Accelerator
91 } // namespace Opm
92 
93 #endif // OPM_MATRIX_HEADER_INCLUDED
This struct resembles a csr matrix, only doubles are supported The data is stored in contiguous memor...
Definition: Matrix.hpp:32
Matrix(int N_, int M_, int nnzs_)
Allocate rectangular Matrix and data arrays with given sizes.
Definition: Matrix.hpp:53
Matrix(int N_, int nnzs_)
Allocate square Matrix and data arrays with given sizes.
Definition: Matrix.hpp:39
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27