OpenCAEPoro  0.2.0 Sep/22/2022
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 "ParamReservoir.hpp"
21 
24 class FlowUnit
25 {
26 public:
28  FlowUnit() = default;
29 
31  virtual OCP_DBL GetPcowBySw(const OCP_DBL& sw) = 0;
32  virtual OCP_DBL GetSwByPcow(const OCP_DBL& pcow) = 0;
34  virtual OCP_DBL GetPcgoBySg(const OCP_DBL& sg) = 0;
35  virtual OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) = 0;
37  virtual OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) = 0;
39  virtual OCP_DBL GetSwco() const = 0;
41  virtual const vector<OCP_DBL>& GetScm() const = 0;
42 
44  virtual void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
45  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) = 0;
46 
48  virtual void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
49  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
50  OCP_DBL& MyFk, OCP_DBL& MyFp) = 0;
51 };
52 
54 // FlowUnit_W
56 
57 class FlowUnit_W : public FlowUnit
58 {
59 public:
60  FlowUnit_W() = default;
61  FlowUnit_W(const ParamReservoir& rs_param, const USI& i){};
62 
63  void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
64  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) override;
65  void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
66  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
67  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
68 
69  OCP_DBL GetSwco() const override { return Swco; };
70 
71  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return 0; }
72  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override { return 0; }
73  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return 0; }
74  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return 0; }
75  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
76 
77  const vector<OCP_DBL>& GetScm() const override {}
78 
79 protected:
80  OCP_DBL Swco;
81 };
82 
84 // FlowUnit_OW
86 
87 class FlowUnit_OW : public FlowUnit
88 {
89 public:
90  FlowUnit_OW() = default;
91  FlowUnit_OW(const ParamReservoir& rs_param, const USI& i);
92 
93  void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
94  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) override;
95  void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
96  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
97  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
98 
99  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWOF.Eval(0, sw, 3); }
100  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
101  {
102  return SWOF.Eval_Inv(3, pcow, 0);
103  }
104  OCP_DBL GetSwco() const override { return Swco; };
105 
106  // useless
107  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return 0; }
108  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return 0; }
109  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
110 
111  const vector<OCP_DBL>& GetScm() const override {}
112 
113 private:
114  OCPTable SWOF;
115  vector<OCP_DBL> data;
116  vector<OCP_DBL> cdata;
117  OCP_DBL kroMax;
118  OCP_DBL Swco;
119 };
120 
122 // FlowUnit_OG
124 
125 class FlowUnit_OG : public FlowUnit
126 {
127 public:
128  FlowUnit_OG() = default;
129  FlowUnit_OG(const ParamReservoir& rs_param, const USI& i);
130 
131  void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
132  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) override;
133  void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
134  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
135  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
136  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGOF.Eval(0, sg, 3); }
137  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGOF.Eval(3, pcgo, 0); }
138 
139  // uesless
140  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return 0; }
141  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override { return 0; }
142  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override { return 0; }
143  OCP_DBL GetSwco() const override { return 0; };
144 
145  const vector<OCP_DBL>& GetScm() const override {}
146 
147 private:
148  OCPTable SGOF;
149  vector<OCP_DBL> data;
150  vector<OCP_DBL> cdata;
151  OCP_DBL kroMax;
152 };
153 
155 // FlowUnit_ODGW
157 
158 class FlowUnit_ODGW : public FlowUnit
159 {
160 public:
161  OCP_DBL CalKro_Stone2(const OCP_DBL& krow, const OCP_DBL& krog, const OCP_DBL& krw,
162  const OCP_DBL& krg) const;
163 
164  OCP_DBL CalKro_Default(const OCP_DBL& Sg, const OCP_DBL& Sw, const OCP_DBL& krog,
165  const OCP_DBL& krow) const;
166 
167  OCP_DBL GetSwco() const override { return Swco; };
168  const vector<OCP_DBL>& GetScm() const override { return Scm; }
169 
170 protected:
174  vector<OCP_DBL> Scm;
175 };
176 
178 // FlowUnit_ODGW01
180 
182 {
183 public:
184  FlowUnit_ODGW01() = default;
185  FlowUnit_ODGW01(const ParamReservoir& rs_param, const USI& i);
186 
187  virtual void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
188  const OCP_DBL& MySurTen, OCP_DBL& MyFk,
189  OCP_DBL& MyFp) override;
190  virtual void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
191  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
192  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
193 
194  OCP_DBL CalKro_Stone2Der(OCP_DBL krow, OCP_DBL krog, OCP_DBL krw, OCP_DBL krg,
195  OCP_DBL dkrwdSw, OCP_DBL dkrowdSw, OCP_DBL dkrgdSg,
196  OCP_DBL dkrogdSg, OCP_DBL& out_dkrodSw,
197  OCP_DBL& out_dkrodSg) const;
198  OCP_DBL CalKro_DefaultDer(const OCP_DBL& Sg, const OCP_DBL& Sw, const OCP_DBL& krog,
199  const OCP_DBL& krow, const OCP_DBL& dkrogSg,
200  const OCP_DBL& dkrowSw, OCP_DBL& dkroSg,
201  OCP_DBL& dkroSw) const;
202 
203  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWOF.Eval(0, sw, 3); }
204  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
205  {
206  return SWOF.Eval_Inv(3, pcow, 0);
207  }
208 
209  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGOF.Eval(0, sg, 3); }
210  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGOF.Eval(3, pcgo, 0); }
211  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override
212  {
213  return SWPCGW.Eval_Inv(1, pcgw, 0);
214  }
215 
216  void Generate_SWPCWG();
217 
218 protected:
221  vector<OCP_DBL> data;
222  vector<OCP_DBL> cdata;
225 };
226 
228 // FlowUnit_ODGW01_Miscible
230 
232 {
233 public:
234  FlowUnit_ODGW01_Miscible(const ParamReservoir& rs_param, const USI& i)
235  : FlowUnit_ODGW01(rs_param, i)
236  {
237 
238  // gas is moveable all the time
239  Scm[1] = 0;
240 
241  USI len = rs_param.miscstr.surTenRef.size();
242  if (len > 0) {
243  surTenRef = rs_param.miscstr.surTenRef[0];
244  surTenPc = 1;
245  if (len > 2) {
246  surTenPc = rs_param.miscstr.surTenRef[2] / surTenRef;
247  }
248  } else {
249  OCP_ABORT("No data in MISCSTR!");
250  }
251  }
252 
253  void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
254  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) override;
255  void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
256  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
257  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
258 
259 private:
260  OCP_DBL kroMis{0};
261  OCP_DBL krgMis{0};
262  OCP_DBL PcogMis{0};
263  OCP_DBL socrMis{0};
264  OCP_DBL sgcrMis{0};
265 
266  OCP_DBL Fk{0};
267  OCP_DBL Fp{0};
268  OCP_DBL surTenRef{0};
269  OCP_DBL Fkexp{0.25};
270  OCP_DBL surTenPc{0};
271  OCP_DBL surTen{0};
272 };
273 
275 // FlowUnit_ODGW02
277 
279 {
280 public:
281  FlowUnit_ODGW02() = default;
282  FlowUnit_ODGW02(const ParamReservoir& rs_param, const USI& i);
283 
284  void CalKrPc(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
285  const OCP_DBL& MySurTen, OCP_DBL& MyFk, OCP_DBL& MyFp) override;
286  void CalKrPcDeriv(const OCP_DBL* S_in, OCP_DBL* kr_out, OCP_DBL* pc_out,
287  OCP_DBL* dkrdS, OCP_DBL* dPcjdS, const OCP_DBL& MySurTen,
288  OCP_DBL& MyFk, OCP_DBL& MyFp) override;
289  OCP_DBL CalKro_Stone2Der(OCP_DBL krow, OCP_DBL krog, OCP_DBL krw, OCP_DBL krg,
290  OCP_DBL dkrwdSw, OCP_DBL dkrowdSo, OCP_DBL dkrgdSg,
291  OCP_DBL dkrogdSo, OCP_DBL& out_dkrodSo) const;
292  OCP_DBL CalKro_DefaultDer(const OCP_DBL& Sg, const OCP_DBL& Sw, const OCP_DBL& krog,
293  const OCP_DBL& krow, const OCP_DBL& dkrogSo,
294  const OCP_DBL& dkrowSo, OCP_DBL& dkroSo) const;
295 
296  OCP_DBL GetPcowBySw(const OCP_DBL& sw) override { return SWFN.Eval(0, sw, 2); }
297  OCP_DBL GetSwByPcow(const OCP_DBL& pcow) override
298  {
299  return SWFN.Eval_Inv(2, pcow, 0);
300  }
301  OCP_DBL GetPcgoBySg(const OCP_DBL& sg) override { return SGFN.Eval(0, sg, 2); }
302  OCP_DBL GetSgByPcgo(const OCP_DBL& pcgo) override { return SGFN.Eval(2, pcgo, 0); }
303  OCP_DBL GetSwByPcgw(const OCP_DBL& pcgw) override
304  {
305  return SWPCGW.Eval_Inv(1, pcgw, 0);
306  }
307  void Generate_SWPCWG();
308 
309 private:
310  OCPTable SWFN;
311  OCPTable SGFN;
312  OCPTable SOF3;
313  vector<OCP_DBL> data;
314  vector<OCP_DBL> cdata;
315  OCPTable SWPCGW;
317 };
318 
319 #endif /* end if __FLOWUNIT_HEADER__ */
320 
321 /*----------------------------------------------------------------------------*/
322 /* Brief Change History of This File */
323 /*----------------------------------------------------------------------------*/
324 /* Author Date Actions */
325 /*----------------------------------------------------------------------------*/
326 /* Shizhe Li Oct/01/2021 Create file */
327 /* Chensong Zhang Oct/05/2022 Format file */
328 /*----------------------------------------------------------------------------*/
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
OCPTable class declaration.
ParamReservoir class declaration.
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:393
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:343
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:203
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:211
virtual void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:219
OCPTable SGOF
saturation table about gas and oil.
Definition: FlowUnit.hpp:219
vector< OCP_DBL > cdata
container to store the slopes of interpolation.
Definition: FlowUnit.hpp:222
virtual void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:191
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:209
OCPTable SWPCGW
Definition: FlowUnit.hpp:223
OCPTable SWOF
saturation table about water and oil.
Definition: FlowUnit.hpp:220
vector< OCP_DBL > data
container to store the values of interpolation.
Definition: FlowUnit.hpp:221
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:301
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:303
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:525
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:296
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:494
OCP_DBL kroMax
oil relative permeability in the presence of connate water only, used in stone2
Definition: FlowUnit.hpp:172
vector< OCP_DBL > Scm
critical saturation when phase becomes mobile / immobile
Definition: FlowUnit.hpp:174
OCP_DBL GetSwco() const override
Return the value of Swco.
Definition: FlowUnit.hpp:167
OCP_DBL Swco
Saturation of connate water.
Definition: FlowUnit.hpp:173
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:168
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:111
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:142
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:136
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:145
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:128
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:140
OCP_DBL GetSwco() const override
Return the value of Swco.
Definition: FlowUnit.hpp:143
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:109
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:68
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:51
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:107
OCP_DBL GetSwco() const override
Return the value of Swco.
Definition: FlowUnit.hpp:104
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:99
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:111
const vector< OCP_DBL > & GetScm() const override
Return the value of Scm.
Definition: FlowUnit.hpp:77
void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate relative permeability and capillary pressure.
Definition: FlowUnit.cpp:20
OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw) override
Pcgw = Pg - Pw.
Definition: FlowUnit.hpp:75
void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp) override
Calculate derivatives of relative permeability and capillary pressure.
Definition: FlowUnit.cpp:27
OCP_DBL GetPcgoBySg(const OCP_DBL &sg) override
Pcgo = Pg - Po.
Definition: FlowUnit.hpp:73
OCP_DBL GetPcowBySw(const OCP_DBL &sw) override
Pcow = Po - Pw.
Definition: FlowUnit.hpp:71
OCP_DBL GetSwco() const override
Return the value of Swco.
Definition: FlowUnit.hpp:69
virtual OCP_DBL GetSwByPcgw(const OCP_DBL &pcgw)=0
Pcgw = Pg - Pw.
FlowUnit()=default
Default constructor.
virtual void CalKrPcDeriv(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, OCP_DBL *dkrdS, OCP_DBL *dPcjdS, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp)=0
Calculate derivatives of relative permeability and capillary pressure.
virtual OCP_DBL GetPcgoBySg(const OCP_DBL &sg)=0
Pcgo = Pg - Po.
virtual const vector< OCP_DBL > & GetScm() const =0
Return the value of Scm.
virtual OCP_DBL GetSwco() const =0
Return the value of Swco.
virtual void CalKrPc(const OCP_DBL *S_in, OCP_DBL *kr_out, OCP_DBL *pc_out, const OCP_DBL &MySurTen, OCP_DBL &MyFk, OCP_DBL &MyFp)=0
Calculate relative permeability and capillary pressure.
virtual OCP_DBL GetPcowBySw(const OCP_DBL &sw)=0
Pcow = Po - Pw.
OCP_DBL Eval_Inv(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:192
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
Definition: OCPTable.cpp:135
Miscstr miscstr
reference Miscibility surface tension