WellContributions.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 WELLCONTRIBUTIONS_HEADER_INCLUDED
21#define WELLCONTRIBUTIONS_HEADER_INCLUDED
22
23#include <memory>
24#include <vector>
25
26#if HAVE_SUITESPARSE_UMFPACK
27#include<umfpack.h>
28#endif
29#include <dune/common/version.hh>
30
31namespace Opm {
32
33class MultisegmentWellContribution;
34
40
52{
53public:
54 static std::unique_ptr<WellContributions> create(const std::string& accelerator_mode, bool useWellConn);
55
56 using UMFPackIndex = SuiteSparse_long;
58 enum class MatrixType {
59 C,
60 D,
61 B
62 };
63
64protected:
65 bool allocated = false;
66
67 unsigned int N; // number of rows (not blockrows) in vectors x and y
68 unsigned int dim; // number of columns in blocks in B and C, equal to StandardWell::numEq
69 unsigned int dim_wells; // number of rows in blocks in B and C, equal to StandardWell::numStaticWellEq
70 unsigned int num_blocks = 0; // total number of blocks in all wells
71 unsigned int num_std_wells = 0; // number of StandardWells in this object
72 unsigned int num_ms_wells = 0; // number of MultisegmentWells in this object, must equal multisegments.size()
73 unsigned int num_blocks_so_far = 0; // keep track of where next data is written
74 unsigned int num_std_wells_so_far = 0; // keep track of where next data is written
75 std::vector<unsigned int> val_pointers; // val_pointers[wellID] == index of first block for this well in Ccols and Bcols
76
77 std::vector<std::unique_ptr<MultisegmentWellContribution>> multisegments;
78
79public:
80 unsigned int getNumWells(){
82 }
83
86 void addNumBlocks(unsigned int numBlocks);
87
89 void alloc();
90
93
97 void setBlockSize(unsigned int dim, unsigned int dim_wells);
98
101 void setVectorSize(unsigned N);
102
108 void addMatrix(MatrixType type, int *colIndices, double *values, unsigned int val_size);
109
123 void addMultisegmentWellContribution(unsigned int dim, unsigned int dim_wells,
124 unsigned int Mb,
125 std::vector<double> &Bvalues, std::vector<unsigned int> &BcolIndices, std::vector<unsigned int> &BrowPointers,
126 unsigned int DnumBlocks, double *Dvalues,
127 UMFPackIndex *DcolPointers, UMFPackIndex *DrowIndices,
128 std::vector<double> &Cvalues);
129protected:
131 virtual void APIalloc() {}
132
134 virtual void APIaddMatrix(MatrixType, int*, double*, unsigned int) {}
135};
136} //namespace Opm
137
138#endif
Definition: WellContributions.hpp:52
unsigned int num_std_wells
Definition: WellContributions.hpp:71
unsigned int num_blocks_so_far
Definition: WellContributions.hpp:73
unsigned int getNumWells()
Definition: WellContributions.hpp:80
unsigned int N
Definition: WellContributions.hpp:67
std::vector< unsigned int > val_pointers
Definition: WellContributions.hpp:75
unsigned int dim_wells
Definition: WellContributions.hpp:69
void setBlockSize(unsigned int dim, unsigned int dim_wells)
virtual void APIalloc()
API specific allocation.
Definition: WellContributions.hpp:131
void addMatrix(MatrixType type, int *colIndices, double *values, unsigned int val_size)
unsigned int num_std_wells_so_far
Definition: WellContributions.hpp:74
void addMultisegmentWellContribution(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)
unsigned int num_ms_wells
Definition: WellContributions.hpp:72
MatrixType
StandardWell has C, D and B matrices that need to be copied.
Definition: WellContributions.hpp:58
static std::unique_ptr< WellContributions > create(const std::string &accelerator_mode, bool useWellConn)
virtual ~WellContributions()
Empty destructor.
void alloc()
Allocate memory for the StandardWells.
void setVectorSize(unsigned N)
void addNumBlocks(unsigned int numBlocks)
bool allocated
Definition: WellContributions.hpp:65
virtual void APIaddMatrix(MatrixType, int *, double *, unsigned int)
Api specific upload of matrix.
Definition: WellContributions.hpp:134
std::vector< std::unique_ptr< MultisegmentWellContribution > > multisegments
Definition: WellContributions.hpp:77
unsigned int num_blocks
Definition: WellContributions.hpp:70
unsigned int dim
Definition: WellContributions.hpp:68
SuiteSparse_long UMFPackIndex
Definition: WellContributions.hpp:56
Definition: BlackoilPhases.hpp:27