OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
ParamReservoir.cpp
Go to the documentation of this file.
1 
12 #include "ParamReservoir.hpp"
13 
15 vector<OCP_DBL>* ParamReservoir::FindPtr(const string& varName)
16 {
17  vector<OCP_DBL>* myPtr = nullptr;
18 
19  switch (Map_Str2Int(&varName[0], varName.size())) {
20  case Map_Str2Int("DX", 2):
21  dx.reserve(numGrid);
22  myPtr = &dx;
23  break;
24 
25  case Map_Str2Int("DY", 2):
26  dy.reserve(numGrid);
27  myPtr = &dy;
28  break;
29 
30  case Map_Str2Int("DZ", 2):
31  dz.reserve(numGrid);
32  myPtr = &dz;
33  break;
34 
35  case Map_Str2Int("COORD", 5):
36  coord.reserve((dimens.nx + 1) * (dimens.ny + 1) * 6);
37  myPtr = &coord;
38  break;
39 
40  case Map_Str2Int("ZCORN", 5):
41  zcorn.reserve(numGrid * 8);
42  myPtr = &zcorn;
43  break;
44 
45  case Map_Str2Int("PORO", 4):
46  poro.reserve(numGrid);
47  myPtr = &poro;
48  break;
49 
50  case Map_Str2Int("NTG", 3):
51  ntg.reserve(numGrid);
52  myPtr = &ntg;
53  break;
54 
55  case Map_Str2Int("PERMX", 5):
56  permX.reserve(numGrid);
57  myPtr = &permX;
58  break;
59 
60  case Map_Str2Int("PERMY", 5):
61  permY.reserve(numGrid);
62  myPtr = &permY;
63  break;
64 
65  case Map_Str2Int("PERMZ", 5):
66  permZ.reserve(numGrid);
67  myPtr = &permZ;
68  break;
69 
70  case Map_Str2Int("TOPS", 4):
71  tops.reserve(dimens.nx * dimens.ny);
72  myPtr = &tops;
73  break;
74 
75  case Map_Str2Int("PRESSURE", 8):
76  P.reserve(numGrid);
77  myPtr = &P;
78  break;
79 
80  case Map_Str2Int("Ni", 2):
81  Ni.reserve(numGrid);
82  myPtr = &Ni;
83  break;
84 
85  case Map_Str2Int("SWATINIT", 8):
86  Swat.reserve(numGrid);
87  myPtr = &Swat;
88  ScalePcow = true;
89  break;
90 
91  case Map_Str2Int("SATNUM", 6):
92  SATNUM.activity = true;
93  SATNUM.data.reserve(numGrid);
94  myPtr = &SATNUM.data;
95  break;
96 
97  case Map_Str2Int("PVTNUM", 6):
98  PVTNUM.activity = true;
99  PVTNUM.data.reserve(numGrid);
100  myPtr = &PVTNUM.data;
101  break;
102  }
103 
104  return myPtr;
105 }
106 
108 TableSet* ParamReservoir::FindPtr_T(const string& varName)
109 {
110  TableSet* myPtr = nullptr;
111 
112  switch (Map_Str2Int(&varName[0], varName.size()))
113  {
114  case Map_Str2Int("SWFN", 4):
115  myPtr = &SWFN_T;
116  break;
117 
118  case Map_Str2Int("SWOF", 4):
119  myPtr = &SWOF_T;
120  break;
121 
122  case Map_Str2Int("SGFN", 4):
123  myPtr = &SGFN_T;
124  break;
125 
126  case Map_Str2Int("SGOF", 4):
127  myPtr = &SGOF_T;
128  break;
129 
130  case Map_Str2Int("SOF3", 4):
131  myPtr = &SOF3_T;
132  break;
133 
134  case Map_Str2Int("PBVD", 4):
135  myPtr = &PBVD_T;
136  break;
137 
138  case Map_Str2Int("PVCO", 4):
139  myPtr = &PVCO_T;
140  break;
141 
142  case Map_Str2Int("PVDO", 4):
143  myPtr = &PVDO_T;
144  break;
145 
146  case Map_Str2Int("PVDG", 4):
147  myPtr = &PVDG_T;
148  break;
149 
150  case Map_Str2Int("PVTW", 4):
151  myPtr = &PVTW_T;
152  break;
153 
154  case Map_Str2Int("ZMFVD", 5):
155  myPtr = &ZMFVD_T;
156  break;
157  }
158 
159  return myPtr;
160 }
161 
164 {
165  InitTable();
166 
167  gravity.data.resize(3);
168  gravity.data[0] = 45.5; // oil
169  gravity.data[1] = 1.0; // pure water
170  gravity.data[2] = 0.7773; // air
171 
172  density.data.resize(3);
173  density.data[0] = 37.457; // oil
174  density.data[1] = 62.366416; // pure water
175  density.data[2] = 0.062428; // air
176 
177  rsTemp = 60.0;
178  rock.Pref = 14.7;
179  rock.Cr = 3.406E-6;
180 }
181 
184 {
185  SWFN_T.name = "SWFN";
186  SWFN_T.colNum = 3;
187  SWOF_T.name = "SWOF";
188  SWOF_T.colNum = 4;
189  SGFN_T.name = "SGFN";
190  SGFN_T.colNum = 3;
191  SGOF_T.name = "SGOF";
192  SGOF_T.colNum = 4;
193  SOF3_T.name = "SOF3";
194  SOF3_T.colNum = 3;
195  PBVD_T.name = "PBVD";
196  PBVD_T.colNum = 2;
197  PVCO_T.name = "PVCO";
198  PVCO_T.colNum = 6;
199  PVDO_T.name = "PVDO";
200  PVDO_T.colNum = 3;
201  PVDG_T.name = "PVDG";
202  PVDG_T.colNum = 3;
203  PVTW_T.name = "PVTW";
204  PVTW_T.colNum = 5;
205  ZMFVD_T.name = "ZMFVD"; // colnum equals numCom(hydrocarbon) + 1
206 }
207 
209 template <typename T>
210 void ParamReservoir::setVal(vector<T>& obj, const T& val, const vector<USI>& index)
211 {
212  USI Nx = dimens.nx;
213  USI Ny = dimens.ny;
214  OCP_USI NxNy = Nx * Ny;
215  OCP_USI id = 0;
216 
217  for (USI k = index[4]; k <= index[5]; k++) {
218  for (USI j = index[2]; j <= index[3]; j++) {
219  for (USI i = index[0]; i <= index[1]; i++) {
220  id = k * NxNy + j * Nx + i;
221  obj[id] = val;
222  }
223  }
224  }
225 }
226 
228 template <typename T>
229 void ParamReservoir::CopyVal(vector<T>& obj, const vector<T>& src,
230  const vector<USI>& index)
231 {
232  USI Nx = dimens.nx;
233  USI Ny = dimens.ny;
234  OCP_USI NxNy = Nx * Ny;
235  OCP_USI id = 0;
236 
237  for (USI k = index[4]; k <= index[5]; k++) {
238  for (USI j = index[2]; j <= index[3]; j++) {
239  for (USI i = index[0]; i <= index[1]; i++) {
240  id = k * NxNy + j * Nx + i;
241  obj[id] = src[id];
242  }
243  }
244  }
245 }
246 
248 void ParamReservoir::MultiplyVal(vector<OCP_DBL>& obj, const OCP_DBL& val,
249  const vector<USI>& index)
250 {
251  USI Nx = dimens.nx;
252  USI Ny = dimens.ny;
253  OCP_USI NxNy = Nx * Ny;
254  OCP_USI id = 0;
255 
256  for (USI k = index[4]; k <= index[5]; k++) {
257  for (USI j = index[2]; j <= index[3]; j++) {
258  for (USI i = index[0]; i <= index[1]; i++) {
259  id = k * NxNy + j * Nx + i;
260  obj[id] *= val;
261  }
262  }
263  }
264 }
265 
267 void ParamReservoir::InputCOMPS(ifstream& ifs)
268 {
269  comps = true;
270  vector<string> vbuf;
271  ReadLine(ifs, vbuf);
272  numCom = stoi(vbuf[0]);
273  EoSp.numCom = numCom;
274  EoSp.InitEoSparam();
275 
276  cout << "COMPS" << endl << numCom << "\n\n";
277 }
278 
280 void ParamReservoir::InputDIMENS(ifstream& ifs)
281 {
282  vector<string> vbuf;
283  ReadLine(ifs, vbuf);
284  dimens.nx = stoi(vbuf[0]);
285  dimens.ny = stoi(vbuf[1]);
286  dimens.nz = stoi(vbuf[2]);
288 
289  DisplayDIMENS();
290 }
291 
294 {
295  cout << "DIMENS" << endl;
296  cout << dimens.nx << " " << dimens.ny << " " << dimens.nz << "\n\n";;
297 }
298 
300 void ParamReservoir::InputRTEMP(ifstream& ifs)
301 {
302  vector<string> vbuf;
303  ReadLine(ifs, vbuf);
304  if (vbuf[0] == "/") return;
305 
306  rsTemp = stod(vbuf[0]);
307  cout << "RTEMP" << endl;
308  cout << rsTemp << endl;
309 }
310 
312 void ParamReservoir::InputEQUALS(ifstream& ifs)
313 {
314  cout << "EQUALS" << endl;
315 
316  vector<USI> index(6, 0);
317  vector<string> vbuf;
318 
319  while (ReadLine(ifs, vbuf)) {
320  if (vbuf[0] == "/") break;
321 
322  for (auto v : vbuf) { if (v != "/") cout << setw(10) << v; } cout << "\n";;
323 
324  index[0] = 0, index[1] = dimens.nx - 1;
325  index[2] = 0, index[3] = dimens.ny - 1;
326  index[4] = 0, index[5] = dimens.nz - 1;
327 
328  string objName = vbuf[0];
329  OCP_DBL val = stod(vbuf[1]);
330 
331  DealDefault(vbuf);
332 
333  for (USI n = 2; n < 8; n++) {
334  if (vbuf[n] != "DEFAULT") index[n - 2] = stoi(vbuf[n]) - 1;
335  }
336  if (index[0] < 0 || index[2] < 0 || index[4] < 0 || index[1] > dimens.nx - 1 ||
337  index[3] > dimens.ny - 1 || index[5] > dimens.nz - 1) {
338  OCP_ABORT("WRONG Range in " + objName + " in EQUALS!");
339  }
340 
341  vector<OCP_DBL>* objPtr = FindPtr(objName);
342 
343  if (objPtr != nullptr) {
344  if (objName == "TOPS") {
345  objPtr->resize(dimens.nx * dimens.ny);
346  index[4] = index[5] = 0;
347  } else {
348  objPtr->resize(numGrid);
349  }
350  setVal(*objPtr, val, index);
351  } else {
352  OCP_ABORT("Wrong object name: " + objName);
353  }
354  }
355 
356  cout << "/\n\n";
357 }
358 
360 void ParamReservoir::InputGRID(ifstream& ifs, string& keyword)
361 {
362  vector<OCP_DBL>* objPtr = nullptr;
363 
364  objPtr = FindPtr(keyword);
365  if (objPtr == nullptr) {
366  OCP_ABORT("Unknown keyword!");
367  }
368 
369  vector<string> vbuf;
370  while (ReadLine(ifs, vbuf)) {
371  if (vbuf[0] == "/") break;
372 
373  for (auto& str : vbuf) {
374  // if m*n occurs, then push back n m times
375  auto pos = str.find('*');
376  if (pos == string::npos) {
377  objPtr->push_back(stod(str));
378  }
379  else {
380  USI len = str.size();
381  OCP_USI num = stoi(str.substr(0, pos));
382  OCP_DBL val = stod(str.substr(pos + 1, len - (pos + 1)));
383  for (USI i = 0; i < num; i++)
384  objPtr->push_back(val);
385  }
386  }
387  }
388 }
389 
391 void ParamReservoir::InputCOPY(ifstream& ifs)
392 {
393  cout << "COPY" << endl;
394 
395  vector<string> vbuf;
396  vector<USI> index(6, 0);
397 
398  while (ReadLine(ifs, vbuf)) {
399  if (vbuf[0] == "/") break;
400 
401  for (auto v : vbuf) { if (v != "/") cout << setw(10) << v; } cout << "\n";
402 
403  index[0] = 0, index[1] = dimens.nx - 1;
404  index[2] = 0, index[3] = dimens.ny - 1;
405  index[4] = 0, index[5] = dimens.nz - 1;
406 
407  string srcName = vbuf[0];
408  string objName = vbuf[1];
409  DealDefault(vbuf);
410  for (USI n = 2; n < 8; n++) {
411  if (vbuf[n] != "DEFAULT") index[n - 2] = stoi(vbuf[n]) - 1;
412  }
413 
414  vector<OCP_DBL>* srcPtr = FindPtr(srcName);
415  vector<OCP_DBL>* objPtr = FindPtr(objName);
416  if (srcPtr != nullptr && objPtr != nullptr) {
417  objPtr->resize(srcPtr->size());
418  CopyVal(*objPtr, *srcPtr, index);
419  } else {
420  OCP_ABORT("Wrong object names: " + srcName + ", " + objName);
421  }
422  }
423  cout << "/\n\n";
424 }
425 
427 void ParamReservoir::InputMULTIPLY(ifstream& ifs)
428 {
429  vector<string> vbuf;
430  vector<USI> index(6, 0);
431 
432  while (ReadLine(ifs, vbuf)) {
433  if (vbuf[0] == "/") break;
434 
435  index[0] = 0, index[1] = dimens.nx - 1;
436  index[2] = 0, index[3] = dimens.ny - 1;
437  index[4] = 0, index[5] = dimens.nz - 1;
438 
439  string objName = vbuf[0];
440  OCP_DBL val = stod(vbuf[1]);
441 
442  DealDefault(vbuf);
443  for (USI n = 2; n < 8; n++) {
444  if (vbuf[n] != "DEFAULT") index[n - 2] = stoi(vbuf[n]) - 1;
445  }
446 
447  vector<OCP_DBL>* objPtr = FindPtr(objName);
448  if (objPtr != nullptr) {
449  if (objName == "TOPS") {
450  index[4] = index[5] = 0;
451  }
452  MultiplyVal(*objPtr, val, index);
453  } else {
454  OCP_ABORT("Wrong object name: " + objName);
455  }
456  }
457 }
458 
460 void ParamReservoir::InputTABLE(ifstream& ifs, const string& tabName)
461 {
462  TableSet* obj;
463  obj = FindPtr_T(tabName);
464  if (obj == nullptr) {
465  OCP_ABORT("Wrong table name :" + tabName);
466  }
467 
468  USI col = obj->colNum;
469  if (tabName == "ZMFVD") {
470  if (!comps) OCP_ABORT("COMPS isn't set correctly!");
471  obj->colNum = numCom + 1;
472  col = obj->colNum;
473  }
474  vector<vector<OCP_DBL>> tmpTab(col);
475 
476  vector<string> vbuf;
477  while (ReadLine(ifs, vbuf)) {
478  if (vbuf[0] == "/") break;
479 
480  for (USI i = 0; i < col; i++) {
481  tmpTab[i].push_back(stod(vbuf[i]));
482  }
483 
484  if (vbuf.back() == "/") {
485  obj->data.push_back(tmpTab);
486  for (USI j = 0; j < col; j++) {
487  tmpTab[j].clear();
488  }
489  }
490  }
491  if (!tmpTab[0].empty()) obj->data.push_back(tmpTab);
492 
493  obj->DisplayTable();
494 }
495 
497 void ParamReservoir::InputROCK(ifstream& ifs)
498 {
499  vector<string> vbuf;
500  ReadLine(ifs, vbuf);
501  if (vbuf[0] == "/") return;
502 
503  rock.Pref = stod(vbuf[0]);
504  rock.Cr = stod(vbuf[1]);
505 
506  cout << "---------------------" << endl
507  << "ROCK" << endl
508  << "---------------------" << endl;
509  cout << rock.Pref << " " << rock.Cr << endl;
510 }
511 
513 void ParamReservoir::InputMISCSTR(ifstream& ifs)
514 {
515  if (!EoSp.miscible) {
516  OCP_WARNING("MISCIBLE has not been declared, this keyword will be ignored!");
517  }else{
518  vector<string> vbuf;
519  ReadLine(ifs, vbuf);
520  if (vbuf[0] == "/") return;
521  if (vbuf.back() == "/") vbuf.pop_back();
522 
523  USI len = vbuf.size();
524  for (USI i = 0; i < len; i++) {
525  miscstr.surTenRef.push_back(stod(vbuf[i]));
526  }
527  }
528 
529  cout << "MISCSTR" << endl;
530  for (auto& v : miscstr.surTenRef)
531  cout << v << " ";
532  cout << endl << endl;
533 }
534 
536 void ParamReservoir::InputGRAVITY(ifstream& ifs)
537 {
538  gravity.activity = true;
539  vector<string> vbuf;
540  ReadLine(ifs, vbuf);
541  if (vbuf[0] == "/") return;
542  DealDefault(vbuf);
543  OCP_ASSERT(vbuf.size() == 4, "Wrong Keyword GRAVITY!");
544  for (USI i = 0; i < 3; i++) {
545  if (vbuf[i] != "DEFAULT") {
546  gravity.data[i] = stod(vbuf[i]);
547  }
548  }
549 
550  cout << "---------------------" << endl
551  << "GRAVITY" << endl
552  << "---------------------" << endl;
553  cout << gravity.data[0] << " " << gravity.data[1] << " " << gravity.data[2]
554  << endl;
555 }
556 
558 void ParamReservoir::InputDENSITY(ifstream& ifs)
559 {
560  vector<string> vbuf;
561  ReadLine(ifs, vbuf);
562  if (vbuf[0] == "/") return;
563 
564  DealDefault(vbuf);
565  OCP_ASSERT(vbuf.size() == 4, "Wrong Keyword DENSITY!");
566  for (USI i = 0; i < 3; i++) {
567  if (vbuf[i] != "DEFAULT") {
568  density.activity = true;
569  density.data[i] = stod(vbuf[i]);
570  }
571  }
572 
573  cout << "---------------------" << endl
574  << "DENSITY" << endl
575  << "---------------------" << endl;
576  cout << density.data[0] << " " << density.data[1] << " " << density.data[2]
577  << endl;
578 }
579 
581 void ParamReservoir::InputEQUIL(ifstream& ifs)
582 {
583  vector<string> vbuf;
584  ReadLine(ifs, vbuf);
585  if (vbuf[0] == "/") return;
586 
587  EQUIL.resize(6, 0);
588  DealDefault(vbuf);
589  for (USI i = 0; i < 6; i++) {
590  if (vbuf[i] != "DEFAULT") EQUIL[i] = stod(vbuf[i]);
591  }
592 
593  cout << "---------------------" << endl
594  << "EQUIL" << endl
595  << "---------------------" << endl;
596  for (USI i = 0; i < 6; i++) cout << EQUIL[i] << " ";
597  cout << endl;
598 }
599 
601 void ParamReservoir::InputTABDIMS(ifstream& ifs)
602 {
603  vector<string> vbuf;
604  ReadLine(ifs, vbuf);
605  NTSFUN = stoi(vbuf[0]);
606  NTPVT = stoi(vbuf[1]);
607 
608  cout << "TABDIMS" << endl;
609  cout << NTSFUN << " " << NTPVT << "\n\n";
610 }
611 
614 void ParamReservoir::InputRegion(ifstream& ifs, const string& keyword)
615 {
616  Type_A_r<OCP_DBL>* ptr = &PVTNUM;
617  USI lim = NTPVT;
618 
619  if (keyword == "SATNUM") {
620  ptr = &SATNUM;
621  lim = NTSFUN;
622  }
623  else if (keyword == "ACTNUM") {
624  ptr = &ACTNUM;
625  }
626 
627  ptr->activity = true;
628  ptr->data.reserve(numGrid);
629  vector<string> vbuf;
630  vector<OCP_USI> obj;
631  vector<USI> region;
632 
633  while (ReadLine(ifs, vbuf)) {
634  if (vbuf[0] == "/") break;
635 
636  for (auto& str : vbuf) {
637  // if m*n occurs, then push back n m times
638  auto pos = str.find('*');
639  if (pos == string::npos) {
640  ptr->data.push_back(stod(str));
641  }
642  else {
643  USI len = str.size();
644  OCP_USI num = stoi(str.substr(0, pos));
645  OCP_DBL val = stod(str.substr(pos + 1, len - (pos + 1)));
646  for (USI i = 0; i < num; i++)
647  ptr->data.push_back(val);
648  }
649  }
650  }
651 
652  cout << "Number of Tables = " << lim << endl;
653 }
654 
657 {
658  CheckGrid();
659  CheckEQUIL();
660  CheckDenGra();
661  CheckPhase();
662  // CheckPhaseTab();
663  CheckRegion();
664 }
665 
668 {
669  if (coord.size() == 0) {
670  if (tops.size() != dimens.nx * dimens.ny) OCP_ABORT("Wrong TOPS size!");
671  if (dx.size() != numGrid) OCP_ABORT("Wrong DX size!");
672  if (dy.size() != numGrid) OCP_ABORT("Wrong DY size!");
673  if (dz.size() != numGrid) OCP_ABORT("Wrong DZ size!");
674  } else {
675  if (coord.size() != (dimens.nx + 1) * (dimens.ny + 1) * 6)
676  OCP_ABORT("Wrong COORD size!");
677  if (zcorn.size() != numGrid * 8) OCP_ABORT("Wrong ZCORN size!");
678  }
679 
680  if (poro.size() != numGrid) OCP_ABORT("Wrong PORO size!");
681  if (permX.size() != numGrid) OCP_ABORT("Wrong PERMX size!");
682  if (permY.size() != numGrid) OCP_ABORT("Wrong PERMY size!");
683  if (permZ.size() != numGrid) OCP_ABORT("Wrong PERMZ size!");
684  if (ntg.size() != numGrid) {
685  ntg.resize(numGrid, 1);
686  cout << "Reset Ntg size to 1!" << endl;
687  }
688 }
689 
692 {
693  if (EQUIL.empty()) OCP_ABORT("EQUIL is missing!");
694 }
695 
698 {
699  if (density.activity && gravity.activity) {
700  OCP_ABORT("Both DENSITY and GRAVITY have been given, just one can be used!");
701  }
702 }
703 
706 {
707  if (blackOil && disGas && (!gas && !oil)) {
708  OCP_ABORT("DISGAS can only be used only if OIL and GAS are both present!");
709  }
710 }
711 
714 {
715  if (!blackOil && !comps) OCP_ABORT("Unknown model: Use BLACKOIL or COMPS!");
716 
717  if (water && oil && SWOF_T.data.empty()) OCP_ABORT("SWOF is missing!");
718  if (gas && oil && SGOF_T.data.empty()) OCP_ABORT("SGOF is missing!");
719  if (water && PVTW_T.data.empty()) OCP_ABORT("PVTW is missing!");
720 
721  if (blackOil) {
722  if (oil && disGas && PVCO_T.data.empty()) OCP_ABORT("PVCO is missing!");
723  if (oil && (!disGas) && PVDO_T.data.empty()) OCP_ABORT("PVDO is missing!");
724  if (gas && PVDG_T.data.empty()) OCP_ABORT("PVDG is missing!");
725  }
726 }
727 
730 {
731  if (SATNUM.activity && SATNUM.data.size() != numGrid) {
732  OCP_ABORT("Missing data in SATNUM!");
733  }
734  if (PVTNUM.activity && PVTNUM.data.size() != numGrid) {
735  OCP_ABORT("Missing data in PVTNUM!");
736  }
737 }
738 
741 {
742  if (PBVD_T.data.size() > 1) {
743  OCP_ABORT("Only one equilibration region is supported!");
744  }
745 }
746 
749 {
750  cout << "---------------------\n";
751  cout << "TABLE: " << name << "\n";
752  cout << "---------------------\n";
753  for (auto v : data) {
754  const USI len = v[0].size();
755  for (USI i = 0; i < len; i++) {
756  for (USI j = 0; j < colNum; j++) {
757  cout << setw(12) << v[j][i];
758  }
759  cout << "\n";
760  }
761  }
762 }
763 
765 {
766  // Init LBC coefficient
767  LBCcoef.resize(5);
768  LBCcoef[0] = 0.1023;
769  LBCcoef[1] = 0.023364;
770  LBCcoef[2] = 0.058533;
771  LBCcoef[3] = -0.040758;
772  LBCcoef[4] = 0.0093324;
773 }
774 
775 
777 void EoSparam::InputCOM(ifstream& ifs)
778 {
779  OCP_ASSERT(numCom > 0, "Wrong NC!");
780  COM.resize(numCom);
781  USI len = 9;
782 
783  vector<string> vbuf;
784 
785  for (USI c = 0; c < numCom; c++) {
786  COM[c].resize(len);
787  ReadLine(ifs, vbuf);
788  for (USI i = 0; i < len; i++) {
789  COM[c][i] = vbuf[i];
790  }
791  }
792  OCP_FUNCNAME;
793  cout << "Name "
794  << "Pc "
795  << "Tc "
796  << "Acentric "
797  << "MW "
798  << "Vc "
799  << "OmegaA "
800  << "OmegaB "
801  << "Shift" << endl;
802  for (auto& c : COM) {
803  for (auto& item : c) {
804  cout << item << "\t";
805  }
806  cout << endl;
807  }
808  cout << endl;
809 }
810 
812 {
813  Type_A_r<vector<OCP_DBL>>* myPtr = nullptr;
814 
815  switch (Map_Str2Int(&varName[0], varName.size()))
816  {
817  case Map_Str2Int("TCRIT", 5):
818  myPtr = &Tc;
819  break;
820 
821  case Map_Str2Int("PCRIT", 5):
822  myPtr = &Pc;
823  break;
824 
825  case Map_Str2Int("VCRIT", 5):
826  myPtr = &Vc;
827  break;
828 
829  case Map_Str2Int("ZCRIT", 5):
830  myPtr = &Zc;
831  break;
832 
833  case Map_Str2Int("MW", 2):
834  myPtr = &MW;
835  break;
836 
837  case Map_Str2Int("ACF", 3):
838  myPtr = &Acf;
839  break;
840 
841  case Map_Str2Int("OMEGAA", 6):
842  myPtr = &OmegaA;
843  break;
844 
845  case Map_Str2Int("OMEGAB", 6):
846  myPtr = &OmegaB;
847  break;
848 
849  case Map_Str2Int("SSHIFT", 6):
850  myPtr = &Vshift;
851  break;
852 
853  case Map_Str2Int("PARACHOR", 8):
854  myPtr = &Parachor;
855  break;
856 
857  case Map_Str2Int("VCRITVIS", 8):
858  myPtr = &Vcvis;
859  break;
860 
861  case Map_Str2Int("ZCRITVIS", 8):
862  myPtr = &Zcvis;
863  break;
864 
865  }
866 
867  return myPtr;
868 }
869 
870 
871 void EoSparam::InputCOMPONENTS(ifstream& ifs, const string& keyword)
872 {
873  OCP_ASSERT((numCom > 0) && (NTPVT > 0), "NPNC hasn't be input!");
874 
875  Type_A_r<vector<OCP_DBL>>* objPtr = nullptr;
876  objPtr = FindPtr(keyword);
877  if (objPtr == nullptr) {
878  OCP_ABORT("Unknown keyword!");
879  }
880  objPtr->activity = true;
881 
882  vector<string> vbuf;
883  vector<OCP_DBL> tmp;
884  USI nReg = 0;
885 
886  while (true) {
887  ReadLine(ifs, vbuf);
888  if (vbuf[0] == "/") {
889  nReg++;
890  objPtr->data.push_back(tmp);
891  if (nReg >= NTPVT)
892  break;
893  tmp.clear();
894  continue;
895  }
896  for (auto& v : vbuf) {
897  if (v != "/") {
898  tmp.push_back(stod(v));
899  }
900  }
901  if (vbuf.back() == "/") {
902  nReg++;
903  objPtr->data.push_back(tmp);
904  tmp.clear();
905  if (nReg >= NTPVT)
906  break;
907  }
908  }
909 }
910 
911 
912 void EoSparam::InputCNAMES(ifstream& ifs)
913 {
914  OCP_ASSERT(numCom > 0, "NCNP hasn't be input!");
915 
916  vector<string> vbuf;
917  while (true) {
918  ReadLine(ifs, vbuf);
919  if (vbuf[0] == "/") {
920  break;
921  }
922  for (auto& v : vbuf) {
923  if (v != "/")
924  Cname.push_back(v);
925  }
926  if (vbuf.back() == "/")
927  break;
928  }
929 
930  OCP_FUNCNAME;
931  cout << "CNAMES" << endl;
932  for (USI i = 0; i < numCom; i++) {
933  cout << Cname[i] << " ";
934  }
935  cout << endl << endl;
936 }
937 
938 
939 void EoSparam::InputLBCCOEF(ifstream& ifs)
940 {
941  vector<string> vbuf;
942  ReadLine(ifs, vbuf);
943  DealDefault(vbuf);
944  for (USI i = 0; i < 5; i++) {
945  if (vbuf[i] != "DEFAULT")
946  LBCcoef[i] = stod(vbuf[i]);
947  }
948 
949  OCP_FUNCNAME;
950  cout << "LBCCOEF" << endl;
951  for (USI i = 0; i < 5; i++) {
952  cout << LBCcoef[i] << " ";
953  }
954  cout << endl << endl;
955 }
956 
958 void EoSparam::InputBIC(ifstream& ifs)
959 {
960  OCP_ASSERT((numCom > 0) && (NTPVT > 0), "NCNP hasn't been input!");
961 
962  BIC.resize(NTPVT);
963 
964  vector<string> vbuf;
965  USI nReg = 0;
966  while (true) {
967  ReadLine(ifs, vbuf);
968  if (vbuf[0] == "/") {
969  nReg++;
970  if (nReg >= NTPVT)
971  break;
972  continue;
973  }
974  for (auto& v : vbuf) {
975  if (v != "/") {
976  BIC[nReg].push_back(stod(v));
977  cout << setw(10) << BIC[nReg].back();
978  }
979  }
980  cout << endl;
981  if (vbuf.back() == "/") {
982  nReg++;
983  if (nReg >= NTPVT)
984  break;
985  }
986  }
987 }
988 
990 void EoSparam::InputSSMSTA(ifstream& ifs)
991 {
992  vector<string> vbuf;
993  ReadLine(ifs, vbuf);
994  int len = vbuf.size();
995  for (USI i = 0; i < len; i++) {
996  SSMparamSTA.push_back(vbuf[i]);
997  }
998  OCP_FUNCNAME;
999  for (USI i = 0; i < len; i++) {
1000  cout << SSMparamSTA[i] << " ";
1001  }
1002  cout << endl << endl;
1003 }
1004 
1006 void EoSparam::InputNRSTA(ifstream& ifs)
1007 {
1008  vector<string> vbuf;
1009  ReadLine(ifs, vbuf);
1010  for (USI i = 0; i < 2; i++) {
1011  NRparamSTA.push_back(vbuf[i]);
1012  }
1013  OCP_FUNCNAME;
1014  for (USI i = 0; i < 2; i++) {
1015  cout << NRparamSTA[i] << " ";
1016  }
1017  cout << endl << endl;
1018 }
1019 
1021 void EoSparam::InputSSMSP(ifstream& ifs)
1022 {
1023  vector<string> vbuf;
1024  ReadLine(ifs, vbuf);
1025  for (USI i = 0; i < 2; i++) {
1026  SSMparamSP.push_back(vbuf[i]);
1027  }
1028  OCP_FUNCNAME;
1029  for (USI i = 0; i < 2; i++) {
1030  cout << SSMparamSP[i] << " ";
1031  }
1032  cout << endl << endl;
1033 }
1034 
1036 void EoSparam::InputNRSP(ifstream& ifs)
1037 {
1038  vector<string> vbuf;
1039  ReadLine(ifs, vbuf);
1040  for (USI i = 0; i < 2; i++) {
1041  NRparamSP.push_back(vbuf[i]);
1042  }
1043  OCP_FUNCNAME;
1044  for (USI i = 0; i < 2; i++) {
1045  cout << NRparamSP[i] << " ";
1046  }
1047  cout << endl << endl;
1048 }
1049 
1051 void EoSparam::InputRR(ifstream& ifs)
1052 {
1053  vector<string> vbuf;
1054  ReadLine(ifs, vbuf);
1055  for (USI i = 0; i < 2; i++) {
1056  RRparam.push_back(vbuf[i]);
1057  }
1058  OCP_FUNCNAME;
1059  for (USI i = 0; i < 2; i++) {
1060  cout << RRparam[i] << " ";
1061  }
1062  cout << endl << endl;
1063 }
1064 
1065 /*----------------------------------------------------------------------------*/
1066 /* Brief Change History of This File */
1067 /*----------------------------------------------------------------------------*/
1068 /* Author Date Actions */
1069 /*----------------------------------------------------------------------------*/
1070 /* Shizhe Li Oct/01/2021 Create file */
1071 /* Chensong Zhang Oct/15/2021 Format file */
1072 /* Chensong Zhang Jan/09/2022 Update output and Doxygen */
1073 /*----------------------------------------------------------------------------*/
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.
#define OCP_FUNCNAME
Print Function Name.
Definition: UtilError.hpp:73
#define OCP_WARNING(msg)
Log warning messages.
Definition: UtilError.hpp:39
#define OCP_ASSERT(cond, msg)
Assert condition and log user messages in DEBUG mode.
Definition: UtilError.hpp:58
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
void DealDefault(vector< string > &result)
Definition: UtilInput.cpp:50
constexpr long long Map_Str2Int(const char *mystr, const USI &len)
Definition: UtilInput.hpp:34
bool ReadLine(ifstream &ifs, vector< string > &result)
Definition: UtilInput.cpp:14
USI nx
Num of bulks along x-direction.
USI ny
Num of bulks along y-direction.
USI nz
Num of bulks along z-direction.
Type_A_r< vector< OCP_DBL > > Zcvis
Critical Z-factor used for viscosity calculations only.
void InputBIC(ifstream &ifs)
Input the Binary interaction of components.
void InputCNAMES(ifstream &ifs)
Input the names of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > Vcvis
Critical volume used for viscosity calculations only.
Type_A_r< vector< OCP_DBL > > Vshift
Volume shift of hydrocarbon components.
USI numCom
num of components, water is excluded.
void InputSSMSTA(ifstream &ifs)
TODO: Add Doxygen.
vector< OCP_DBL > LBCcoef
LBC coefficients for viscosity calculation.
Type_A_r< vector< OCP_DBL > > MW
Molecular Weight of hydrocarbon components.
void InputCOM(ifstream &ifs)
Input the information of components.
Type_A_r< vector< OCP_DBL > > Acf
Acentric factor of hydrocarbon components.
void InputCOMPONENTS(ifstream &ifs, const string &keyword)
Input the information of hydrocarbon components.
void InputNRSTA(ifstream &ifs)
TODO: Add Doxygen.
void InputNRSP(ifstream &ifs)
TODO: Add Doxygen.
void InputRR(ifstream &ifs)
TODO: Add Doxygen.
vector< string > Cname
Name of hydrocarbon components.
void InitEoSparam()
Init Params.
Type_A_r< vector< OCP_DBL > > OmegaB
OMEGA_B of hydrocarbon components.
vector< vector< string > > COM
Components information.
void InputSSMSP(ifstream &ifs)
TODO: Add Doxygen.
void InputLBCCOEF(ifstream &ifs)
Input LBC coefficients for viscosity calculation.
Type_A_r< vector< OCP_DBL > > Pc
Critical pressure of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > * FindPtr(const string &varName)
Type_A_r< vector< OCP_DBL > > Vc
Critical volume of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > OmegaA
OMEGA_A of hydrocarbon components.
USI NTPVT
num of EoS region, constant now.
vector< vector< OCP_DBL > > BIC
Binary interaction.
Type_A_r< vector< OCP_DBL > > Tc
Critical temperature of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > Parachor
PARACHOR of hydrocarbon components.
Type_A_r< vector< OCP_DBL > > Zc
Critical Z-factor of hydrocarbon components.
bool miscible
Miscible treatment of hydrocarbons, used in compositional Model.
Params for NR in Phase Split.
Definition: MixtureComp.hpp:74
Params for NR in Phase Stability Analysis.
Definition: MixtureComp.hpp:46
vector< OCP_DBL > permY
Permeability along the y-direction for each grid.
void InputDIMENS(ifstream &ifs)
TODO: Add Doxygen.
void CheckEQUIL() const
Check if keyword EQUIL is given.
USI NTSFUN
Num of SAT regions.
bool disGas
If true, dissolve gas could exist in oil phase.
vector< OCP_DBL > Ni
Initial moles of components in each grid.
void InputTABDIMS(ifstream &ifs)
TABDIMS contains the num of saturation region and PVT region.
void CheckParam()
Check the reservoir param from input file.
vector< OCP_DBL > zcorn
TODO: Add Doxygen.
Type_A_r< OCP_DBL > SATNUM
Records the index of SAT region for each grid.
TableSet ZMFVD_T
Table set of ZMFVD.
vector< OCP_DBL > EQUIL
See ParamEQUIL.
Type_A_r< OCP_DBL > ACTNUM
Records the index of Active region for each grid.
vector< OCP_DBL > poro
Porosity for each grid.
void InputGRID(ifstream &ifs, string &keyword)
TODO: Add Doxygen.
TableSet * FindPtr_T(const string &varName)
Find pointer to the specified table.
vector< OCP_DBL > dy
Size along the y - direction for each grid.
vector< OCP_DBL > permX
Permeability along the x - direction for each grid.
void MultiplyVal(vector< OCP_DBL > &obj, const OCP_DBL &val, const vector< USI > &index)
TODO: Add Doxygen.
void CheckPhase() const
Check existence of disgas, it could only exist when both oil and gas exist.
void InputMISCSTR(ifstream &ifs)
Input the Miscibility information.
TableSet PVDG_T
Table set of PVDG.
vector< OCP_DBL > permZ
Permeability along the z-direction for each grid.
bool gas
If true, gas phase could exist.
TableSet SOF3_T
Table set of SOF3.
vector< OCP_DBL > dx
Size along the x - direction for each grid.
TableSet PBVD_T
Table set of PBVD.
bool ScalePcow
whether Pcow should be scaled.
void InputEQUIL(ifstream &ifs)
EQUIL contains initial information of reservoir; see ParamEQUIL.
Type_A_r< OCP_DBL > density
Density of oil, water, gas in standard conditions.
TableSet PVDO_T
Table set of PVDO.
void InputCOMPS(ifstream &ifs)
TODO: Add Doxygen.
vector< OCP_DBL > tops
Depth of the top surface of the uppermost grids.
TableSet SGOF_T
Table set of SGOF.
Type_A_r< OCP_DBL > PVTNUM
Records the index of PVT region for each grid.
USI numCom
Number of components(hydrocarbon components), used in Compositional Model when input.
void CopyVal(vector< T > &obj, const vector< T > &src, const vector< USI > &index)
It's used in InputCOPY, copying the value of one variable to another.
void DisplayDIMENS()
Display the dimens, it's used to chech input.
void InputRegion(ifstream &ifs, const string &keyword)
Input the keyword: SATNUM and PVTNUM.
void InitTable()
Initialize the tables' name and num of colum.
void InputMULTIPLY(ifstream &ifs)
TODO: Add Doxygen.
void CheckEqlRegion() const
(Todo) Initialization of equilibration of only one region is realized.
bool oil
If true, oil phase could exist.
void CheckGrid()
Check the size of properties of grids.
void CheckRegion() const
Check if each grid is assigned to an area or all defaulted.
void Init()
Initialize the default value in reservoir, such as temperature, density, table.
void InputEQUALS(ifstream &ifs)
TODO: Add Doxygen.
vector< OCP_DBL > ntg
Net to gross for each grid.
void InputTABLE(ifstream &ifs, const string &tabName)
Input PVTtable and SATtable such as SWOF, PVCO.
void InputROCK(ifstream &ifs)
Read data from the ROCK keyword.
void CheckPhaseTab() const
Check existence of PVTtable and SATtable.
void InputDENSITY(ifstream &ifs)
Input the reference density of oil, water, and air in standard condition.
TableSet SGFN_T
Table set of SGFN.
vector< OCP_DBL > coord
TODO: Add Doxygen.
Type_A_r< OCP_DBL > gravity
Gravity of oil, water, gas in standard conditions.
void setVal(vector< T > &obj, const T &val, const vector< USI > &index)
It's used in InputEQUALS, assigning values in batches.
void CheckDenGra() const
Check if density and gravity are both input, only one of them is needed.
void InputCOPY(ifstream &ifs)
Input the keyword: COPY. COPY could copy the value of one variable to another.
TableSet PVTW_T
Table set of PVTW.
bool blackOil
If ture, blackoil model will be used.
Dimens dimens
Dimension of grid: the number of grids along x,y,z direction.
vector< OCP_DBL > * FindPtr(const string &varName)
Find pointer to the specified variable.
bool comps
If true, compositional model will be used.
vector< OCP_DBL > dz
Size along the z - direction for each grid.
TableSet SWOF_T
Table set of SWOF.
vector< OCP_DBL > Swat
Initial water saturation in each grid.
void InputGRAVITY(ifstream &ifs)
Input the reference gravity of oil, water, and air in standard condition.
Miscstr miscstr
reference Miscibility surface tension
vector< OCP_DBL > P
Initial pressure of components in each grid.
TableSet PVCO_T
Table set of PVCO.
TableSet SWFN_T
Table set of SWFN.
USI NTPVT
Num of PVT regions.
OCP_DBL rsTemp
Temperature for reservoir.
void InputRTEMP(ifstream &ifs)
Input the keyword: RTEMP. RTEMP gives the temperature of reservoir.
bool water
If true, water phase could exist.
OCP_USI numGrid
Num of grids.
EoSparam EoSp
Initial component composition, used in compositional models.
Param for Solving Rachford-Rice Equations.
Definition: MixtureComp.hpp:87
OCP_DBL Cr
Compressibility factor of rock in reservoir.
OCP_DBL Pref
Reference pressure at initial porosity.
Params for SSM in Phase Split.
Definition: MixtureComp.hpp:60
Params for SSM in Phase Stability Analysis.
Definition: MixtureComp.hpp:29
vector< vector< vector< OCP_DBL > > > data
All table with the same name.
USI colNum
Number of columns of table.
void DisplayTable() const
Print table.
string name
Name of table.
vector< T > data
Data of param.
bool activity
If false, this param is not given.