OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
BulkConn.hpp
Go to the documentation of this file.
1 
12 #ifndef __BULKCONN_HEADER__
13 #define __BULKCONN_HEADER__
14 
15 // Standard header files
16 #include <vector>
17 
18 // OpenCAEPoro header files
19 #include "Bulk.hpp"
20 #include "DenseMat.hpp"
21 #include "Grid.hpp"
22 #include "LinearSystem.hpp"
23 #include "OCPStructure.hpp"
24 
25 using namespace std;
26 
28 // Note: Bulks are the active grid cells.
29 class BulkPair
30 {
31  friend class BulkConn;
32 
33 public:
35  BulkPair() = default;
36 
38  BulkPair(const OCP_USI& bId, const OCP_USI& eId, const OCP_DBL& Area)
39  : BId(bId)
40  , EId(eId)
41  , area(Area){};
42 
43  OCP_USI GetBId() const { return BId; }
44  OCP_USI GetEId() const { return EId; }
45 
46 private:
47  OCP_USI BId;
48  OCP_USI EId;
49  OCP_DBL area;
50 };
51 
53 // Note: BulkConn is a core component of reservoir, it contains all properties and
54 // operations on connections between bulks (active grids). You can traverse all the
55 // connections through an effective iterator. Flow calculations between active
56 // bulks and matrix assembling with contributions from bulks only are included.
57 class BulkConn
58 {
59 
60 public:
61  BulkConn() = default;
62 
64  // General
66 
67 public:
69  void Setup(const Grid& myGrid, const Bulk& myBulk);
70 
72  void SetupWellBulk_K(Bulk& myBulk) const;
73 
75  void AllocateMat(LinearSystem& myLS) const;
76 
78  void SetupMatSparsity(LinearSystem& myLS) const;
79 
81  void UpdateLastStep();
82 
84  void Reset();
85 
87  void CheckDiff() const;
88 
90  OCP_USI GetBulkNum() const { return numBulk; }
91 
93  void PrintConnectionInfo(const Grid& myGrid) const;
94  void PrintConnectionInfoCoor(const Grid& myGrid) const;
95 
96 private:
97  OCP_USI numBulk;
98  OCP_USI numConn;
99 
101  // Note: The i-th entry stores the i-th bulk's neighbors, which is sorted in an
102  // increasing order.
103  vector<vector<OCP_USI>> neighbor;
104 
105  // sum of num of neighbors who has the bigger Index than current bulk
106  // used to find the location in iteratorConn, upblock, etc.
107  vector<USI> neighborNumGacc;
108 
110  vector<USI> selfPtr;
111 
113  vector<USI> neighborNum;
114 
116  // Note: In each pair, the index of first bulk is greater than the second. The data
117  // in iteratorConn is generated from neighbor.
118  vector<BulkPair> iteratorConn;
119 
120 
121 
124  // Note: Upblock is identified by difference of pressure between phases.
125  vector<OCP_USI> upblock;
127  vector<OCP_DBL> upblock_Rho;
129  vector<OCP_DBL> upblock_Trans;
131  vector<OCP_DBL> upblock_Velocity;
132 
134  vector<OCP_USI> lastUpblock;
135  vector<OCP_DBL> lastUpblock_Rho;
136  vector<OCP_DBL> lastUpblock_Trans;
137  vector<OCP_DBL> lastUpblock_Velocity;
138 
140  // IMPEC
142 
143 public:
145  void AllocateAuxIMPEC(const USI& np);
146 
148  void AssembleMatIMPEC(LinearSystem& myLS, const Bulk& myBulk,
149  const OCP_DBL& dt) const;
150 
152  void CalCFL(const Bulk& myBulk, const OCP_DBL& dt) const;
153 
155  void CalFluxIMPEC(const Bulk& myBulk);
156 
158  void MassConserveIMPEC(Bulk& myBulk, const OCP_DBL& dt) const;
159 
161  // FIM
163 
164 public:
166  void AllocateAuxFIM(const USI& np);
167 
169  void AssembleMat_FIM(LinearSystem& myLS, const Bulk& myBulk,
170  const OCP_DBL& dt) const;
171 
173  void CalFluxFIM(const Bulk& myBulk);
174 
176  void CalResFIM(vector<OCP_DBL>& res, const Bulk& myBulk, const OCP_DBL& dt);
177 
179  void CalFluxFIMS(const Bulk& myBulk);
180  void CalResFIMS(vector<OCP_DBL>& res, const Bulk& myBulk, const OCP_DBL& dt);
181 
182 
184  // FIM(new)
186 
189  void AssembleMat_FIM_new(LinearSystem& myLS, const Bulk& myBulk,
190  const OCP_DBL& dt) const;
192  void AssembleMat_FIM_newS(LinearSystem& myLS, const Bulk& myBulk,
193  const OCP_DBL& dt) const;
195  void AssembleMat_FIM_new_n(LinearSystem& myLS, const Bulk& myBulk,
196  const OCP_DBL& dt) const;
197 
199  // AIMs, AIMt
201 
202 public:
203  void SetupFIMBulk(Bulk& myBulk, const bool& NRflag = false) const;
204  void AddFIMBulk(Bulk& myBulk);
205  void SetupFIMBulkBoundAIMs(Bulk& myBulk);
207  void AllocateAuxAIMt();
209  void SetupMatSparsityAIMt(LinearSystem& myLS, const Bulk& myBulk) const;
211  void AssembleMat_AIMt(LinearSystem& myLS, const Bulk& myBulk,
212  const OCP_DBL& dt) const;
214  void CalResAIMt(vector<OCP_DBL>& res, const Bulk& myBulk, const OCP_DBL& dt);
217  void CalResAIMs(vector<OCP_DBL>& res, const Bulk& myBulk, const OCP_DBL& dt);
220  void AssembleMat_AIMs(LinearSystem& myLS, vector<OCP_DBL>& res, const Bulk& myBulk,
221  const OCP_DBL& dt) const;
222 
224  void AllocateAuxAIMc(const USI& np);
225  void AssembleMat_AIMc(LinearSystem& myLS, const Bulk& myBulk, const OCP_DBL& dt) const;
226  void AssembleMat_AIMc01(LinearSystem& myLS, const Bulk& myBulk, const OCP_DBL& dt) const;
228  void CalResAIMc(vector<OCP_DBL>& res, const Bulk& myBulk, const OCP_DBL& dt);
229 };
230 
231 
232 #endif
233 
234 /*----------------------------------------------------------------------------*/
235 /* Brief Change History of This File */
236 /*----------------------------------------------------------------------------*/
237 /* Author Date Actions */
238 /*----------------------------------------------------------------------------*/
239 /* Shizhe Li Oct/01/2021 Create file */
240 /* Chensong Zhang Oct/15/2021 Format file */
241 /* Chensong Zhang Jan/17/2022 Update Doxygen */
242 /*----------------------------------------------------------------------------*/
Bulk class declaration.
Operations about small dense mat.
Grid class declaration.
Linear solver class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:26
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:24
Some Structure in OpenCAEPoro.
Properties and operations on connections between bulks (active grids).
Definition: BulkConn.hpp:58
OCP_USI GetBulkNum() const
Return number of bulks.
Definition: BulkConn.hpp:90
BulkConn()=default
Default constructor.
Connection between two bulks (BId, EId); usually, indices BId > EId.
Definition: BulkConn.hpp:30
BulkPair(const OCP_USI &bId, const OCP_USI &eId, const OCP_DBL &Area)
Setup BulkPair with bId and eId.
Definition: BulkConn.hpp:38
OCP_USI GetEId() const
Return ending index.
Definition: BulkConn.hpp:44
OCP_USI GetBId() const
Return beginning index.
Definition: BulkConn.hpp:43
BulkPair()=default
Default constructor.
Physical information of each active reservoir bulk.
Definition: Bulk.hpp:58
Basic information of computational grid, including the rock properties.
Definition: Grid.hpp:76
Linear solvers for discrete systems.