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
24{
25namespace Accelerator
26{
27
31{
32
33public:
34
39 BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_)
40 : nnzValues(new double[nnzbs_*block_size_*block_size_]),
41 colIndices(new int[nnzbs_*block_size_*block_size_]),
42 rowPointers(new int[Nb_+1]),
43 Nb(Nb_),
44 nnzbs(nnzbs_),
45 block_size(block_size_),
46 deleteNnzs(true),
47 deleteSparsity(true)
48 {}
49
53 : nnzValues(new double[M.nnzbs*M.block_size*M.block_size]),
56 Nb(M.Nb),
57 nnzbs(M.nnzbs),
59 deleteNnzs(true),
60 deleteSparsity(false)
61 {}
62
70 BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_, double *nnzValues_, int *colIndices_, int *rowPointers_)
71 : nnzValues(nnzValues_),
72 colIndices(colIndices_),
73 rowPointers(rowPointers_),
74 Nb(Nb_),
75 nnzbs(nnzbs_),
76 block_size(block_size_),
77 deleteNnzs(false),
78 deleteSparsity(false)
79 {}
80
82 if (deleteNnzs) {
83 delete[] nnzValues;
84 }
85 if (deleteSparsity) {
86 delete[] colIndices;
87 delete[] rowPointers;
88 }
89 }
90
91
92 double *nnzValues;
95 int Nb;
96 int nnzbs;
97 unsigned int block_size;
100};
101
102
109void sortRow(int *colIndices, int *data, int left, int right);
110
117void blockMultSub(double *a, double *b, double *c, unsigned int block_size);
118
125void blockMult(double *mat1, double *mat2, double *resMat, unsigned int block_size);
126
127} // namespace Accelerator
128} // namespace Opm
129
130#endif
Definition: BlockedMatrix.hpp:31
BlockedMatrix(const BlockedMatrix &M)
Definition: BlockedMatrix.hpp:52
unsigned int block_size
Definition: BlockedMatrix.hpp:97
int Nb
Definition: BlockedMatrix.hpp:95
int nnzbs
Definition: BlockedMatrix.hpp:96
BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_, double *nnzValues_, int *colIndices_, int *rowPointers_)
Definition: BlockedMatrix.hpp:70
BlockedMatrix(int Nb_, int nnzbs_, unsigned int block_size_)
Definition: BlockedMatrix.hpp:39
bool deleteSparsity
Definition: BlockedMatrix.hpp:99
int * colIndices
Definition: BlockedMatrix.hpp:93
int * rowPointers
Definition: BlockedMatrix.hpp:94
double * nnzValues
Definition: BlockedMatrix.hpp:92
~BlockedMatrix()
Definition: BlockedMatrix.hpp:81
bool deleteNnzs
Definition: BlockedMatrix.hpp:98
void sortRow(int *colIndices, int *data, int left, int right)
void blockMultSub(double *a, double *b, double *c, unsigned int block_size)
void blockMult(double *mat1, double *mat2, double *resMat, unsigned int block_size)
Definition: BlackoilPhases.hpp:27