MultisegmentWellContribution.hpp
Go to the documentation of this file.
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 MULTISEGMENTWELLCONTRIBUTION_HEADER_INCLUDED
21#define MULTISEGMENTWELLCONTRIBUTION_HEADER_INCLUDED
22
23#include <vector>
24
25#if HAVE_CUDA
26#include <cuda_runtime.h>
27#endif
28
29#if HAVE_SUITESPARSE_UMFPACK
30#include<umfpack.h>
31#endif
32#include <dune/common/version.hh>
33
34namespace Opm
35{
36
43
45{
46
47private:
48 unsigned int dim; // size of blockvectors in vectors x and y, equal to MultisegmentWell::numEq
49 unsigned int dim_wells; // size of blocks in C, B and D, equal to MultisegmentWell::numWellEq
50 unsigned int M; // number of rows, M == dim_wells*Mb
51 unsigned int Mb; // number of blockrows in C, D and B
52
53#if HAVE_CUDA
54 cudaStream_t stream; // not actually used yet, will be when MultisegmentWellContribution are applied on GPU
55#endif
56
57 // C and B are stored in BCRS format, D is stored in CSC format (Dune::UMFPack)
58 // Sparsity pattern for C is not stored, since it is the same as B
59 unsigned int DnumBlocks; // number of blocks in D
60 std::vector<double> Cvals;
61 std::vector<double> Dvals;
62 std::vector<double> Bvals;
63 std::vector<int> Dcols; // Columnpointers, contains M+1 entries
64 std::vector<unsigned int> Bcols;
65 std::vector<int> Drows; // Rowindicies, contains DnumBlocks*dim*dim_wells entries
66 std::vector<unsigned int> Brows;
67 std::vector<double> z1; // z1 = B * x
68 std::vector<double> z2; // z2 = D^-1 * B * x
69 void *UMFPACK_Symbolic, *UMFPACK_Numeric;
70
73 unsigned int getColIdx(unsigned int idx);
74
75public:
76 using UMFPackIndex = SuiteSparse_long;
77
78#if HAVE_CUDA
81 void setCudaStream(cudaStream_t stream);
82#endif
83
98 MultisegmentWellContribution(unsigned int dim, unsigned int dim_wells,
99 unsigned int Mb,
100 std::vector<double> &Bvalues, std::vector<unsigned int> &BcolIndices, std::vector<unsigned int> &BrowPointers,
101 unsigned int DnumBlocks, double *Dvalues, UMFPackIndex *DcolPointers,
102 UMFPackIndex *DrowIndices, std::vector<double> &Cvalues);
103
106
111 void apply(double *h_x, double *h_y);
112};
113
114} //namespace Opm
115
116#endif
Definition: MultisegmentWellContribution.hpp:45
~MultisegmentWellContribution()
Destroy a MultisegmentWellContribution, and free memory.
void apply(double *h_x, double *h_y)
MultisegmentWellContribution(unsigned int dim, unsigned int dim_wells, unsigned int Mb, std::vector< double > &Bvalues, std::vector< unsigned int > &BcolIndices, std::vector< unsigned int > &BrowPointers, unsigned int DnumBlocks, double *Dvalues, UMFPackIndex *DcolPointers, UMFPackIndex *DrowIndices, std::vector< double > &Cvalues)
SuiteSparse_long UMFPackIndex
Definition: MultisegmentWellContribution.hpp:76
Definition: BlackoilPhases.hpp:27