OpenCAEPoro  0.2.0 Sep/22/2022
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 = true;
65  break;
66 
67  case Map_Str2Int("COMPS", 5):
68  paramRs.InputCOMPS(ifs);
69  break;
70 
71  case Map_Str2Int("OIL", 3):
72  paramRs.oil = true;
73  break;
74 
75  case Map_Str2Int("GAS", 3):
76  paramRs.gas = true;
77  break;
78 
79  case Map_Str2Int("WATER", 5):
80  paramRs.water = true;
81  break;
82 
83  case Map_Str2Int("DISGAS", 6):
84  paramRs.disGas = true;
85  break;
86 
87  case Map_Str2Int("DIMENS", 6):
88  paramRs.InputDIMENS(ifs);
89  break;
90 
91  case Map_Str2Int("RTEMP", 5):
92  paramRs.InputRTEMP(ifs);
93  break;
94 
95  case Map_Str2Int("EQUALS", 6):
96  paramRs.InputEQUALS(ifs);
97  break;
98 
99  case Map_Str2Int("DX", 2):
100  case Map_Str2Int("DY", 2):
101  case Map_Str2Int("DZ", 2):
102  case Map_Str2Int("COORD", 5):
103  case Map_Str2Int("ZCORN", 5):
104  case Map_Str2Int("NTG", 3):
105  case Map_Str2Int("PORO", 4):
106  case Map_Str2Int("TOPS", 4):
107  case Map_Str2Int("PERMX", 5):
108  case Map_Str2Int("PERMY", 5):
109  case Map_Str2Int("PERMZ", 5):
110  case Map_Str2Int("PRESSURE", 8):
111  case Map_Str2Int("Ni", 2):
112  case Map_Str2Int("SWATINIT", 8):
113  paramRs.InputGRID(ifs, keyword);
114  break;
115 
116  case Map_Str2Int("COPY", 4):
117  paramRs.InputCOPY(ifs);
118  break;
119 
120  case Map_Str2Int("MULTIPLY", 8):
121  paramRs.InputMULTIPLY(ifs);
122  break;
123 
124  case Map_Str2Int("SWFN", 4):
125  case Map_Str2Int("SWOF", 4):
126  case Map_Str2Int("SGFN", 4):
127  case Map_Str2Int("SGOF", 4):
128  case Map_Str2Int("SOF3", 4):
129  case Map_Str2Int("PVCO", 4):
130  case Map_Str2Int("PVDO", 4):
131  case Map_Str2Int("PVDG", 4):
132  case Map_Str2Int("PVTW", 4):
133  case Map_Str2Int("PBVD", 4):
134  case Map_Str2Int("ZMFVD",5):
135  paramRs.InputTABLE(ifs, keyword);
136  break;
137 
138  case Map_Str2Int("ROCK", 4):
139  paramRs.InputROCK(ifs);
140  break;
141 
142  case Map_Str2Int("MISCIBLE", 8):
143  paramRs.EoSp.miscible = true;
144  break;
145 
146  case Map_Str2Int("MISCSTR", 7):
147  paramRs.InputMISCSTR(ifs);
148  break;
149 
150  case Map_Str2Int("GRAVITY", 7):
151  paramRs.InputGRAVITY(ifs);
152  break;
153 
154  case Map_Str2Int("DENSITY", 7):
155  paramRs.InputDENSITY(ifs);
156  break;
157 
158  case Map_Str2Int("EQUIL", 5):
159  paramRs.InputEQUIL(ifs);
160  break;
161 
162  case Map_Str2Int("TABDIMS", 7):
163  paramRs.InputTABDIMS(ifs);
164  break;
165 
166  case Map_Str2Int("SATNUM", 6):
167  case Map_Str2Int("PVTNUM", 6):
168  case Map_Str2Int("ACTNUM", 6):
169  paramRs.InputRegion(ifs, keyword);
170  break;
171 
172  case Map_Str2Int("INCLUDE", 7):
173  ReadINCLUDE(ifs);
174  break;
175 
176  case Map_Str2Int("METHOD", 6):
178  break;
179 
180  case Map_Str2Int("TUNING", 6):
182  break;
183 
184  case Map_Str2Int("WELSPECS", 8):
186  break;
187 
188  case Map_Str2Int("COMPDAT", 7):
189  paramWell.InputCOMPDAT(ifs);
190  break;
191 
192  case Map_Str2Int("WCONINJE", 8):
194  break;
195 
196  case Map_Str2Int("WCONPROD", 8):
198  break;
199 
200  case Map_Str2Int("TSTEP", 5):
201  paramWell.InputTSTEP(ifs);
203  break;
204 
205  case Map_Str2Int("WELTARG", 7):
206  case Map_Str2Int("WELLTARG", 8):
207  paramWell.InputWELTARG(ifs);
208  break;
209 
210  case Map_Str2Int("WELLSTRE", 8):
212  break;
213 
214  case Map_Str2Int("SUMMARY", 7):
216  break;
217 
218  case Map_Str2Int("RPTSCHED", 8):
220  break;
221 
222  case Map_Str2Int("CNAMES", 6):
223  paramRs.InputCNAMES(ifs);
224  break;
225 
226  case Map_Str2Int("COM", 3):
227  paramRs.InputCOM(ifs);
228  break;
229 
230  case Map_Str2Int("TCRIT", 5):
231  case Map_Str2Int("PCRIT", 5):
232  case Map_Str2Int("VCRIT", 5):
233  case Map_Str2Int("ZCRIT", 5):
234  case Map_Str2Int("MW", 2):
235  case Map_Str2Int("ACF", 3):
236  case Map_Str2Int("OMEGAA", 6):
237  case Map_Str2Int("OMEGAB", 6):
238  case Map_Str2Int("SSHIFT", 6):
239  case Map_Str2Int("PARACHOR", 8):
240  case Map_Str2Int("VCRITVIS", 8):
241  paramRs.InputCOMPONENTS(ifs, keyword);
242  break;
243 
244  case Map_Str2Int("LBCCOEF", 7):
245  paramRs.InputLBCCOEF(ifs);
246  break;
247 
248  case Map_Str2Int("BIC", 3):
249  paramRs.InputBIC(ifs);
250  break;
251 
252  case Map_Str2Int("SSMSTA", 6):
253  paramRs.InputSSMSTA(ifs);
254  break;
255 
256  case Map_Str2Int("SSMSP", 5):
257  paramRs.InputSSMSP(ifs);
258  break;
259 
260  case Map_Str2Int("NRSTA", 5):
261  paramRs.InputNRSTA(ifs);
262  break;
263 
264  case Map_Str2Int("NRSP", 4):
265  paramRs.InputNRSP(ifs);
266  break;
267 
268  case Map_Str2Int("RR", 2):
269  paramRs.InputRR(ifs);
270  break;
271 
272  default: // skip non-keywords
273  break;
274  }
275  }
276 
277  ifs.close();
278 }
279 
281 void ParamRead::ReadINCLUDE(ifstream& ifs)
282 {
283  vector<string> vbuf;
284  ReadLine(ifs, vbuf);
285  DealDefault(vbuf);
286  ReadFile(workDir + vbuf[0]);
287 }
288 
291 {
292  cout << "=========================================" << endl
293  << "Check reading parameters from input data!" << endl
294  << "=========================================" << endl;
297 }
298 
299 /*----------------------------------------------------------------------------*/
300 /* Brief Change History of This File */
301 /*----------------------------------------------------------------------------*/
302 /* Author Date Actions */
303 /*----------------------------------------------------------------------------*/
304 /* Shizhe Li Oct/01/2021 Create file */
305 /* Chensong Zhang Oct/15/2021 Format file */
306 /* Chensong Zhang Jan/08/2022 Test robustness for wrong keywords */
307 /*----------------------------------------------------------------------------*/
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
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
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
bool miscible
Miscible treatment of hydrocarbons, used in compositional Model.
vector< OCP_DBL > criticalTime
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)
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:281
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:290
void InputDIMENS(ifstream &ifs)
TODO: Add Doxygen.
bool disGas
If true, dissolve gas could exist in oil phase.
void InputTABDIMS(ifstream &ifs)
TABDIMS contains the num of saturation region and PVT region.
void CheckParam()
Check the reservoir param from input file.
void InputGRID(ifstream &ifs, string &keyword)
TODO: Add Doxygen.
void InputMISCSTR(ifstream &ifs)
Input the Miscibility information.
bool gas
If 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.
bool oil
If true, oil phase could exist.
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.
void InputDENSITY(ifstream &ifs)
Input the reference density of oil, water, and air in standard condition.
void InputCOPY(ifstream &ifs)
Input the keyword: COPY. COPY could copy the value of one variable to another.
bool blackOil
If ture, blackoil model will be used.
void InputGRAVITY(ifstream &ifs)
Input the reference gravity of oil, water, and air in standard condition.
void InputRTEMP(ifstream &ifs)
Input the keyword: RTEMP. RTEMP gives the temperature of reservoir.
bool water
If true, water phase could exist.
EoSparam EoSp
Initial component composition, used in compositional models.
void InputWCONPROD(ifstream &ifs)
Definition: ParamWell.cpp:184
void InputWELLSTRE(ifstream &ifs)
Definition: ParamWell.cpp:282
void InputWELSPECS(ifstream &ifs)
Definition: ParamWell.cpp:69
void InputWELTARG(ifstream &ifs)
Definition: ParamWell.cpp:236
void InputTSTEP(ifstream &ifs)
Definition: ParamWell.cpp:215
void Init()
Initialize the inputting the params of wells.
Definition: ParamWell.hpp:108
void CheckParam(const bool &boModel) const
Check if wrong params are input.
Definition: ParamWell.cpp:293
vector< OCP_DBL > criticalTime
Records the critical time given by users.
Definition: ParamWell.hpp:104
void InputWCONINJE(ifstream &ifs)
Definition: ParamWell.cpp:149
void InputCOMPDAT(ifstream &ifs)
Definition: ParamWell.cpp:81