OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
ParamRead.cpp
Go to the documentation of this file.
1 
12 #include "ParamRead.hpp"
13 
16 {
17  paramRs.Init();
18  paramWell.Init();
20 }
21 
24 {
25 #if defined(_CONSOLE) || defined(_WIN32) || defined(_WIN64)
26  // for Window file system
27  OCP_INT pos = inputFile.find_last_of('\\') + 1;
28  workDir = inputFile.substr(0, pos);
29  fileName = inputFile.substr(pos, inputFile.size() - pos);
30 #else
31  // for Linux and Mac OSX file system
32  OCP_INT pos = inputFile.find_last_of('/') + 1;
33  workDir = inputFile.substr(0, pos);
34  fileName = inputFile.substr(pos, inputFile.size() - pos);
35 #endif
36 }
37 
39 void ParamRead::ReadInputFile(const string& filename)
40 {
41  inputFile = filename;
42  GetDirAndName();
43  Init();
45  CheckParam();
46 }
47 
49 void ParamRead::ReadFile(const string& filename)
50 {
51  ifstream ifs(filename, ios::in);
52  if (!ifs) {
53  OCP_MESSAGE("Trying to open file: " << (filename));
54  OCP_ABORT("Failed to open the input file!");
55  }
56 
57  while (!ifs.eof()) {
58  vector<string> vbuf;
59  if (!ReadLine(ifs, vbuf)) break;
60  string keyword = vbuf[0];
61 
62  switch (Map_Str2Int(&keyword[0], keyword.size())) {
63  case Map_Str2Int("BLACKOIL", 8):
64  paramRs.blackOil = OCP_TRUE;
65  break;
66 
67  case Map_Str2Int("COMPS", 5):
68  paramRs.InputCOMPS(ifs);
69  break;
70 
71  case Map_Str2Int("THERMAL", 7):
72  paramRs.thermal = OCP_TRUE;
73  paramControl.model = THERMALMODEL;
74  break;
75 
76  case Map_Str2Int("OIL", 3):
77  paramRs.oil = OCP_TRUE;
78  break;
79 
80  case Map_Str2Int("GAS", 3):
81  paramRs.gas = OCP_TRUE;
82  break;
83 
84  case Map_Str2Int("WATER", 5):
85  paramRs.water = OCP_TRUE;
86  break;
87 
88  case Map_Str2Int("DISGAS", 6):
89  paramRs.disGas = OCP_TRUE;
90  break;
91 
92  case Map_Str2Int("DIMENS", 6):
93  paramRs.InputDIMENS(ifs);
94  break;
95 
96  case Map_Str2Int("RTEMP", 5):
97  paramRs.InputRTEMP(ifs);
98  break;
99 
100  case Map_Str2Int("EQUALS", 6):
101  paramRs.InputEQUALS(ifs);
102  break;
103 
104  case Map_Str2Int("DX", 2):
105  case Map_Str2Int("DY", 2):
106  case Map_Str2Int("DZ", 2):
107  case Map_Str2Int("COORD", 5):
108  case Map_Str2Int("ZCORN", 5):
109  case Map_Str2Int("NTG", 3):
110  case Map_Str2Int("PORO", 4):
111  case Map_Str2Int("TOPS", 4):
112  case Map_Str2Int("PERMX", 5):
113  case Map_Str2Int("PERMY", 5):
114  case Map_Str2Int("PERMZ", 5):
115  case Map_Str2Int("PRESSURE", 8):
116  case Map_Str2Int("Ni", 2):
117  case Map_Str2Int("SWATINIT", 8):
118  case Map_Str2Int("THCONR", 6):
119  paramRs.InputGRID(ifs, keyword);
120  break;
121 
122  case Map_Str2Int("COPY", 4):
123  paramRs.InputCOPY(ifs);
124  break;
125 
126  case Map_Str2Int("MULTIPLY", 8):
127  paramRs.InputMULTIPLY(ifs);
128  break;
129 
130  case Map_Str2Int("SWFN", 4):
131  case Map_Str2Int("SWOF", 4):
132  case Map_Str2Int("SGFN", 4):
133  case Map_Str2Int("SGOF", 4):
134  case Map_Str2Int("SOF3", 4):
135  case Map_Str2Int("PVCO", 4):
136  case Map_Str2Int("PVDO", 4):
137  case Map_Str2Int("PVDG", 4):
138  case Map_Str2Int("PVTW", 4):
139  case Map_Str2Int("PBVD", 4):
140  case Map_Str2Int("ZMFVD", 5):
141  case Map_Str2Int("TEMPVD", 6):
142  paramRs.InputTABLE(ifs, keyword);
143  break;
144 
145  case Map_Str2Int("ROCK", 4):
146  paramRs.InputROCK(ifs);
147  break;
148 
149  case Map_Str2Int("ROCKT", 5):
150  paramRs.InputROCKT(ifs);
151  break;
152 
153  case Map_Str2Int("HLOSS", 5):
154  paramRs.InputHLOSS(ifs);
155  break;
156 
157  case Map_Str2Int("MISCIBLE", 8):
158  paramRs.comsParam.miscible = OCP_TRUE;
159  break;
160 
161  case Map_Str2Int("MISCSTR", 7):
162  paramRs.InputMISCSTR(ifs);
163  break;
164 
165  case Map_Str2Int("GRAVITY", 7):
166  paramRs.InputGRAVITY(ifs);
167  break;
168 
169  case Map_Str2Int("DENSITY", 7):
170  paramRs.InputDENSITY(ifs);
171  break;
172 
173  case Map_Str2Int("THCONO", 6):
174  case Map_Str2Int("THCONG", 6):
175  case Map_Str2Int("THCONW", 6):
176  paramRs.InputTHCON(ifs, keyword);
177  break;
178 
179  case Map_Str2Int("EQUIL", 5):
180  paramRs.InputEQUIL(ifs);
181  break;
182 
183  case Map_Str2Int("TABDIMS", 7):
184  paramRs.InputTABDIMS(ifs);
185  break;
186 
187  case Map_Str2Int("SATNUM", 6):
188  case Map_Str2Int("PVTNUM", 6):
189  case Map_Str2Int("ACTNUM", 6):
190  case Map_Str2Int("ROCKNUM", 7):
191  paramRs.InputRegion(ifs, keyword);
192  break;
193 
194  case Map_Str2Int("INCLUDE", 7):
195  ReadINCLUDE(ifs);
196  break;
197 
198  case Map_Str2Int("METHOD", 6):
200  break;
201 
202  case Map_Str2Int("TUNING", 6):
204  break;
205 
206  case Map_Str2Int("WELSPECS", 8):
208  break;
209 
210  case Map_Str2Int("COMPDAT", 7):
211  paramWell.InputCOMPDAT(ifs);
212  break;
213 
214  case Map_Str2Int("WCONINJE", 8):
216  break;
217 
218  case Map_Str2Int("WCONPROD", 8):
220  break;
221 
222  case Map_Str2Int("UNWEIGHT", 8):
224  break;
225 
226  case Map_Str2Int("TSTEP", 5):
227  paramWell.InputTSTEP(ifs);
229  break;
230 
231  case Map_Str2Int("WELTARG", 7):
232  case Map_Str2Int("WELLTARG", 8):
233  paramWell.InputWELTARG(ifs);
234  break;
235 
236  case Map_Str2Int("WTEMP", 5):
237  paramWell.InputWTEMP(ifs);
238  break;
239 
240  case Map_Str2Int("WELLSTRE", 8):
242  break;
243 
244  case Map_Str2Int("PSURF", 5):
245  paramWell.InputPSURF(ifs);
246  break;
247 
248  case Map_Str2Int("TSURF", 5):
249  paramWell.InputTSURF(ifs);
250  break;
251 
252  case Map_Str2Int("SUMMARY", 7):
254  break;
255 
256  case Map_Str2Int("RPTSCHED", 8):
257  case Map_Str2Int("VTKSCHED", 8):
258  paramOutput.InputRPTSCHED(ifs, keyword);
259  break;
260 
261  case Map_Str2Int("CNAMES", 6):
262  paramRs.InputCNAMES(ifs);
263  break;
264 
265  case Map_Str2Int("TCRIT", 5):
266  case Map_Str2Int("PCRIT", 5):
267  case Map_Str2Int("VCRIT", 5):
268  case Map_Str2Int("ZCRIT", 5):
269  case Map_Str2Int("MW", 2):
270  case Map_Str2Int("ACF", 3):
271  case Map_Str2Int("OMEGAA", 6):
272  case Map_Str2Int("OMEGAB", 6):
273  case Map_Str2Int("SSHIFT", 6):
274  case Map_Str2Int("PARACHOR", 8):
275  case Map_Str2Int("VCRITVIS", 8):
276  case Map_Str2Int("MOLDEN", 6):
277  case Map_Str2Int("CP", 2):
278  case Map_Str2Int("CT1", 3):
279  case Map_Str2Int("CT2", 3):
280  case Map_Str2Int("CPT", 3):
281  case Map_Str2Int("CPL1", 4):
282  case Map_Str2Int("CPL2", 4):
283  case Map_Str2Int("CPL3", 4):
284  case Map_Str2Int("CPL4", 4):
285  case Map_Str2Int("CPG1", 4):
286  case Map_Str2Int("CPG2", 4):
287  case Map_Str2Int("CPG3", 4):
288  case Map_Str2Int("CPG4", 4):
289  case Map_Str2Int("HVAPR", 5):
290  case Map_Str2Int("HVR", 3):
291  case Map_Str2Int("EV", 2):
292  case Map_Str2Int("AVSIC", 5):
293  case Map_Str2Int("BVSIC", 5):
294  case Map_Str2Int("AVG", 3):
295  case Map_Str2Int("BVG", 3):
296  paramRs.InputCOMPONENTS(ifs, keyword);
297  break;
298 
299  case Map_Str2Int("PRSR", 4):
300  case Map_Str2Int("TEMR", 4):
301  paramRs.InputRefPR(ifs, keyword);
302  break;
303 
304  case Map_Str2Int("LBCCOEF", 7):
305  paramRs.InputLBCCOEF(ifs);
306  break;
307 
308  case Map_Str2Int("BIC", 3):
309  paramRs.InputBIC(ifs);
310  break;
311 
312  case Map_Str2Int("VISCTAB", 7):
313  paramRs.InputVISCTAB(ifs);
314  break;
315 
316  case Map_Str2Int("SSMSTA", 6):
317  paramRs.InputSSMSTA(ifs);
318  break;
319 
320  case Map_Str2Int("SSMSP", 5):
321  paramRs.InputSSMSP(ifs);
322  break;
323 
324  case Map_Str2Int("NRSTA", 5):
325  paramRs.InputNRSTA(ifs);
326  break;
327 
328  case Map_Str2Int("NRSP", 4):
329  paramRs.InputNRSP(ifs);
330  break;
331 
332  case Map_Str2Int("RR", 2):
333  paramRs.InputRR(ifs);
334  break;
335 
336  default: // skip non-keywords
337  break;
338  }
339  }
340 
341  ifs.close();
342 }
343 
345 void ParamRead::ReadINCLUDE(ifstream& ifs)
346 {
347  vector<string> vbuf;
348  ReadLine(ifs, vbuf);
349  DealDefault(vbuf);
350  ReadFile(workDir + vbuf[0]);
351 }
352 
355 {
356  cout << endl
357  << "=========================================" << endl
358  << "Check reading parameters from input data!" << endl
359  << "=========================================" << endl;
362 }
363 
364 /*----------------------------------------------------------------------------*/
365 /* Brief Change History of This File */
366 /*----------------------------------------------------------------------------*/
367 /* Author Date Actions */
368 /*----------------------------------------------------------------------------*/
369 /* Shizhe Li Oct/01/2021 Create file */
370 /* Chensong Zhang Oct/15/2021 Format file */
371 /* Chensong Zhang Jan/08/2022 Test robustness for wrong keywords */
372 /*----------------------------------------------------------------------------*/
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
ParamRead class declaration.
#define OCP_MESSAGE(msg)
Log error messages.
Definition: UtilError.hpp:28
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
void DealDefault(vector< string > &result)
Definition: UtilInput.cpp:50
OCP_BOOL ReadLine(ifstream &ifs, vector< string > &result)
Definition: UtilInput.cpp:14
constexpr long long Map_Str2Int(const char *mystr, const USI &len)
Definition: UtilInput.hpp:34
vector< OCP_DBL > criticalTime
USI model
model: thermal or isothermal.
void Init(string &indir)
Assign default values to parameters.
void InputTUNING(ifstream &ifs)
Input the Keyword: TUNING.
void InputMETHOD(ifstream &ifs)
Input the Keyword: METHOD.
void InputRPTSCHED(ifstream &ifs, const string &keyword)
void InputSUMMARY(ifstream &ifs)
Definition: ParamOutput.cpp:14
ParamOutput paramOutput
Read the output params.
Definition: ParamRead.hpp:45
ParamWell paramWell
Read the well params.
Definition: ParamRead.hpp:43
void Init()
Initialize the param reading process.
Definition: ParamRead.cpp:15
void GetDirAndName()
Get current work dir and input file name from the full file path.
Definition: ParamRead.cpp:23
void ReadFile(const string &file)
Read the input file.
Definition: ParamRead.cpp:49
void ReadInputFile(const string &file)
General interface for reading input data.
Definition: ParamRead.cpp:39
void ReadINCLUDE(ifstream &ifs)
Handle the INCLUDE keyword, which contains other input files.
Definition: ParamRead.cpp:345
ParamControl paramControl
Read the control params.
Definition: ParamRead.hpp:44
string workDir
Current work directory.
Definition: ParamRead.hpp:36
ParamReservoir paramRs
Read the reservoir params.
Definition: ParamRead.hpp:42
string fileName
File name of input file.
Definition: ParamRead.hpp:37
string inputFile
Input file with its path (absolute or relative).
Definition: ParamRead.hpp:35
void CheckParam()
Check whether the params contain error.
Definition: ParamRead.cpp:354
OCP_BOOL oil
If OCP_TRUE, oil phase could exist.
void InputDIMENS(ifstream &ifs)
TODO: Add Doxygen.
void InputTABDIMS(ifstream &ifs)
TABDIMS contains the num of saturation region and PVT region.
void CheckParam()
Check the reservoir param from input file.
void InputTHCON(ifstream &ifs, const string &keyword)
Input the phase ifThermal conductivity.
ComponentParam comsParam
information for components
void InputGRID(ifstream &ifs, string &keyword)
TODO: Add Doxygen.
void InputMISCSTR(ifstream &ifs)
Input the Miscibility information.
OCP_BOOL gas
If OCP_TRUE, gas phase could exist.
void InputEQUIL(ifstream &ifs)
EQUIL contains initial information of reservoir; see ParamEQUIL.
void InputCOMPS(ifstream &ifs)
TODO: Add Doxygen.
void InputRegion(ifstream &ifs, const string &keyword)
Input the keyword: SATNUM and PVTNUM.
void InputMULTIPLY(ifstream &ifs)
TODO: Add Doxygen.
void Init()
Initialize the default value in reservoir, such as temperature, density, table.
void InputEQUALS(ifstream &ifs)
TODO: Add Doxygen.
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.
OCP_BOOL blackOil
If ture, blackoil model will be used.
void InputDENSITY(ifstream &ifs)
Input the reference density of oil, water, and air in standard condition.
OCP_BOOL disGas
If OCP_TRUE, dissolve gas could exist in oil phase.
void InputCOPY(ifstream &ifs)
Input the keyword: COPY. COPY could copy the value of one variable to another.
void InputHLOSS(ifstream &ifs)
Input heat loss property for overburden rock and underburden rock.
void InputROCKT(ifstream &ifs)
Input Rock information for ifThermal model.
void InputGRAVITY(ifstream &ifs)
Input the reference gravity of oil, water, and air in standard condition.
OCP_BOOL water
If OCP_TRUE, water phase could exist.
OCP_BOOL thermal
If OCP_TRUE, ifThermal model will be used.
void InputRTEMP(ifstream &ifs)
Input the keyword: RTEMP. RTEMP gives the temperature of reservoir.
void InputWTEMP(ifstream &ifs)
Input the temperature of injected fluid.
Definition: ParamWell.cpp:290
void InputWCONPROD(ifstream &ifs)
Definition: ParamWell.cpp:183
void InputPSURF(ifstream &ifs)
Input surface pressure.
Definition: ParamWell.cpp:383
void InputWELLSTRE(ifstream &ifs)
Definition: ParamWell.cpp:373
void InputWELSPECS(ifstream &ifs)
Definition: ParamWell.cpp:68
void InputWELTARG(ifstream &ifs)
Definition: ParamWell.cpp:235
void InputTSTEP(ifstream &ifs)
Definition: ParamWell.cpp:214
void Init()
Initialize the inputting the params of wells.
Definition: ParamWell.hpp:109
vector< OCP_DBL > criticalTime
Records the critical time given by users.
Definition: ParamWell.hpp:103
void InputWCONINJE(ifstream &ifs)
Definition: ParamWell.cpp:148
void InputUNWEIGHT(ifstream &ifs)
Input injector type – MOBWEIGHT(defaulted) or UNWEIGHT.
Definition: ParamWell.cpp:336
void InputTSURF(ifstream &ifs)
Input surface temperature.
Definition: ParamWell.cpp:396
void InputCOMPDAT(ifstream &ifs)
Definition: ParamWell.cpp:80
void CheckParam(const OCP_BOOL &boModel) const
Check if wrong params are input.
Definition: ParamWell.cpp:410