OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
Grid.hpp
Go to the documentation of this file.
1 
12 #ifndef __GRID_HEADER__
13 #define __GRID_HEADER__
14 
15 // Standard header files
16 #include <iostream>
17 #include <vector>
18 
19 // OpenCAEPoro header files
20 #include "CornerGrid.hpp"
21 #include "OCPConst.hpp"
22 #include "ParamReservoir.hpp"
23 #include "UtilOutput.hpp"
24 
25 using namespace std;
26 
27 
28 
29 
31 class GPair
32 {
33 public:
34  GPair() = default;
35  GPair(const OCP_USI& Id, const OCP_DBL& Area)
36  : id(Id)
37  , area(Area){};
38  static bool lessG(const GPair& G1, const GPair& G2) { return G1.id < G2.id; }
39 
42 };
43 
45 // Note: GB_Pair contains two variables, which indicates if a grid cell is active or
46 // not and its index among active cells if it is active.
47 class GB_Pair
48 {
49 public:
51  GB_Pair() = default;
52 
54  GB_Pair(bool act, OCP_USI i)
55  : activity(act)
56  , index(i){};
57 
59  bool IsAct() const { return activity; }
60 
62  OCP_USI GetId() const { return index; }
63 
64 private:
65  bool activity;
66  OCP_USI index;
67 };
68 
70 // Note: All grid cells are stored here, you can regard it as a database of the
71 // reservoir. Considering there exist inactive cells (whose porosity or cell volume is
72 // too small) and activeness status might change, the Grid class is necessary. The Grid
73 // class is static while simulating, active grids will be stored in bulks, which is
74 // "area" for calculating???
75 class Grid
76 {
77  friend class Bulk;
78  friend class BulkConn;
79  friend class Well;
80 
81 public:
83  Grid() = default;
85  void InputParam(const ParamReservoir& rs_param);
87  void Setup();
88 
90  void SetupOrthogonalGrid();
92  void SetupNeighborOrthogonalGrid();
94  OCP_DBL CalAkdOrthogonalGrid(const OCP_USI& bId, const OCP_USI& eId,
95  const USI& direction);
97  void CalDepthVOrthogonalGrid();
98 
100  void SetupCornerGrid();
102  void SetupNeighborCornerGrid(const COORD& CoTmp);
104  OCP_DBL CalAkdCornerGrid(const GeneralConnect& conn);
105 
107  void CalActiveGrid(const OCP_DBL& e1, const OCP_DBL& e2);
109  const GB_Pair& MapG2B(const OCP_USI& i) const { return activeMap_G2B[i]; }
111  OCP_USI GetGridNx() const { return nx; }
113  OCP_USI GetGridNy() const { return ny; }
115  OCP_USI GetGridNz() const { return nz; }
117  OCP_USI GetGridNum() const { return numGrid; }
119  OCP_USI GetConnNum() const { return numConn; }
121  OCP_USI GetActiveGridNum() const { return activeGridNum; }
123  OCP_USI GetActIndex(const USI& i, const USI& j, const USI& k) const;
125  void GetIJKGrid(USI& i, USI& j, USI& k, const OCP_USI& n) const;
127  void GetIJKBulk(USI& i, USI& j, USI& k, const OCP_USI& n) const;
128  void CalSomeInfo()const;
129 private:
130  USI nx;
131  USI ny;
132  USI nz;
133  OCP_USI numGrid;
134  OCP_USI numConn;
135 
136  USI gridType;
137  vector<vector<GPair>> gNeighbor;
138 
139  // Orthogonal grid
140  vector<OCP_DBL> tops;
141  vector<OCP_DBL> depth;
142  vector<OCP_DBL> dx;
143  vector<OCP_DBL> dy;
144  vector<OCP_DBL> dz;
145 
146  // Corner-point grid
147  vector<OCP_DBL> coord;
148  vector<OCP_DBL> zcorn;
149 
150  // Rock properties
151  vector<OCP_DBL> v;
152  vector<OCP_DBL> ntg;
153  vector<OCP_DBL> poro;
154  vector<OCP_DBL> kx;
155  vector<OCP_DBL> ky;
156  vector<OCP_DBL> kz;
157 
158  // Initial Properties
159  vector<OCP_DBL> SwatInit;
160 
161  // Region
162  vector<USI> SATNUM;
163  vector<USI> PVTNUM;
164  vector<USI> ACTNUM;
165 
166  // Active grid cells
167  OCP_USI activeGridNum;
168  vector<OCP_USI> activeMap_B2G;
169  vector<GB_Pair> activeMap_G2B;
170 
171 private:
172  // Auxiliary variable
173  USI numDigutIJK;
174 
175 public:
176  void CalNumDigutIJK();
177  USI GetNumDigitIJK() const { return numDigutIJK; }
178 };
179 
180 #endif /* end if __GRID_HEADER__ */
181 
182 /*----------------------------------------------------------------------------*/
183 /* Brief Change History of This File */
184 /*----------------------------------------------------------------------------*/
185 /* Author Date Actions */
186 /*----------------------------------------------------------------------------*/
187 /* Shizhe Li Oct/01/2021 Create file */
188 /* Chensong Zhang Oct/15/2021 Format file */
189 /* Shizhe Li Nov/18/2021 Add Connections between Grids */
190 /* Chensong Zhang Jan/16/2022 Finish Doxygen */
191 /*----------------------------------------------------------------------------*/
Declaration of classes related to the corner grid.
Definition of build-in datatypes and consts.
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
ParamReservoir class declaration.
Supply basic tools used to output files.
Properties and operations on connections between bulks (active grids).
Definition: BulkConn.hpp:58
Physical information of each active reservoir bulk.
Definition: Bulk.hpp:58
Active cell indicator and its index among active cells.
Definition: Grid.hpp:48
GB_Pair(bool act, OCP_USI i)
Constructor with given information. TODO: needed???
Definition: Grid.hpp:54
GB_Pair()=default
Default constructor.
bool IsAct() const
Return whether this cell is active or not.
Definition: Grid.hpp:59
OCP_USI GetId() const
Return the index of this cell among active cells.
Definition: Grid.hpp:62
Effective area of intersection surfaces with neighboring cells.
Definition: Grid.hpp:32
OCP_DBL area
Effective area between this cell and the neighbor indicated by id.
Definition: Grid.hpp:41
OCP_USI id
Id of a neighboring cell.
Definition: Grid.hpp:40
Basic information of computational grid, including the rock properties.
Definition: Grid.hpp:76
OCP_USI GetGridNy() const
Return ny of grid cell.
Definition: Grid.hpp:113
OCP_USI GetGridNz() const
Return nz of grid cell.
Definition: Grid.hpp:115
const GB_Pair & MapG2B(const OCP_USI &i) const
Mapping from grid cells to bulks (active cells).
Definition: Grid.hpp:109
OCP_USI GetActiveGridNum() const
Return the num of bulks (active cells).
Definition: Grid.hpp:121
OCP_USI GetGridNum() const
Return the num of grid cells.
Definition: Grid.hpp:117
Grid()=default
Default constructor.
OCP_USI GetGridNx() const
Return nx of grid cell.
Definition: Grid.hpp:111
OCP_USI GetConnNum() const
Return the num of connections.
Definition: Grid.hpp:119
Definition: Well.hpp:105
void Setup(const Grid &myGrid, const Bulk &myBulk, const vector< SolventINJ > &sols)
Setup the well after Grid and Bulk finish setupping.
Definition: Well.cpp:105