OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
Reservoir.cpp
Go to the documentation of this file.
1 
12 #include "Reservoir.hpp"
13 
15 // General
17 
19 {
21 
22  grid.InputParam(param.paramRs);
23  bulk.InputParam(param.paramRs);
24  allWells.InputParam(param.paramWell);
25 
26 }
27 
29 {
31 
32  grid.Setup();
33  bulk.Setup(grid);
34  conn.Setup(grid, bulk);
35  allWells.Setup(grid, bulk);
36 }
37 
39 {
41 
42  allWells.ApplyControl(i);
43  allWells.SetupWellGroup(bulk);
44 }
45 
47 {
49 
50  allWells.PrepareWell(bulk);
51 }
52 
54 {
56 
57  allWells.CalFlux(bulk);
58 }
59 
61 {
63 
64  allWells.CalTrans(bulk);
65 }
66 
68 {
70 
71  bulk.CalVpore();
72 }
73 
75 {
77 
78  bulk.CalKrPc();
79 }
80 
82 {
84 
85  bulk.CalMaxChange();
86  allWells.CalMaxBHPChange();
87 }
88 
89 void Reservoir::CalIPRT(const OCP_DBL& dt)
90 {
92  // Calculate injection / production rate for current step
93  allWells.CalIPRT(bulk, dt);
94  // Calculate Reinjection fluid for next step
95  allWells.CalReInjFluid(bulk);
96 }
97 
98 OCP_INT Reservoir::CheckP(const bool& bulkCheck, const bool& wellCheck)
99 {
100  OCP_FUNCNAME;
101 
102  if (bulkCheck) {
103  if (!bulk.CheckP()) {
104  return 1;
105  }
106  }
107 
108  if (wellCheck) {
109  OCP_INT flag = 0;
110  flag = allWells.CheckP(bulk);
111  return flag;
112  }
113 
114  return 0;
115 }
116 
118 {
119  OCP_FUNCNAME;
120 
121  return bulk.CheckNi();
122 }
123 
124 bool Reservoir::CheckVe(const OCP_DBL& Vlim) const
125 {
126  OCP_FUNCNAME;
127 
128  return bulk.CheckVe(Vlim);
129 }
130 
131 void Reservoir::GetNTQT(const OCP_DBL& dt)
132 {
133  OCP_DBL NT = bulk.CalNT();
134  OCP_DBL QT = allWells.CalWellQT() * dt;
135  cout << setprecision(8) << NT << " " << QT << endl;
136 }
137 
139 // IMPEC
141 
143 {
144  OCP_FUNCNAME;
145 
146  bulk.AllocateAuxIMPEC();
147  conn.AllocateAuxIMPEC(bulk.GetPhaseNum());
148 }
149 
151 {
152  OCP_FUNCNAME;
153 
154  if (bulk.GetMixMode() == BLKOIL)
155  bulk.InitSjPcBo(50);
156  else if (bulk.GetMixMode() == EOS_PVTW)
157  bulk.InitSjPcComp(50, grid);
158 
159  bulk.CalVpore();
160  bulk.InitFlash(true);
161  bulk.CalKrPc();
162  bulk.UpdateLastStepIMPEC();
163  conn.CalFluxIMPEC(bulk);
164  conn.UpdateLastStep();
165  allWells.InitBHP(bulk);
166  allWells.UpdateLastBHP();
167 }
168 
169 
171 {
172  OCP_FUNCNAME;
173 
174  bulk.SetCFL2Zero();
175  conn.CalCFL(bulk, dt);
176  allWells.CalCFL(bulk, dt);
177  cfl = bulk.CalCFL();
178 
179  return cfl;
180 }
181 
183 {
184  OCP_FUNCNAME;
185 
186  conn.CalFluxIMPEC(bulk);
187  allWells.CalFlux(bulk);
188 }
189 
191 {
192  OCP_FUNCNAME;
193 
194  conn.CalFluxIMPEC(bulk);
195 }
196 
198 {
199  OCP_FUNCNAME;
200 
201  conn.MassConserveIMPEC(bulk, dt);
202  allWells.MassConserveIMPEC(bulk, dt);
203 }
204 
206 {
207  OCP_FUNCNAME;
208 
209  bulk.Flash();
210 }
211 
213 {
214  OCP_FUNCNAME;
215  bulk.UpdateLastStepIMPEC();
216  conn.UpdateLastStep();
217  // useless in IMPEC now
218  // allWells.UpdateLastBHP();
219  // allWells.UpdateLastDg();
220 }
221 
223 {
224  OCP_FUNCNAME;
225 
226  myLS.AllocateRowMem(bulk.GetBulkNum() + allWells.GetWellNum(), 1);
227  conn.AllocateMat(myLS);
228  allWells.AllocateMat(myLS, bulk.GetBulkNum());
229  myLS.AllocateColMem();
230 }
231 
233 {
234  OCP_FUNCNAME;
235 
236  conn.SetupMatSparsity(myLS);
237  conn.AssembleMatIMPEC(myLS, bulk, dt);
238  allWells.AssemblaMatIMPEC(myLS, bulk, dt);
239 }
240 
241 void Reservoir::GetSolutionIMPEC(const vector<OCP_DBL>& u)
242 {
243  OCP_FUNCNAME;
244 
245  bulk.GetSolIMPEC(u);
246  allWells.GetSolIMPEC(u, bulk.GetBulkNum());
247 }
248 
250 {
251  // allWells.ResetDg();
252  allWells.ResetBHP();
253  allWells.CalTrans(bulk);
254  allWells.CalFlux(bulk);
255  allWells.CaldG(bulk);
256 }
257 
258 
260 {
261  OCP_FUNCNAME;
262  bulk.ResetPj();
263  conn.Reset();
264 }
265 
267 {
268  OCP_FUNCNAME;
269 
270  bulk.ResetPj();
271  bulk.ResetNi();
272  conn.Reset();
273 }
274 
276 {
277  OCP_FUNCNAME;
278  bulk.ResetphaseNum();
279  bulk.ResetminEigenSkip();
280  bulk.ResetflagSkip();
281  bulk.ResetziSkip();
282  bulk.ResetPSkip();
283  bulk.ResetKs();
284 
285  bulk.ResetPj();
286  bulk.ResetNi();
287  bulk.ResetNt();
288  bulk.ResetFlash();
289  bulk.ResetVp();
290  conn.Reset();
291 
292  // Becareful! if recalculate the flash, result may be different because the initial
293  // flash was calculated by InitFlash not Flash.
294 }
295 
297 // FIM
299 
301 {
302  OCP_FUNCNAME;
303 
304  bulk.AllocateAuxFIM();
305  conn.AllocateAuxFIM(bulk.GetPhaseNum());
306 }
307 
309 {
310  OCP_FUNCNAME;
311 
312  if (bulk.GetMixMode() == BLKOIL)
313  bulk.InitSjPcBo(50);
314  else if (bulk.GetMixMode() == EOS_PVTW)
315  bulk.InitSjPcComp(50, grid);
316 
317  bulk.CalVpore();
318  bulk.InitFlashDer();
319  bulk.CalKrPcDeriv();
320  conn.CalFluxFIM(bulk);
321  allWells.InitBHP(bulk);
323 }
324 
325 
326 void Reservoir::InitFIM_n()
327 {
328  OCP_FUNCNAME;
329 
330  if (bulk.GetMixMode() == BLKOIL)
331  bulk.InitSjPcBo(50);
332  else if (bulk.GetMixMode() == EOS_PVTW)
333  bulk.InitSjPcComp(50, grid);
334 
335  bulk.CalVpore();
336  bulk.InitFlashDer_n();
337  bulk.CalKrPcDeriv();
338  conn.CalFluxFIM(bulk);
339  allWells.InitBHP(bulk);
341 }
342 
343 
345 {
346  OCP_FUNCNAME;
347 
348  bulk.FlashDeriv();
349 }
350 
351 void Reservoir::CalFlashDerivFIM_n()
352 {
353  OCP_FUNCNAME;
354 
355  bulk.FlashDeriv_n();
356 }
357 
359 {
360  OCP_FUNCNAME;
361 
362  bulk.CalKrPcDeriv();
363 }
364 
366 {
367  OCP_FUNCNAME;
368 
369  bulk.UpdateLastStepFIM();
370  allWells.UpdateLastBHP();
371 }
372 
374 {
375  OCP_FUNCNAME;
376 
377  myLS.AllocateRowMem(bulk.GetBulkNum() + allWells.GetWellNum(),
378  bulk.GetComNum() + 1);
379  conn.AllocateMat(myLS);
380  allWells.AllocateMat(myLS, bulk.GetBulkNum());
381  myLS.AllocateColMem();
382 }
383 
384 void Reservoir::AssembleMatFIM(LinearSystem& myLS, const OCP_DBL& dt) const
385 {
386  OCP_FUNCNAME;
387 
388  conn.SetupMatSparsity(myLS);
389 
390 #ifdef OCP_NEW_FIM
391  conn.AssembleMat_FIM_new(myLS, bulk, dt);
392  allWells.AssemblaMatFIM_new(myLS, bulk, dt);
393 #else
394  conn.AssembleMat_FIM(myLS, bulk, dt);
395  allWells.AssemblaMatFIM(myLS, bulk, dt);
396 #endif // OCP_NEW_FIM
397 }
398 
399 
400 void Reservoir::AssembleMatFIM_n(LinearSystem& myLS, const OCP_DBL& dt) const
401 {
402  OCP_FUNCNAME;
403 
404  conn.SetupMatSparsity(myLS);
405  conn.AssembleMat_FIM_new_n(myLS, bulk, dt);
406  allWells.AssemblaMatFIM_new_n(myLS, bulk, dt);
407 }
408 
409 void Reservoir::GetSolutionFIM(const vector<OCP_DBL>& u, const OCP_DBL& dPmax,
410  const OCP_DBL& dSmax)
411 {
412  bulk.GetSolFIM(u, dPmax, dSmax);
413  allWells.GetSolFIM(u, bulk.GetBulkNum(), bulk.GetComNum() + 1);
414 }
415 
416 
417 void Reservoir::GetSolutionFIM_n(const vector<OCP_DBL>& u, const OCP_DBL& dPmax,
418  const OCP_DBL& dSmax)
419 {
420  OCP_FUNCNAME;
421 
422  bulk.GetSolFIM_n(u, dPmax, dSmax);
423  allWells.GetSolFIM(u, bulk.GetBulkNum(), bulk.GetComNum() + 1);
424 }
425 
426 
427 // Not useful
428 void Reservoir::GetSolution01FIM(const vector<OCP_DBL>& u)
429 {
430  bulk.GetSol01FIM(u);
431  allWells.GetSol01FIM(u, bulk.GetBulkNum(), bulk.GetComNum() + 1, 1);
432 }
433 
434 void Reservoir::CalResFIM(ResFIM& resFIM, const OCP_DBL& dt)
435 {
436  OCP_FUNCNAME;
437  // Initialize
438  resFIM.SetZero();
439  // Bulk to Bulk
440  conn.CalResFIM(resFIM.res, bulk, dt);
441  // Well to Bulk
442  allWells.CalResFIM(resFIM, bulk, dt);
443  // Calculate RelRes
444  bulk.CalRelResFIM(resFIM);
445  Dscalar(resFIM.res.size(), -1.0, resFIM.res.data());
446 
447  // Calculate Res2 and ResMax
448  // OCP_DBL resmax = 0;
449  // OCP_USI maxId = 0;
450  // OCP_DBL res2 = 0;
451  // for (OCP_USI i = 0; i < resFIM.res.size(); i++) {
452  // res2 += pow(resFIM.res[i], 2);
453  // if (resmax < fabs(resFIM.res[i])) {
454  // resmax = fabs(resFIM.res[i]);
455  // maxId = i;
456  // }
457  //}
458  // cout << "Res2 " << pow(res2 / resFIM.res.size(), 0.5) << " "
459  // << resFIM.res.size() << endl;
460  // cout << "ResMax " << resmax << " " << maxId << endl;
461  // cout << "BHP \n";
462  // for (USI w = 0; w < allWells.numWell; w++) {
463  // cout << allWells.GetWBHP(w) << " ";
464  // for (USI p = 0; p < allWells.GetWellPerfNum(w); p++) {
465  // cout << allWells.wells[w].GetPerfPre(p) << " ";
466  // }
467  //}
468  // cout << endl;
469 }
470 
471 void Reservoir::ResetFIM(const bool& flag)
472 {
473  bulk.ResetFIM();
474  allWells.ResetBHP();
475  allWells.CalTrans(bulk);
476  allWells.CalFlux(bulk);
477 
478  if (flag) {
479  allWells.CaldG(bulk);
480  allWells.CalFlux(bulk);
481  }
482 }
483 
484 void Reservoir::PrintSolFIM(const string& outfile) const
485 {
486  ofstream outu(outfile);
487  if (!outu.is_open()) cout << "Can not open " << outfile << endl;
488  const OCP_USI nb = bulk.numBulk;
489  const OCP_USI nc = bulk.numCom;
490 
491  for (OCP_USI n = 0; n < nb; n++) {
492  // Pressure
493  outu << bulk.P[n] << "\n";
494  // Ni
495  for (USI i = 0; i < nc; i++) {
496  outu << bulk.Ni[n * nc + i] << "\n";
497  }
498  }
499  // Well Pressure
500  for (USI w = 0; w < allWells.numWell; w++) {
501  outu << allWells.GetWBHP(w) << "\n";
502  }
503  outu.close();
504 }
505 
506 void Reservoir::ShowRes(const vector<OCP_DBL>& res) const
507 {
508  bulk.ShowRes(res);
509  allWells.ShowRes(res, bulk);
510 }
511 
512 
514 // AIMt
516 
518 {
519  bulk.AllocateAuxIMPEC();
520  conn.AllocateAuxIMPEC(bulk.GetPhaseNum());
521  conn.AllocateAuxAIMt();
522 
523  bulk.AllocateWellBulkId(allWells.GetWellPerfNum() * 10);
524  bulk.AllocateAuxAIM(0.05);
525 }
526 
528 {
529  OCP_FUNCNAME;
530 
531  myLS.AllocateRowMem(bulk.GetMaxFIMBulk() + allWells.GetWellNum(),
532  bulk.GetComNum() + 1);
533  myLS.AllocateColMem(10);
534 }
535 
536 
537 void Reservoir::CalFlashDerivAIM(const bool& IfAIMs)
538 {
539  bulk.FlashDerivAIM(IfAIMs);
540 }
541 
542 
543 void Reservoir::CalKrPcDerivAIM(const bool& IfAIMs)
544 {
545  bulk.CalKrPcDerivAIM(IfAIMs);
546 }
547 
548 
549 void Reservoir::CalResAIMt(ResFIM& resFIM, const OCP_DBL& dt)
550 {
551  // Initialize
552  resFIM.SetZero();
553  // Bulk to Bulk
554  conn.CalResAIMt(resFIM.res, bulk, dt);
555  // Well to Bulk
556  allWells.CalResAIMt(resFIM, bulk, dt);
557  // Calculate RelRes
558  bulk.CalRelResAIMt(resFIM);
559  Dscalar(resFIM.res.size(), -1, resFIM.res.data());
560 }
561 
562 
563 void Reservoir::AssembleMatAIMt(LinearSystem& myLS, const OCP_DBL& dt) const
564 {
565  conn.SetupMatSparsityAIMt(myLS, bulk);
566  conn.AssembleMat_AIMt(myLS, bulk, dt);
567  allWells.AssemblaMatAIMt(myLS, bulk, dt);
568 }
569 
570 void Reservoir::GetSolutionAIMt(const vector<OCP_DBL>& u, const OCP_DBL& dPmax,
571  const OCP_DBL& dSmax)
572 {
573  bulk.GetSolAIMt(u, dPmax, dSmax);
574  allWells.GetSolAIMt(u, bulk.numFIMBulk, bulk.GetComNum() + 1);
575 }
576 
577 
579 {
580  bulk.AllocateAuxIMPEC();
581  bulk.AllocateWellBulkId(allWells.GetWellPerfNum() * 10);
582  bulk.AllocateAuxAIM(1);
583 
584  conn.AllocateAuxIMPEC(bulk.GetPhaseNum());
585  conn.AllocateAuxAIMt();
586 }
587 
588 void Reservoir::CalResAIMs(ResFIM& resFIM, const OCP_DBL& dt)
589 {
590  // Initialize
591  resFIM.SetZero();
592  // Bulk to Bulk
593  conn.CalResAIMs(resFIM.res, bulk, dt);
594  // Well to Bulk
595  allWells.CalResFIM(resFIM, bulk, dt);
596  // Calculate RelRes
597  bulk.CalRelResAIMs(resFIM);
598  Dscalar(resFIM.res.size(), -1, resFIM.res.data());
599 }
600 
601 void Reservoir::AssembleMatAIMs(LinearSystem& myLS, vector<OCP_DBL>& res, const OCP_DBL& dt) const
602 {
603  conn.SetupMatSparsity(myLS);
604  conn.AssembleMat_AIMs(myLS, res, bulk, dt);
605  allWells.AssemblaMatAIMs(myLS, bulk, dt);
606 }
607 
608 void Reservoir::GetSolutionAIMs(const vector<OCP_DBL>& u, const OCP_DBL& dPmax,
609  const OCP_DBL& dSmax)
610 {
611  bulk.GetSolAIMs(u, dPmax, dSmax);
612  allWells.GetSolFIM(u, bulk.GetBulkNum(), bulk.GetComNum() + 1);
613 }
614 
615 void Reservoir::ResetValAIM()
616 {
617  ResetVal03IMPEC();
618  bulk.ResetFIMBulk();
619  allWells.ResetBHP();
620  allWells.CalTrans(bulk);
621  allWells.CalFlux(bulk);
622 
623  if (false) {
624  allWells.CaldG(bulk);
625  allWells.CalFlux(bulk);
626  }
627 }
628 
629 OCP_DBL Reservoir::CalCFLAIM(const OCP_DBL& dt)
630 {
631  OCP_FUNCNAME;
632 
633  bulk.SetCFL2Zero();
634  conn.CalCFL(bulk, dt);
635  cfl = bulk.CalCFL();
636 
637  return cfl;
638 }
639 
641 {
642  OCP_FUNCNAME;
643  bulk.UpdateLastStepIMPEC();
644  bulk.UpdateLastStepAIM();
645  conn.UpdateLastStep();
646  allWells.UpdateLastBHP();
647  allWells.UpdateLastDg();
648 }
649 
651 {
652  OCP_FUNCNAME;
653 
654  bulk.AllocateAuxFIM();
655  bulk.AllocateAuxAIMc();
656  conn.AllocateAuxAIMc(bulk.GetPhaseNum());
657 }
658 
659 void Reservoir::AssembleMatAIMc(LinearSystem& myLS, const OCP_DBL& dt) const
660 {
661  OCP_FUNCNAME;
662 
663  conn.SetupMatSparsity(myLS);
664  conn.AssembleMat_AIMc01(myLS, bulk, dt);
665  allWells.AssemblaMatFIM(myLS, bulk, dt);
666 }
667 
668 void Reservoir::CalResAIMc(ResFIM& resFIM, const OCP_DBL& dt)
669 {
670  OCP_FUNCNAME;
671  // Initialize
672  resFIM.SetZero();
673  // Bulk to Bulk
674  conn.CalResAIMc(resFIM.res, bulk, dt);
675  // Well to Bulk
676  allWells.CalResFIM(resFIM, bulk, dt);
677  // Calculate RelRes
678  bulk.CalRelResFIM(resFIM);
679  Dscalar(resFIM.res.size(), -1, resFIM.res.data());
680 }
681 
682 void Reservoir::CalFlashAIMc()
683 {
684  bulk.FlashAIMc();
685 }
686 
687 void Reservoir::CalFlashAIMc01()
688 {
689  bulk.FlashAIMc01();
690 }
691 
692 void Reservoir::CalKrPcAIMc()
693 {
694  bulk.CalKrPcAIMc();
695 }
696 
697 
700 {
701  bulk.FlashDerivAIMc();
702 }
703 
704 
707 {
708  bulk.CalKrPcDerivAIMc();
709 }
710 
711 void Reservoir::GetSolutionAIMc(const vector<OCP_DBL>& u, const OCP_DBL& dPmax,
712  const OCP_DBL& dSmax)
713 {
714  bulk.GetSolAIMc01(u, dPmax, dSmax);
715  allWells.GetSolFIM(u, bulk.GetBulkNum(), bulk.GetComNum() + 1);
716 }
717 
718 void Reservoir::InitAIMc()
719 {
720  OCP_FUNCNAME;
721 
722  if (bulk.GetMixMode() == BLKOIL)
723  bulk.InitSjPcBo(50);
724  else if (bulk.GetMixMode() == EOS_PVTW)
725  bulk.InitSjPcComp(50, grid);
726 
727  bulk.CalVpore();
728  bulk.InitFlash(true);
729  bulk.CalKrPc();
730  conn.CalFluxFIM(bulk);
731  allWells.InitBHP(bulk);
733 }
734 
735 
736 /*----------------------------------------------------------------------------*/
737 /* Brief Change History of This File */
738 /*----------------------------------------------------------------------------*/
739 /* Author Date Actions */
740 /*----------------------------------------------------------------------------*/
741 /* Shizhe Li Oct/01/2021 Create file */
742 /* Chensong Zhang Oct/15/2021 Format file */
743 /*----------------------------------------------------------------------------*/
void Dscalar(const int &n, const double &alpha, double *x)
Scales a vector by a constant.
Definition: DenseMat.cpp:62
const USI BLKOIL
Mixture model = black-oil.
Definition: OCPConst.hpp:88
const USI EOS_PVTW
Mixture model = equation-of-state.
Definition: OCPConst.hpp:89
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
Reservoir class declaration.
#define OCP_FUNCNAME
Print Function Name.
Definition: UtilError.hpp:73
void ShowRes(const vector< OCP_DBL > &res, const Bulk &myBulk) const
Show Res.
Definition: AllWells.cpp:587
void CalResAIMt(ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt) const
Calculate Resiual and relative Resiual for local FIM.
Definition: AllWells.cpp:677
void CalFlux(const Bulk &myBulk)
Calculate volume flow rate and moles flow rate of each perforation.
Definition: AllWells.cpp:203
void CalTrans(const Bulk &myBulk)
Calculate Transmissibility of Wells.
Definition: AllWells.cpp:192
void AllocateMat(LinearSystem &myLS, const USI &bulknum) const
Calculate memory for Matrix.
Definition: AllWells.cpp:318
void AssemblaMatFIM(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for FIM.
Definition: AllWells.cpp:512
void UpdateLastDg()
Reset dG to ldG for each well.
Definition: AllWells.hpp:118
void AssemblaMatAIMt(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for AIMt.
Definition: AllWells.cpp:657
void AssemblaMatIMPEC(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for IMPEC.
Definition: AllWells.cpp:461
void MassConserveIMPEC(Bulk &myBulk, OCP_DBL dt)
Update moles of components in Bulks which connects to well.
Definition: AllWells.cpp:450
OCP_INT CheckP(const Bulk &myBulk)
Check if unreasonable well pressure or perforation pressure occurs.
Definition: AllWells.cpp:340
void CaldG(const Bulk &myBulk)
Calculate dG.
Definition: AllWells.cpp:225
OCP_DBL GetWBHP(const USI &w) const
Return the BHP of wth well.
Definition: AllWells.hpp:183
void ApplyControl(const USI &i)
Apply the operation mode at the ith critical time.
Definition: AllWells.cpp:149
void AssemblaMatFIM_new(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for FIM.
Definition: AllWells.cpp:606
void CalIPRT(const Bulk &myBulk, OCP_DBL dt)
Calculate Injection rate, total Injection, Production rate, total Production.
Definition: AllWells.cpp:236
void GetSolAIMt(const vector< OCP_DBL > &u, const OCP_USI &bId, const USI &len)
Get solution from solver class after linear system is solved for local FIM.
Definition: AllWells.cpp:692
void GetSolFIM(const vector< OCP_DBL > &u, const OCP_USI &bId, const USI &len)
Get solution from solver class after linear system is solved for FIM.
Definition: AllWells.cpp:545
void GetSolIMPEC(const vector< OCP_DBL > &u, const OCP_USI &bId)
Update Well P and Perforation P after linear system is solved for IMPEC.
Definition: AllWells.cpp:494
void InitBHP(const Bulk &myBulk)
Set the initial well pressure.
Definition: AllWells.cpp:165
USI GetWellPerfNum(const USI &i) const
Return the num of perforations of well i.
Definition: AllWells.hpp:135
void SetupWellGroup(const Bulk &myBulk)
Setup information of wellGroup.
Definition: AllWells.cpp:76
void Setup(const Grid &myGrid, const Bulk &myBulk)
Setup well in allWells.
Definition: AllWells.cpp:58
void PrepareWell(const Bulk &myBulk)
Calculate well properties at the beginning of each time step.
Definition: AllWells.cpp:174
void CalResFIM(ResFIM &resFIM, const Bulk &myBulk, const OCP_DBL &dt) const
Calculate Resiual and relative Resiual for FIM.
Definition: AllWells.cpp:572
USI GetWellNum() const
Return the num of wells.
Definition: AllWells.hpp:129
void CalReInjFluid(const Bulk &myBulk)
Calculate Reinjection fluid.
Definition: AllWells.cpp:273
void InputParam(const ParamWell &paramWell)
Input param from ParamWell.
Definition: AllWells.cpp:19
void CalCFL(const Bulk &myBulk, const OCP_DBL &dt) const
Calculate the CFL number for each perforation and return the maximum one.
Definition: AllWells.cpp:439
void AssemblaMatAIMs(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assemble matrix, parts related to well are included for AIMt.
Definition: AllWells.cpp:706
void Setup(const Grid &myGrid, const Bulk &myBulk)
Setup active connections and calculate necessary properties using Grid and Bulk.
Definition: BulkConn.cpp:25
void UpdateLastStep()
Update physcial values of the previous step.
Definition: BulkConn.cpp:127
void AllocateAuxAIMc(const USI &np)
Allocate memory for auxiliary variables used by the AIMc method.
Definition: BulkConn.cpp:2921
void AssembleMatIMPEC(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for IMPEC, terms related to bulks only.
Definition: BulkConn.cpp:241
void SetupMatSparsity(LinearSystem &myLS) const
Setup sparsity pattern of the coefficient matrix.
Definition: BulkConn.cpp:116
void AssembleMat_FIM(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for FIM, terms related to bulks only.
Definition: BulkConn.cpp:467
void CalCFL(const Bulk &myBulk, const OCP_DBL &dt) const
Calculate the CFL number for flow between bulks???
Definition: BulkConn.cpp:335
void AllocateAuxIMPEC(const USI &np)
Allocate memory for auxiliary variables used by the IMPEC method.
Definition: BulkConn.cpp:227
void AllocateAuxAIMt()
Allocate memory for auxiliary variables used by the AIMt method.
Definition: BulkConn.cpp:2129
void MassConserveIMPEC(Bulk &myBulk, const OCP_DBL &dt) const
Update mole composition of each bulk according to mass conservation for IMPEC.
Definition: BulkConn.cpp:426
void CalResFIM(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in FIM.
Definition: BulkConn.cpp:777
void CalResAIMc(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in FIM.
Definition: BulkConn.cpp:3331
void CalFluxFIM(const Bulk &myBulk)
Calculate flux for FIM, considering upwinding.
Definition: BulkConn.cpp:727
void CalFluxIMPEC(const Bulk &myBulk)
Calculate flux information about flow between bulks for IMPEC.
Definition: BulkConn.cpp:352
void AssembleMat_FIM_new(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Definition: BulkConn.cpp:1002
void AssembleMat_FIM_new_n(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
OCP_NEW_FIMn.
Definition: BulkConn.cpp:1621
void AllocateMat(LinearSystem &myLS) const
Allocate memory for the coefficient matrix.
Definition: BulkConn.cpp:107
void SetupMatSparsityAIMt(LinearSystem &myLS, const Bulk &myBulk) const
Setup sparsity pattern of the coefficient matrix for AIMt.
Definition: BulkConn.cpp:2140
void Reset()
Reset physcial values of the current step with the previous step.
Definition: BulkConn.cpp:137
void CalResAIMt(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Calculate resiual for the Newton iteration in local FIM.
Definition: BulkConn.cpp:2374
void AllocateAuxFIM(const USI &np)
Allocate memory for auxiliary variables used by the FIM method.
Definition: BulkConn.cpp:459
void CalResAIMs(vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt)
Definition: BulkConn.cpp:2477
void AssembleMat_AIMt(LinearSystem &myLS, const Bulk &myBulk, const OCP_DBL &dt) const
Assmeble coefficient matrix for FIM, terms related to bulks only.
Definition: BulkConn.cpp:2158
void AssembleMat_AIMs(LinearSystem &myLS, vector< OCP_DBL > &res, const Bulk &myBulk, const OCP_DBL &dt) const
Definition: BulkConn.cpp:2573
void AllocateAuxAIM(const OCP_DBL &ratio)
Allocate memory for auxiliary variables used for AIMt.
Definition: Bulk.cpp:3138
void InitSjPcComp(const USI &tabrow, const Grid &myGrid)
Calculate initial equilibrium for compositional model according to EQUIL.
Definition: Bulk.cpp:812
USI GetPhaseNum() const
Return the number of phases.
Definition: Bulk.hpp:149
void AllocateWellBulkId(const USI &n)
Allocate memory for WellbulkId.
Definition: Bulk.hpp:209
void ResetPj()
Reset Pj to the ones of the last time step.
Definition: Bulk.hpp:199
void CalRelResAIMs(ResFIM &resFIM) const
Calculate relative resiual for AIMs, parts related to FIM are considered.
Definition: Bulk.cpp:3426
void GetSolIMPEC(const vector< OCP_DBL > &u)
Update P and Pj after linear system is solved.
Definition: Bulk.cpp:2446
void InitFlash(const bool &flag=false)
Perform flash calculation with saturations.
Definition: Bulk.cpp:1280
void FlashAIMc()
Perform flash calculation with Ni.
Definition: Bulk.cpp:3632
bool CheckVe(const OCP_DBL &Vlim) const
Check if relative volume error is out of range, return false if so.
Definition: Bulk.cpp:2160
void AllocateAuxIMPEC()
Allocate memory for auxiliary variables used for IMPEC.
Definition: Bulk.cpp:2417
void CalMaxChange()
Calculate max change of some variables.
Definition: Bulk.cpp:2000
USI GetMixMode() const
Return the mixture mode.
Definition: Bulk.cpp:2270
void UpdateLastStepFIM()
Update values of last step for FIM.
Definition: Bulk.cpp:2999
void FlashDeriv()
Perform flash calculation with Ni and calculate derivatives.
Definition: Bulk.cpp:1401
void ResetNi()
Reset Ni to the ones of the last time step.
Definition: Bulk.hpp:201
void ResetVp()
Reset Vp to the ones of the last time step.
Definition: Bulk.hpp:205
void CalVpore()
Calculate volume of pore with pressure.
Definition: Bulk.cpp:1963
void CalRelResFIM(ResFIM &resFIM) const
Calculate relative resiual for FIM.
Definition: Bulk.cpp:2860
void ResetFIM()
Reset FIM.
Definition: Bulk.cpp:2950
void ResetNt()
Reset Nt to the ones of the last time step.
Definition: Bulk.hpp:194
void CalKrPcDerivAIMc()
Calculate relative permeability and capillary pressure and their derivatives.
Definition: Bulk.cpp:3832
void SetCFL2Zero() const
Initialize the CFL number.
Definition: Bulk.hpp:389
void GetSolAIMt(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
Get the solution for local FIM after a Newton iteration.
Definition: Bulk.cpp:3360
void Flash()
Perform flash calculation with Ni.
Definition: Bulk.cpp:1340
void CalKrPcDeriv()
Calculate relative permeability and capillary pressure and their derivatives.
Definition: Bulk.cpp:1929
void GetSol01FIM(const vector< OCP_DBL > &u)
Get the solution for FIM after a Newton iteration???
Definition: Bulk.cpp:2858
OCP_DBL CalCFL() const
Calculate the CFL number.
Definition: Bulk.cpp:2459
void Setup(const Grid &myGrid)
Allocate memory for bulk data of grid.
Definition: Bulk.cpp:183
void FlashDerivAIM(const bool &IfAIMs)
Perform flash calculation with Ni and calculate derivatives.
Definition: Bulk.cpp:3173
void CalKrPcDerivAIM(const bool &IfAIMs)
Calculate relative permeability and capillary pressure and their derivatives.
Definition: Bulk.cpp:3309
void ResetFlash()
Reset variables in flash calculations.
Definition: Bulk.cpp:1880
void FlashDerivAIMc()
Perform flash calculation with Ni and calculate derivatives.
Definition: Bulk.cpp:3760
void InputParam(ParamReservoir &rs_param)
Input param from internal data structure ParamReservoir.
Definition: Bulk.cpp:24
void CalKrPcAIMc()
Calculate relative permeability and capillary pressure with saturation.
Definition: Bulk.cpp:3817
void CalKrPc()
Calculate relative permeability and capillary pressure with saturation.
Definition: Bulk.cpp:1897
OCP_USI GetBulkNum() const
Return the number of bulks.
Definition: Bulk.hpp:145
void InitSjPcBo(const USI &tabrow)
Calculate initial equilibrium for blkoil model according to EQUIL.
Definition: Bulk.cpp:371
USI GetComNum() const
Return the number of components.
Definition: Bulk.hpp:147
void UpdateLastStepIMPEC()
Update value of last step for IMPEC.
Definition: Bulk.cpp:2485
bool CheckNi()
Check if negative Ni occurs, return false if so.
Definition: Bulk.cpp:2114
void InitFlashDer()
Perform flash calculation with saturations and calculate derivatives.
Definition: Bulk.cpp:1302
void AllocateAuxFIM()
Allocate memory for auxiliary variables used for FIM.
Definition: Bulk.cpp:2522
void GetSolFIM_n(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
Definition: Bulk.cpp:2704
bool CheckP() const
Check if negative P occurs, return false if so.
Definition: Bulk.cpp:2095
void CalRelResAIMt(ResFIM &resFIM) const
Calculate relative resiual for local FIM.
Definition: Bulk.cpp:3331
void GetSolFIM(const vector< OCP_DBL > &u, const OCP_DBL &dPmaxlim, const OCP_DBL &dSmaxlim)
Get the solution for FIM after a Newton iteration.
Definition: Bulk.cpp:2587
void InputParam(const ParamReservoir &rs_param)
Input parameters from the internal param structure.
Definition: Grid.cpp:14
void Setup()
Setup the grid information and calculate the properties.
Definition: Grid.cpp:74
Linear solvers for discrete systems.
void AllocateColMem()
Allocate memory for each matrix row with max possible number of columns.
void AllocateRowMem(const OCP_USI &dimMax, const USI &nb)
Allocate memory for linear system with max possible number of rows.
Pre-processing unit for OpenCAEPoro for reading params from input files.
Definition: ParamRead.hpp:33
ParamWell paramWell
Read the well params.
Definition: ParamRead.hpp:43
ParamReservoir paramRs
Read the reservoir params.
Definition: ParamRead.hpp:42
bool CheckVe(const OCP_DBL &Vlim) const
Check error between Fluids and Pores.
Definition: Reservoir.cpp:124
void AllocateMatIMPEC(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for IMPEC.
Definition: Reservoir.cpp:222
void InitFIM()
Initialize the properties of Reservoir for FIM.
Definition: Reservoir.cpp:308
void ResetWellIMPEC()
Reset Well for IMPEC.
Definition: Reservoir.cpp:249
void AssembleMatAIMs(LinearSystem &myLS, vector< OCP_DBL > &res, const OCP_DBL &dt) const
Assemble Matrix for AIMs.
Definition: Reservoir.cpp:601
void AssembleMatFIM(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for FIM.
Definition: Reservoir.cpp:384
void AllocateAuxAIMt()
Allocate memory for auxiliary variables used for AIMt.
Definition: Reservoir.cpp:517
void UpdateLastStepFIM()
Update value of last step for FIM.
Definition: Reservoir.cpp:365
void AllocateAuxFIM()
Allocate memory for auxiliary variables used for FIM.
Definition: Reservoir.cpp:300
void ResetVal01IMPEC()
Reset Capillary Pressure, Flux for IMPEC.
Definition: Reservoir.cpp:259
void CalKrPc()
Calculate Relative Permeability and Capillary for each Bulk.
Definition: Reservoir.cpp:74
void Setup()
Setup static information for reservoir with input params.
Definition: Reservoir.cpp:28
void UpdateLastStepAIM()
Update value of last step for IMPEC.
Definition: Reservoir.cpp:640
void CalFlashIMPEC()
Calculate Flash For IMPEC.
Definition: Reservoir.cpp:205
void MassConseveIMPEC(const OCP_DBL &dt)
Calculate Ni according to Flux.
Definition: Reservoir.cpp:197
void GetSolutionFIM(const vector< OCP_DBL > &u, const OCP_DBL &dPmax, const OCP_DBL &dSmax)
Definition: Reservoir.cpp:409
void CalFlashDerivAIM(const bool &IfAIMs)
Calculate Flash for local FIM, some derivatives are needed.
Definition: Reservoir.cpp:537
void GetSolutionIMPEC(const vector< OCP_DBL > &u)
Return the Solution to Reservoir Pressure for IMPEC.
Definition: Reservoir.cpp:241
bool CheckNi()
Check if abnormal Pressure occurs.
Definition: Reservoir.cpp:117
void InputParam(ParamRead &param)
Definition: Reservoir.cpp:18
void CalVpore()
Calculate pore of Bulks.
Definition: Reservoir.cpp:67
void PrepareWell()
Calculate Well Properties at the beginning of each time step.
Definition: Reservoir.cpp:46
void AllocateAuxIMPEC()
Allocate memory for auxiliary variables used for IMPEC.
Definition: Reservoir.cpp:142
void InitIMPEC()
Initialize the properties of Reservoir for IMPEC.
Definition: Reservoir.cpp:150
void ResetVal03IMPEC()
Definition: Reservoir.cpp:275
void CalKrPcDerivAIM(const bool &IfAIMs)
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
Definition: Reservoir.cpp:543
void GetSolutionAIMt(const vector< OCP_DBL > &u, const OCP_DBL &dPmax, const OCP_DBL &dSmax)
Definition: Reservoir.cpp:570
void UpdateLastStepIMPEC()
Update value of last step for IMPEC.
Definition: Reservoir.cpp:212
void CalMaxChange()
Calculate Maximum Change of some reference variables for IMPEC.
Definition: Reservoir.cpp:81
void AllocateMatFIM(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for FIM.
Definition: Reservoir.cpp:373
OCP_INT CheckP(const bool &bulkCheck=true, const bool &wellCheck=true)
Check if abnormal Pressure occurs.
Definition: Reservoir.cpp:98
void AssembleMatAIMc(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for AIMc.
Definition: Reservoir.cpp:659
void ResetFIM(const bool &flag)
Reset FIM.
Definition: Reservoir.cpp:471
void CalFlashDerivAIMc()
Calculate Flash for local FIM, some derivatives are needed.
Definition: Reservoir.cpp:699
void CalConnFluxIMPEC()
Calculate flux between bulks.
Definition: Reservoir.cpp:190
void ApplyControl(const USI &i)
Apply the control of ith critical time point.
Definition: Reservoir.cpp:38
void CalWellTrans()
Calculate Trans of Wells.
Definition: Reservoir.cpp:60
void AllocateMatAIMt(LinearSystem &myLS) const
Allocate Maxmimum memory for internal Matirx for local FIM.
Definition: Reservoir.cpp:527
void AllocateAuxAIMc()
Allocate memory for auxiliary variables used for FIM.
Definition: Reservoir.cpp:650
void AssembleMatIMPEC(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for IMPEC.
Definition: Reservoir.cpp:232
void AssembleMatAIMt(LinearSystem &myLS, const OCP_DBL &dt) const
Assemble Matrix for AIMt -— local FIM here.
Definition: Reservoir.cpp:563
void AllocateAuxAIMs()
Allocate memory for auxiliary variables used for AIMs.
Definition: Reservoir.cpp:578
void CalIPRT(const OCP_DBL &dt)
Calculate num of Injection, Production.
Definition: Reservoir.cpp:89
OCP_DBL CalCFL(const OCP_DBL &dt)
Calcluate the CFL number, including bulks and wells for IMPEC.
Definition: Reservoir.cpp:170
void ResetVal02IMPEC()
Reset Capillary Pressure, Moles of Componnets, Flux for IMPEC.
Definition: Reservoir.cpp:266
void CalKrPcDerivAIMc()
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
Definition: Reservoir.cpp:706
void CalKrPcDerivFIM()
Calculate Relative Permeability and Capillary and some derivatives for each Bulk.
Definition: Reservoir.cpp:358
void CalFlashDerivFIM()
Calculate Flash for FIM, some derivatives are needed.
Definition: Reservoir.cpp:344
void CalFLuxIMPEC()
Calculate flux between bulks, bulks and wells.
Definition: Reservoir.cpp:182
void CalResAIMs(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for AIMs, it's also RHS of Linear System.
Definition: Reservoir.cpp:588
void CalResAIMc(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for FIM, it's also RHS of Linear System.
Definition: Reservoir.cpp:668
void CalWellFlux()
Calculate Flux between Bulk and Wells.
Definition: Reservoir.cpp:53
void CalResFIM(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for FIM, it's also RHS of Linear System.
Definition: Reservoir.cpp:434
void CalResAIMt(ResFIM &resFIM, const OCP_DBL &dt)
Calculate the Resiual for local FIM, it's also RHS of Linear System.
Definition: Reservoir.cpp:549