BlockedMatrix.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_BLOCKED_MATRIX_HPP
21#define OPM_BLOCKED_MATRIX_HPP
22
23namespace Opm::Accelerator {
24
27template<class Scalar>
29{
30public:
35 BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_)
36 : nnzValues(new Scalar[nnzbs_*block_size_*block_size_])
37 , colIndices(new int[nnzbs_*block_size_*block_size_])
38 , rowPointers(new int[Nb_+1])
39 , Nb(Nb_)
40 , nnzbs(nnzbs_)
41 , block_size(block_size_)
42 , deleteNnzs(true)
43 , deleteSparsity(true)
44 {}
45
49 : nnzValues(new Scalar[M.nnzbs*M.block_size*M.block_size])
52 , Nb(M.Nb)
53 , nnzbs(M.nnzbs)
55 , deleteNnzs(true)
56 , deleteSparsity(false)
57 {}
58
66 BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_,
67 Scalar* nnzValues_, int *colIndices_, int *rowPointers_)
68 : nnzValues(nnzValues_)
69 , colIndices(colIndices_)
70 , rowPointers(rowPointers_)
71 , Nb(Nb_)
72 , nnzbs(nnzbs_)
73 , block_size(block_size_)
74 , deleteNnzs(false)
75 , deleteSparsity(false)
76 {}
77
79 {
80 if (deleteNnzs) {
81 delete[] nnzValues;
82 }
83 if (deleteSparsity) {
84 delete[] colIndices;
85 delete[] rowPointers;
86 }
87 }
88
89 Scalar* nnzValues;
92 int Nb;
93 int nnzbs;
94 unsigned int block_size;
97};
98
105void sortRow(int* colIndices, int* data, int left, int right);
106
113template<class Scalar>
114void blockMultSub(Scalar* a, Scalar* b, Scalar* c, unsigned int block_size);
115
122template<class Scalar>
123void blockMult(Scalar* mat1, Scalar* mat2, Scalar* resMat, unsigned int block_size);
124
125} // namespace Opm::Accelerator
126
127#endif
Definition: BlockedMatrix.hpp:29
~BlockedMatrix()
Definition: BlockedMatrix.hpp:78
bool deleteNnzs
Definition: BlockedMatrix.hpp:95
Scalar * nnzValues
Definition: BlockedMatrix.hpp:89
BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_)
Definition: BlockedMatrix.hpp:35
bool deleteSparsity
Definition: BlockedMatrix.hpp:96
int Nb
Definition: BlockedMatrix.hpp:92
unsigned int block_size
Definition: BlockedMatrix.hpp:94
int * colIndices
Definition: BlockedMatrix.hpp:90
BlockedMatrix(const BlockedMatrix &M)
Definition: BlockedMatrix.hpp:48
int * rowPointers
Definition: BlockedMatrix.hpp:91
BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_, Scalar *nnzValues_, int *colIndices_, int *rowPointers_)
Definition: BlockedMatrix.hpp:66
int nnzbs
Definition: BlockedMatrix.hpp:93
Definition: amgclSolverBackend.hpp:44
void sortRow(int *colIndices, int *data, int left, int right)
void blockMult(Scalar *mat1, Scalar *mat2, Scalar *resMat, unsigned int block_size)
void blockMultSub(Scalar *a, Scalar *b, Scalar *c, unsigned int block_size)