OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
AllWells.hpp
Go to the documentation of this file.
1 
12 #ifndef __WELLGROUP_HEADER__
13 #define __WELLGROUP_HEADER__
14 
15 // OpenCAEPoro header files
16 #include "ParamWell.hpp"
17 #include "Well.hpp"
18 
19 using namespace std;
20 
25 class WellGroup
26 {
27  friend class AllWells;
28 
29 public:
30  WellGroup() = default;
31  WellGroup(const string& gname) :name(gname) {};
32 
33 private:
34 
35  string name;
36  vector<USI> wId;
37  vector<USI> wIdINJ;
38  vector<USI> wIdPROD;
39 
40  // for Reinjection
41  bool reInj{false};
42  USI injPhase;
43  USI prodGroup{0};
45  OCP_DBL saleRate;
47  OCP_DBL xi;
49  vector<OCP_DBL> zi;
50  OCP_DBL factor;
51 
52  OCP_DBL GOPR{0};
53  OCP_DBL GGPR{0};
54  OCP_DBL GWPR{0};
55  OCP_DBL GOPT{0};
56  OCP_DBL GGPT{0};
57  OCP_DBL GWPT{0};
58  OCP_DBL GGIR{0};
59  OCP_DBL GWIR{0};
60  OCP_DBL GGIT{0};
61  OCP_DBL GWIT{0};
62 };
63 
64 
68 class AllWells
69 {
70 
71  // temp
72  friend class Reservoir;
73  friend class DetailInfo;
74 
75 public:
76  AllWells() = default;
77 
79  // General
81 
82 public:
84  void InputParam(const ParamWell& paramWell);
86  void Setup(const Grid& myGrid, const Bulk& myBulk);
88  void SetupWell(const Grid& myGrid, const Bulk& myBulk);
90  void SetupWellGroup(const Bulk& myBulk);
92  void SetupMixture(const Bulk& myBulk);
94  void SetupWellBulk(Bulk& myBulk) const;
96  void ApplyControl(const USI& i);
98  void InitBHP(const Bulk& myBulk);
100  void PrepareWell(const Bulk& myBulk);
102  void CalTrans(const Bulk& myBulk);
104  void CalFlux(const Bulk& myBulk);
106  void CalProdWeight(const Bulk& myBulk);
108  void CaldG(const Bulk& myBulk);
110  void CalIPRT(const Bulk& myBulk, OCP_DBL dt);
112  void CalReInjFluid(const Bulk& myBulk);
114  void AllocateMat(LinearSystem& myLS, const USI& bulknum) const;
115  void UpdateLastBHP() { for (auto& w : wells) w.lBHP = w.BHP; }
116  void ResetBHP();
119  {
120  for (auto& w : wells) w.ldG = w.dG;
121  }
122  void ResetDg()
123  {
124  for (auto& w : wells) w.dG = w.ldG;
125  }
127  OCP_INT CheckP(const Bulk& myBulk);
129  USI GetWellNum() const { return numWell; }
131  string GetWellName(const USI& i) const { return wells[i].name; }
133  USI GetIndex(const string& name) const;
135  USI GetWellPerfNum(const USI& i) const { return wells[i].numPerf; }
137  USI GetWellPerfNum() const;
139  USI GetMaxWellPerNum() const;
140  void CalMaxBHPChange();
141  OCP_DBL GetdBHPmax() const { return dPmax; }
143  OCP_DBL GetFOPR() const { return FOPR; }
145  OCP_DBL GetFOPT() const { return FOPT; }
147  OCP_DBL GetFGPR() const { return FGPR; }
149  OCP_DBL GetFGPT() const { return FGPt; }
151  OCP_DBL GetFWPR() const { return FWPR; }
153  OCP_DBL GetFWPT() const { return FWPT; }
155  OCP_DBL GetFGIR() const { return FGIR; }
157  OCP_DBL GetFGIT() const { return FGIT; }
159  OCP_DBL GetFWIR() const { return FWIR; }
161  OCP_DBL GetFWIT() const { return FWIT; }
163  OCP_DBL GetWOPR(const USI& w) const { return wells[w].WOPR; }
165  OCP_DBL GetWOPT(const USI& w) const { return wells[w].WOPT; }
167  OCP_DBL GetWGPR(const USI& w) const { return wells[w].WGPR; }
169  OCP_DBL GetWGPT(const USI& w) const { return wells[w].WGPT; }
171  OCP_DBL GetWWPR(const USI& w) const { return wells[w].WWPR; }
173  OCP_DBL GetWWPT(const USI& w) const { return wells[w].WWPT; }
175  OCP_DBL GetWGIR(const USI& w) const { return wells[w].WGIR; }
177  OCP_DBL GetWGIT(const USI& w) const { return wells[w].WGIT; }
179  OCP_DBL GetWWIR(const USI& w) const { return wells[w].WWIR; }
181  OCP_DBL GetWWIT(const USI& w) const { return wells[w].WWIT; }
183  OCP_DBL GetWBHP(const USI& w) const {
184  if (wells[w].WellState())
185  return wells[w].BHP;
186  else
187  return 0;
188  }
190  OCP_DBL GetWellDg(const USI& w, const USI& p) const { return wells[w].dG[p]; }
191  OCP_DBL CalWellQT();
192  void ShowWellStatus(const Bulk& myBulk) { for (USI w = 0; w < numWell; w++) wells[w].ShowPerfStatus(myBulk); }
193  bool GetWellChange() const { return wellChange; }
194 
195 private:
196  USI numWell;
197  vector<Well> wells;
198  USI numGroup;
199  vector<WellGroup> wellGroup;
200 
201  bool wellChange;
202  vector<SolventINJ> solvents;
203  OCP_DBL dPmax{0};
204 
205  vector<Mixture*> flashCal;
206 
207  OCP_DBL FGIR{0};
208  OCP_DBL FGIT{0};
209  OCP_DBL FWIR{0};
210  OCP_DBL FWIT{0};
211  OCP_DBL FOPR{0};
212  OCP_DBL FOPT{0};
213  OCP_DBL FGPR{0};
214  OCP_DBL FGPt{0};
215  OCP_DBL FWPR{0};
216  OCP_DBL FWPT{0};
217 
218  OCP_DBL QT{0};
219 
221  // IMPEC
223 
224 public:
226  void CalCFL(const Bulk& myBulk, const OCP_DBL& dt) const;
228  void MassConserveIMPEC(Bulk& myBulk, OCP_DBL dt);
230  void AssemblaMatIMPEC(LinearSystem& myLS, const Bulk& myBulk,
231  const OCP_DBL& dt) const;
233  void GetSolIMPEC(const vector<OCP_DBL>& u, const OCP_USI& bId);
234 
236  // FIM
238 
239 public:
241  void AssemblaMatFIM(LinearSystem& myLS, const Bulk& myBulk,
242  const OCP_DBL& dt) const;
244  void GetSolFIM(const vector<OCP_DBL>& u, const OCP_USI& bId, const USI& len);
245  void GetSol01FIM(const vector<OCP_DBL>& u, const OCP_USI& bId, const USI& len,
246  const OCP_DBL& alpha);
248  void CalResFIM(ResFIM& resFIM, const Bulk& myBulk, const OCP_DBL& dt) const;
250  void ShowRes(const vector<OCP_DBL>& res, const Bulk& myBulk) const;
251 
252 
254  // FIM
257  void AssemblaMatFIM_new(LinearSystem& myLS, const Bulk& myBulk,
258  const OCP_DBL& dt) const;
259  void AssemblaMatFIM_new_n(LinearSystem& myLS, const Bulk& myBulk,
260  const OCP_DBL& dt) const;
261 
263  // AIMt, AIMs
265 
266 public:
268  void AssemblaMatAIMt(LinearSystem& myLS, const Bulk& myBulk,
269  const OCP_DBL& dt) const;
271  void CalResAIMt(ResFIM& resFIM, const Bulk& myBulk, const OCP_DBL& dt) const;
273  void GetSolAIMt(const vector<OCP_DBL>& u, const OCP_USI& bId, const USI& len);
274 
276  void AssemblaMatAIMs(LinearSystem& myLS, const Bulk& myBulk,
277  const OCP_DBL& dt) const;
278 };
279 
280 #endif /* end if __WELLGROUP_HEADER__ */
281 
282 /*----------------------------------------------------------------------------*/
283 /* Brief Change History of This File */
284 /*----------------------------------------------------------------------------*/
285 /* Author Date Actions */
286 /*----------------------------------------------------------------------------*/
287 /* Shizhe Li Oct/01/2021 Create file */
288 /* Chensong Zhang Oct/15/2021 Format file */
289 /* Shizhe Li Feb/08/2022 Rename to AllWells */
290 /*----------------------------------------------------------------------------*/
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
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
ParamWell class declaration.
Well class declaration.
OCP_DBL GetWGIR(const USI &w) const
Return gas injection rate of the wth well.
Definition: AllWells.hpp:175
OCP_DBL GetWGIT(const USI &w) const
Return total gas injection of the wth well.
Definition: AllWells.hpp:177
void UpdateLastDg()
Reset dG to ldG for each well.
Definition: AllWells.hpp:118
OCP_DBL GetFWPT() const
Return total water production in field.
Definition: AllWells.hpp:153
OCP_DBL GetFWIR() const
Return water injection rate in field.
Definition: AllWells.hpp:159
OCP_DBL GetFGPT() const
Return total gas production in field.
Definition: AllWells.hpp:149
OCP_DBL GetWWIR(const USI &w) const
Return water injection rate of the wth well.
Definition: AllWells.hpp:179
OCP_DBL GetWWPR(const USI &w) const
Return water production rate of the wth well.
Definition: AllWells.hpp:171
OCP_DBL GetWWIT(const USI &w) const
Return total water injection of the wth well.
Definition: AllWells.hpp:181
OCP_DBL GetWGPR(const USI &w) const
Return gas production rate of the wth well.
Definition: AllWells.hpp:167
string GetWellName(const USI &i) const
Return the name of specified well.
Definition: AllWells.hpp:131
OCP_DBL GetFWPR() const
Return water production rate in field.
Definition: AllWells.hpp:151
OCP_DBL GetWBHP(const USI &w) const
Return the BHP of wth well.
Definition: AllWells.hpp:183
OCP_DBL GetFWIT() const
Return total water injection in field.
Definition: AllWells.hpp:161
OCP_DBL GetFGIT() const
Return gas water injection in field.
Definition: AllWells.hpp:157
OCP_DBL GetWOPT(const USI &w) const
Return total oil production of the wth well.
Definition: AllWells.hpp:165
OCP_DBL GetFOPT() const
Return total oil production in field.
Definition: AllWells.hpp:145
OCP_DBL GetWGPT(const USI &w) const
Return total gas production of the wth well.
Definition: AllWells.hpp:169
OCP_DBL GetWWPT(const USI &w) const
Return total water production of the wth well.
Definition: AllWells.hpp:173
USI GetWellPerfNum(const USI &i) const
Return the num of perforations of well i.
Definition: AllWells.hpp:135
OCP_DBL GetWellDg(const USI &w, const USI &p) const
Return the pth dG of wth well.
Definition: AllWells.hpp:190
OCP_DBL GetWOPR(const USI &w) const
Return oil production rate of the wth well.
Definition: AllWells.hpp:163
OCP_DBL GetFGPR() const
Return gas production rate in field.
Definition: AllWells.hpp:147
USI GetWellNum() const
Return the num of wells.
Definition: AllWells.hpp:129
OCP_DBL GetFGIR() const
Return gas injection rate in field.
Definition: AllWells.hpp:155
OCP_DBL GetFOPR() const
Return oil production rate in field.
Definition: AllWells.hpp:143
Physical information of each active reservoir bulk.
Definition: Bulk.hpp:58
Collect more detailed information of each time step.
Definition: OCPOutput.hpp:165
Basic information of computational grid, including the rock properties.
Definition: Grid.hpp:76
Linear solvers for discrete systems.