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
44template<class Scalar>
46{
47
48private:
49 unsigned int dim; // size of blockvectors in vectors x and y, equal to MultisegmentWell::numEq
50 unsigned int dim_wells; // size of blocks in C, B and D, equal to MultisegmentWell::numWellEq
51 unsigned int M; // number of rows, M == dim_wells*Mb
52 unsigned int Mb; // number of blockrows in C, D and B
53
54#if HAVE_CUDA
55 cudaStream_t stream; // not actually used yet, will be when MultisegmentWellContribution are applied on GPU
56#endif
57
58 // C and B are stored in BCRS format, D is stored in CSC format (Dune::UMFPack)
59 // Sparsity pattern for C is not stored, since it is the same as B
60 unsigned int DnumBlocks; // number of blocks in D
61 std::vector<Scalar> Cvals;
62 std::vector<Scalar> Dvals;
63 std::vector<Scalar> Bvals;
64 std::vector<int> Dcols; // Columnpointers, contains M+1 entries
65 std::vector<unsigned int> Bcols;
66 std::vector<int> Drows; // Rowindicies, contains DnumBlocks*dim*dim_wells entries
67 std::vector<unsigned int> Brows;
68 std::vector<Scalar> z1; // z1 = B * x
69 std::vector<Scalar> z2; // z2 = D^-1 * B * x
70 void *UMFPACK_Symbolic, *UMFPACK_Numeric;
71
74 unsigned int getColIdx(unsigned int idx);
75
76public:
77 using UMFPackIndex = SuiteSparse_long;
78
79#if HAVE_CUDA
82 void setCudaStream(cudaStream_t stream);
83#endif
84
99 MultisegmentWellContribution(unsigned int dim, unsigned int dim_wells,
100 unsigned int Mb,
101 std::vector<Scalar>& Bvalues,
102 std::vector<unsigned int>& BcolIndices,
103 std::vector<unsigned int>& BrowPointers,
104 unsigned int DnumBlocks,
105 Scalar* Dvalues,
106 UMFPackIndex* DcolPointers,
107 UMFPackIndex* DrowIndices,
108 std::vector<Scalar>& Cvalues);
109
112
117 void apply(Scalar* h_x, Scalar* h_y);
118};
119
120} //namespace Opm
121
122#endif
Definition: MultisegmentWellContribution.hpp:46
SuiteSparse_long UMFPackIndex
Definition: MultisegmentWellContribution.hpp:77
MultisegmentWellContribution(unsigned int dim, unsigned int dim_wells, unsigned int Mb, std::vector< Scalar > &Bvalues, std::vector< unsigned int > &BcolIndices, std::vector< unsigned int > &BrowPointers, unsigned int DnumBlocks, Scalar *Dvalues, UMFPackIndex *DcolPointers, UMFPackIndex *DrowIndices, std::vector< Scalar > &Cvalues)
~MultisegmentWellContribution()
Destroy a MultisegmentWellContribution, and free memory.
void apply(Scalar *h_x, Scalar *h_y)
Definition: blackoilboundaryratevector.hh:37