OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
FlowUnit.hpp
Go to the documentation of this file.
1 
12 #ifndef __FLOWUNIT_HEADER__
13 #define __FLOWUNIT_HEADER__
14 
15 #include <math.h>
16 
17 // OpenCAEPoro header files
18 #include "OCPConst.hpp"
19 #include "OCPTable.hpp"
20 #include "OptionalFeatures.hpp"
21 #include "ParamReservoir.hpp"
22 
25 class FlowUnit
26 {
27 public:
29  FlowUnit() = default;
30  virtual void SetupOptionalFeatures(const Grid& myGrid,
31  OptionalFeatures& optFeatures) = 0;
32  virtual void
33  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) = 0;
35  virtual OCP_DBL GetPcowBySw(const OCP_DBL& sw) = 0;
36  virtual OCP_DBL GetSwByPcow(const OCP_DBL& pcow) = 0;
38  virtual OCP_DBL GetPcgoBySg(const OCP_DBL& sg) = 0;
39  virtual OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) = 0;
41  virtual OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) = 0;
43  virtual const vector<OCP_DBL>& GetScm() const = 0;
44 
46  virtual void CalKrPc(const OCP_DBL* S_in,
47  OCP_DBL* kr_out,
48  OCP_DBL* pc_out,
49  const OCP_USI& bId) = 0;
50 
52  virtual void CalKrPcDeriv(const OCP_DBL* S_in,
53  OCP_DBL* kr_out,
54  OCP_DBL* pc_out,
55  OCP_DBL* dkrdS,
56  OCP_DBL* dPcjdS,
57  const OCP_USI& bId) = 0;
58 
59  OCP_DBL GetSwco() const { return Swco; };
60 
61 protected:
62  OCP_DBL Swco;
63  vector<OCP_DBL> data;
64  vector<OCP_DBL> cdata;
65 };
66 
68 // FlowUnit_W
70 
71 class FlowUnit_W : public FlowUnit
72 {
73 public:
74  FlowUnit_W() = default;
75  FlowUnit_W(const ParamReservoir& rs_param, const USI& i){};
76  void SetupOptionalFeatures(const Grid& myGrid,
77  OptionalFeatures& optFeatures) override{};
78  void
79  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override{};
80  void CalKrPc(const OCP_DBL* S_in,
81  OCP_DBL* kr_out,
82  OCP_DBL* pc_out,
83  const OCP_USI& bId) override;
84  void CalKrPcDeriv(const OCP_DBL* S_in,
85  OCP_DBL* kr_out,
86  OCP_DBL* pc_out,
87  OCP_DBL* dkrdS,
88  OCP_DBL* dPcjdS,
89  const OCP_USI& bId) override;
90 
91  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return 0; }
92  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override { return 0; }
93  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return 0; }
94  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return 0; }
95  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
96 
97  const vector<OCP_DBL>& GetScm() const override
98  {
99  OCP_ABORT("Not Completed in this Condition!");
100  }
101 };
102 
104 // FlowUnit_OW
106 
107 class FlowUnit_OW : public FlowUnit
108 {
109 public:
110  FlowUnit_OW() = default;
111  FlowUnit_OW(const ParamReservoir& rs_param, const USI& i);
112  void SetupOptionalFeatures(const Grid& myGrid,
113  OptionalFeatures& optFeatures) override{};
114  void
115  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override{};
116  void CalKrPc(const OCP_DBL* S_in,
117  OCP_DBL* kr_out,
118  OCP_DBL* pc_out,
119  const OCP_USI& bId) override;
120  void CalKrPcDeriv(const OCP_DBL* S_in,
121  OCP_DBL* kr_out,
122  OCP_DBL* pc_out,
123  OCP_DBL* dkrdS,
124  OCP_DBL* dPcjdS,
125  const OCP_USI& bId) override;
126 
127  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWOF.Eval(0, sw, 3); }
128  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
129  {
130  return SWOF.Eval_Inv(3, pcow, 0);
131  }
132 
133  // useless
134  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return 0; }
135  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return 0; }
136  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
137 
138  const vector<OCP_DBL>& GetScm() const override
139  {
140  OCP_ABORT("Not Completed in this Condition!");
141  }
142 
143 protected:
145 };
146 
148 // FlowUnit_OG
150 
151 class FlowUnit_OG : public FlowUnit
152 {
153 public:
154  FlowUnit_OG() = default;
155  FlowUnit_OG(const ParamReservoir& rs_param, const USI& i);
156  void SetupOptionalFeatures(const Grid& myGrid,
157  OptionalFeatures& optFeatures) override{};
158  void
159  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override{};
160  void CalKrPc(const OCP_DBL* S_in,
161  OCP_DBL* kr_out,
162  OCP_DBL* pc_out,
163  const OCP_USI& bId) override;
164  void CalKrPcDeriv(const OCP_DBL* S_in,
165  OCP_DBL* kr_out,
166  OCP_DBL* pc_out,
167  OCP_DBL* dkrdS,
168  OCP_DBL* dPcjdS,
169  const OCP_USI& bId) override;
170  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGOF.Eval(0, sg, 3); }
171  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGOF.Eval(3, pcgo, 0); }
172 
173  // useless
174  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return 0; }
175  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override { return 0; }
176  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
177 
178  const vector<OCP_DBL>& GetScm() const override
179  {
180  OCP_ABORT("Not Completed in this Condition!");
181  }
182 
183 protected:
185  OCP_DBL kroMax;
186 };
187 
189 // FlowUnit_ODGW
191 
192 class FlowUnit_ODGW : public FlowUnit
193 {
194 public:
195  OCP_DBL CalKro_Stone2(const OCP_DBL& krow,
196  const OCP_DBL& krog,
197  const OCP_DBL& krw,
198  const OCP_DBL& krg) const;
199 
200  OCP_DBL CalKro_Default(const OCP_DBL& Sg,
201  const OCP_DBL& Sw,
202  const OCP_DBL& krog,
203  const OCP_DBL& krow) const;
204 
205  const vector<OCP_DBL>& GetScm() const override { return Scm; }
206 
207 protected:
210  vector<OCP_DBL> Scm;
211 };
212 
214 // FlowUnit_ODGW01
216 
218 {
219 public:
220  FlowUnit_ODGW01() = default;
221  FlowUnit_ODGW01(const ParamReservoir& rs_param, const USI& i);
222  void SetupOptionalFeatures(const Grid& myGrid,
223  OptionalFeatures& optFeatures) override{};
224  void
225  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override{};
226  virtual void CalKrPc(const OCP_DBL* S_in,
227  OCP_DBL* kr_out,
228  OCP_DBL* pc_out,
229  const OCP_USI& bId) override;
230  virtual void CalKrPcDeriv(const OCP_DBL* S_in,
231  OCP_DBL* kr_out,
232  OCP_DBL* pc_out,
233  OCP_DBL* dkrdS,
234  OCP_DBL* dPcjdS,
235  const OCP_USI& bId) override;
236 
237  OCP_DBL CalKro_Stone2Der(OCP_DBL krow,
238  OCP_DBL krog,
239  OCP_DBL krw,
240  OCP_DBL krg,
241  OCP_DBL dkrwdSw,
242  OCP_DBL dkrowdSw,
243  OCP_DBL dkrgdSg,
244  OCP_DBL dkrogdSg,
245  OCP_DBL& out_dkrodSw,
246  OCP_DBL& out_dkrodSg) const;
247  OCP_DBL CalKro_DefaultDer(const OCP_DBL& Sg,
248  const OCP_DBL& Sw,
249  const OCP_DBL& krog,
250  const OCP_DBL& krow,
251  const OCP_DBL& dkrogSg,
252  const OCP_DBL& dkrowSw,
253  OCP_DBL& dkroSg,
254  OCP_DBL& dkroSw) const;
255 
256  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWOF.Eval(0, sw, 3); }
257  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
258  {
259  return SWOF.Eval_Inv(3, pcow, 0);
260  }
261 
262  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGOF.Eval(0, sg, 3); }
263  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGOF.Eval(3, pcgo, 0); }
264  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override
265  {
266  return SWPCGW.Eval_Inv(1, pcgw, 0);
267  }
268 
269  void Generate_SWPCWG();
270 
271 protected:
276 };
277 
279 // FlowUnit_ODGW01_Miscible
281 
283 {
284 public:
285  FlowUnit_ODGW01_Miscible(const ParamReservoir& rs_param, const USI& i)
286  : FlowUnit_ODGW01(rs_param, i)
287  {
288  // gas is moveable all the time
289  Scm[1] = 0;
290  maxPcow = SWOF.GetCol(3).front();
291  minPcow = SWOF.GetCol(3).back();
292  }
293  void SetupOptionalFeatures(const Grid& myGrid,
294  OptionalFeatures& optFeatures) override
295  {
296  misTerm = &optFeatures.miscible;
297  scaleTerm = &optFeatures.scalePcow;
298  scaleTerm->Setup(myGrid);
299  };
300  void SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override;
301  void CalKrPc(const OCP_DBL* S_in,
302  OCP_DBL* kr_out,
303  OCP_DBL* pc_out,
304  const OCP_USI& bId) override;
305  void CalKrPcDeriv(const OCP_DBL* S_in,
306  OCP_DBL* kr_out,
307  OCP_DBL* pc_out,
308  OCP_DBL* dkrdS,
309  OCP_DBL* dPcjdS,
310  const OCP_USI& bId) override;
311 
312 protected:
313  ScalePcow* scaleTerm;
314  Miscible* misTerm;
315 
316  OCP_DBL maxPcow;
317  OCP_DBL minPcow;
318 
322 
323  /*
324  OCP_DBL kroMis{0}; ///< miscible oil relative permeability
325  OCP_DBL krgMis{0}; ///< miscible gas relative permeability
326  OCP_DBL PcogMis{0}; ///< miscible gas capillary pressure
327  OCP_DBL socrMis{0}; ///< oil critical miscible saturations
328  OCP_DBL sgcrMis{0}; ///< gas critical miscible saturations
329  */
330 };
331 
333 // FlowUnit_ODGW02
335 
337 {
338 public:
339  FlowUnit_ODGW02() = default;
340  FlowUnit_ODGW02(const ParamReservoir& rs_param, const USI& i);
341  void SetupOptionalFeatures(const Grid& myGrid,
342  OptionalFeatures& optFeatures) override{};
343  void
344  SetupScale(const OCP_USI& bId, OCP_DBL& Swin, const OCP_DBL& Pcowin) override{};
345  void CalKrPc(const OCP_DBL* S_in,
346  OCP_DBL* kr_out,
347  OCP_DBL* pc_out,
348  const OCP_USI& bId) override;
349  void CalKrPcDeriv(const OCP_DBL* S_in,
350  OCP_DBL* kr_out,
351  OCP_DBL* pc_out,
352  OCP_DBL* dkrdS,
353  OCP_DBL* dPcjdS,
354  const OCP_USI& bId) override;
355  OCP_DBL CalKro_Stone2Der(OCP_DBL krow,
356  OCP_DBL krog,
357  OCP_DBL krw,
358  OCP_DBL krg,
359  OCP_DBL dkrwdSw,
360  OCP_DBL dkrowdSo,
361  OCP_DBL dkrgdSg,
362  OCP_DBL dkrogdSo,
363  OCP_DBL& out_dkrodSo) const;
364  OCP_DBL CalKro_DefaultDer(const OCP_DBL& Sg,
365  const OCP_DBL& Sw,
366  const OCP_DBL& krog,
367  const OCP_DBL& krow,
368  const OCP_DBL& dkrogSo,
369  const OCP_DBL& dkrowSo,
370  OCP_DBL& dkroSo) const;
371 
372  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWFN.Eval(0, sw, 2); }
373  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
374  {
375  return SWFN.Eval_Inv(2, pcow, 0);
376  }
377  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGFN.Eval(0, sg, 2); }
378  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGFN.Eval(2, pcgo, 0); }
379  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override
380  {
381  return SWPCGW.Eval_Inv(1, pcgw, 0);
382  }
383  void Generate_SWPCWG();
384 
385 protected:
391 };
392 
393 #endif /* end if __FLOWUNIT_HEADER__ */
394 
395 /*----------------------------------------------------------------------------*/
396 /* Brief Change History of This File */
397 /*----------------------------------------------------------------------------*/
398 /* Author Date Actions */
399 /*----------------------------------------------------------------------------*/
400 /* Shizhe Li Oct/01/2021 Create file */
401 /* Chensong Zhang Oct/05/2022 Format file */
402 /*----------------------------------------------------------------------------*/
Definition of build-in datatypes and consts.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
OCPTable class declaration.
OptionalFeatures class declaration.
ParamReservoir class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
OCP_DBL Fk
The relative permeability interpolation parameter.
Definition: FlowUnit.hpp:319
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:439
OCP_DBL Fp
The capillary pressure interpolation parameter.
Definition: FlowUnit.hpp:320
OCP_DBL surTen
Surface tension.
Definition: FlowUnit.hpp:321
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:395
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:256
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:264
OCPTable SGOF
saturation table about gas and oil.
Definition: FlowUnit.hpp:272
virtual void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:235
virtual void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:205
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:262
OCPTable SWPCGW
Definition: FlowUnit.hpp:274
OCPTable SWOF
saturation table about water and oil.
Definition: FlowUnit.hpp:273
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:377
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:379
OCPTable SWPCGW
Definition: FlowUnit.hpp:389
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:537
OCPTable SOF3
saturation table about oil.
Definition: FlowUnit.hpp:388
OCPTable SWFN
saturation table about water.
Definition: FlowUnit.hpp:386
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:569
OCPTable SGFN
saturation table about gas.
Definition: FlowUnit.hpp:387
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:372
OCP_DBL kroMax
oil relative permeability in the presence of connate water only, used in stone2
Definition: FlowUnit.hpp:209
vector< OCP_DBL > Scm
critical saturation when phase becomes mobile / immobile
Definition: FlowUnit.hpp:210
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:205
OCPTable SGOF
saturation table about gas and oil.
Definition: FlowUnit.hpp:184
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:137
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:176
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:170
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:118
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:178
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:174
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:136
OCPTable SWOF
saturation table about water and oil.
Definition: FlowUnit.hpp:144
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:134
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:72
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:127
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:138
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:53
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:27
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:97
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:95
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:93
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:91
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:18
virtual void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_USI &bId)=0
Calculate derivatives of relative permeability and capillary pressure.
virtual OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw)=0
Pcgw = Pg - Pw.
vector< OCP_DBL > data
container to store the values of interpolation.
Definition: FlowUnit.hpp:63
FlowUnit()=default
Default constructor.
virtual OCP_DBL GetPcgoBySg(const OCP_DBL &sg)=0
Pcgo = Pg - Po.
vector< OCP_DBL > cdata
container to store the slopes of interpolation.
Definition: FlowUnit.hpp:64
virtual const vector< OCP_DBL > & GetScm() const =0
Return the value of Scm.
virtual OCP_DBL GetPcowBySw(const OCP_DBL &sw)=0
Pcow = Po - Pw.
virtual void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_USI &bId)=0
Calculate relative permeability and capillary pressure.
Definition: Grid.hpp:89
OCP_DBL Eval_Inv(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:178
vector< OCP_DBL > & GetCol(const USI &j)
return the jth column in table to modify or use.
Definition: OCPTable.hpp:55
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:126
ScalePcow scalePcow
Scale water-oil capillary pressure term.
Miscible miscible
Miscible term for Compositional Model.
void Setup(const Grid &myGrid)
Setup ScalePcow term.