OpenCAEPoro  0.2.0 Sep/22/2022
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 290 of file ParamRead.cpp.

291 {
292  cout << "=========================================" << endl
293  << "Check reading parameters from input data!" << endl
294  << "=========================================" << endl;
297 }
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.
bool blackOil
If ture, blackoil model will be used.
void CheckParam(const bool &boModel) const
Check if wrong params are input.
Definition: ParamWell.cpp:293

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:25
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:108

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 = 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):
177  paramControl.InputMETHOD(ifs);
178  break;
179 
180  case Map_Str2Int("TUNING", 6):
181  paramControl.InputTUNING(ifs);
182  break;
183 
184  case Map_Str2Int("WELSPECS", 8):
185  paramWell.InputWELSPECS(ifs);
186  break;
187 
188  case Map_Str2Int("COMPDAT", 7):
189  paramWell.InputCOMPDAT(ifs);
190  break;
191 
192  case Map_Str2Int("WCONINJE", 8):
193  paramWell.InputWCONINJE(ifs);
194  break;
195 
196  case Map_Str2Int("WCONPROD", 8):
197  paramWell.InputWCONPROD(ifs);
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):
211  paramWell.InputWELLSTRE(ifs);
212  break;
213 
214  case Map_Str2Int("SUMMARY", 7):
215  paramOutput.InputSUMMARY(ifs);
216  break;
217 
218  case Map_Str2Int("RPTSCHED", 8):
219  paramOutput.InputRPTSCHED(ifs);
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 }
#define OCP_MESSAGE(msg)
Log error messages.
Definition: UtilError.hpp:28
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
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
vector< OCP_DBL > criticalTime
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:281
vector< OCP_DBL > criticalTime
Records the critical time given by users.
Definition: ParamWell.hpp:104

References ParamReservoir::blackOil, ParamControl::criticalTime, ParamWell::criticalTime, ParamReservoir::disGas, ParamReservoir::EoSp, ParamReservoir::gas, ParamWell::InputCOMPDAT(), ParamReservoir::InputCOMPS(), ParamReservoir::InputCOPY(), ParamReservoir::InputDENSITY(), ParamReservoir::InputDIMENS(), ParamReservoir::InputEQUALS(), ParamReservoir::InputEQUIL(), ParamReservoir::InputGRAVITY(), ParamReservoir::InputGRID(), ParamControl::InputMETHOD(), ParamReservoir::InputMISCSTR(), ParamReservoir::InputMULTIPLY(), ParamReservoir::InputRegion(), ParamReservoir::InputROCK(), ParamOutput::InputRPTSCHED(), ParamReservoir::InputRTEMP(), ParamOutput::InputSUMMARY(), ParamReservoir::InputTABDIMS(), ParamReservoir::InputTABLE(), ParamWell::InputTSTEP(), ParamControl::InputTUNING(), ParamWell::InputWCONINJE(), ParamWell::InputWCONPROD(), ParamWell::InputWELLSTRE(), ParamWell::InputWELSPECS(), ParamWell::InputWELTARG(), Map_Str2Int(), EoSparam::miscible, OCP_ABORT, OCP_MESSAGE, ParamReservoir::oil, paramControl, paramOutput, paramRs, paramWell, ReadINCLUDE(), ReadLine(), and ParamReservoir::water.

◆ 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 281 of file ParamRead.cpp.

282 {
283  vector<string> vbuf;
284  ReadLine(ifs, vbuf);
285  DealDefault(vbuf);
286  ReadFile(workDir + vbuf[0]);
287 }
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:290

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


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