OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
Public Member Functions | Public Attributes | List of all members
ParamRead Class Reference

Pre-processing unit for OpenCAEPoro for reading params from input files. More...

#include <ParamRead.hpp>

Public Member Functions

void GetDirAndName ()
 Get current work dir and input file name from the full file path. More...
 
void Init ()
 Initialize the param reading process. More...
 
void ReadInputFile (const string &file)
 General interface for reading input data. More...
 
void ReadFile (const string &file)
 Read the input file. More...
 
void ReadINCLUDE (ifstream &ifs)
 Handle the INCLUDE keyword, which contains other input files. More...
 
void CheckParam ()
 Check whether the params contain error. More...
 

Public Attributes

string inputFile
 Input file with its path (absolute or relative).
 
string workDir
 Current work directory.
 
string fileName
 File name of input file.
 
ParamReservoir paramRs
 Read the reservoir params.
 
ParamWell paramWell
 Read the well params.
 
ParamControl paramControl
 Read the control params.
 
ParamOutput paramOutput
 Read the output params.
 

Detailed Description

Pre-processing unit for OpenCAEPoro for reading params from input files.

Definition at line 32 of file ParamRead.hpp.

Member Function Documentation

◆ CheckParam()

void ParamRead::CheckParam ( )

Check whether the params contain error.

Check parameters in paramRs and paramWell.

Definition at line 354 of file ParamRead.cpp.

355 {
356  cout << endl
357  << "=========================================" << endl
358  << "Check reading parameters from input data!" << endl
359  << "=========================================" << endl;
362 }
ParamWell paramWell
Read the well params.
Definition: ParamRead.hpp:43
ParamReservoir paramRs
Read the reservoir params.
Definition: ParamRead.hpp:42
void CheckParam()
Check the reservoir param from input file.
OCP_BOOL blackOil
If ture, blackoil model will be used.
void CheckParam(const OCP_BOOL &boModel) const
Check if wrong params are input.
Definition: ParamWell.cpp:410

References ParamReservoir::blackOil, ParamReservoir::CheckParam(), ParamWell::CheckParam(), paramRs, and paramWell.

◆ GetDirAndName()

void ParamRead::GetDirAndName ( )

Get current work dir and input file name from the full file path.

Get workDir and fileName from inputFile.

Definition at line 23 of file ParamRead.cpp.

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 }
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
string workDir
Current work directory.
Definition: ParamRead.hpp:36
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

References fileName, inputFile, and workDir.

◆ Init()

void ParamRead::Init ( )

Initialize the param reading process.

Initialize paramRs, paramWell, and paramControl.

Definition at line 15 of file ParamRead.cpp.

16 {
17  paramRs.Init();
18  paramWell.Init();
20 }
void Init(string &indir)
Assign default values to parameters.
ParamControl paramControl
Read the control params.
Definition: ParamRead.hpp:44
void Init()
Initialize the default value in reservoir, such as temperature, density, table.
void Init()
Initialize the inputting the params of wells.
Definition: ParamWell.hpp:109

References ParamReservoir::Init(), ParamWell::Init(), ParamControl::Init(), paramControl, paramRs, paramWell, and workDir.

◆ ReadFile()

void ParamRead::ReadFile ( const string &  file)

Read the input file.

Read parameters from a file, which is called in ReadInputFile.

Definition at line 49 of file ParamRead.cpp.

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):
199  paramControl.InputMETHOD(ifs);
200  break;
201 
202  case Map_Str2Int("TUNING", 6):
203  paramControl.InputTUNING(ifs);
204  break;
205 
206  case Map_Str2Int("WELSPECS", 8):
207  paramWell.InputWELSPECS(ifs);
208  break;
209 
210  case Map_Str2Int("COMPDAT", 7):
211  paramWell.InputCOMPDAT(ifs);
212  break;
213 
214  case Map_Str2Int("WCONINJE", 8):
215  paramWell.InputWCONINJE(ifs);
216  break;
217 
218  case Map_Str2Int("WCONPROD", 8):
219  paramWell.InputWCONPROD(ifs);
220  break;
221 
222  case Map_Str2Int("UNWEIGHT", 8):
223  paramWell.InputUNWEIGHT(ifs);
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):
241  paramWell.InputWELLSTRE(ifs);
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):
253  paramOutput.InputSUMMARY(ifs);
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 }
#define OCP_MESSAGE(msg)
Log error messages.
Definition: UtilError.hpp:28
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
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.
ParamOutput paramOutput
Read the output params.
Definition: ParamRead.hpp:45
void ReadINCLUDE(ifstream &ifs)
Handle the INCLUDE keyword, which contains other input files.
Definition: ParamRead.cpp:345
vector< OCP_DBL > criticalTime
Records the critical time given by users.
Definition: ParamWell.hpp:103

References ParamReservoir::blackOil, Map_Str2Int(), OCP_ABORT, OCP_MESSAGE, paramRs, and ReadLine().

◆ ReadINCLUDE()

void ParamRead::ReadINCLUDE ( ifstream &  ifs)

Handle the INCLUDE keyword, which contains other input files.

Read INCLUDE files; these files should have identical format.

Definition at line 345 of file ParamRead.cpp.

346 {
347  vector<string> vbuf;
348  ReadLine(ifs, vbuf);
349  DealDefault(vbuf);
350  ReadFile(workDir + vbuf[0]);
351 }
void DealDefault(vector< string > &result)
Definition: UtilInput.cpp:50
void ReadFile(const string &file)
Read the input file.
Definition: ParamRead.cpp:49

References DealDefault(), ReadFile(), ReadLine(), and workDir.

◆ ReadInputFile()

void ParamRead::ReadInputFile ( const string &  file)

General interface for reading input data.

This is the general interface for reading input files.

Definition at line 39 of file ParamRead.cpp.

40 {
41  inputFile = filename;
42  GetDirAndName();
43  Init();
45  CheckParam();
46 }
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 CheckParam()
Check whether the params contain error.
Definition: ParamRead.cpp:354

References CheckParam(), GetDirAndName(), Init(), inputFile, and ReadFile().


The documentation for this class was generated from the following files: