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

#include <ParamControl.hpp>

Public Member Functions

void Init (string &indir)
 Assign default values to parameters. More...
 
void InitTime ()
 Init the critical time.
 
void InitMethod ()
 Determine the default discrete method. More...
 
void InitTuning ()
 Determine the default Tuning. More...
 
void InputMETHOD (ifstream &ifs)
 Input the Keyword: METHOD. More...
 
void InputTUNING (ifstream &ifs)
 Input the Keyword: TUNING. More...
 
void DisplayTuning () const
 Display the Tuning. More...
 

Public Attributes

USI model {ISOTHERMALMODEL}
 model: thermal or isothermal.
 
string dir
 Current work directory.
 
string method
 Discretization method for fluid equations.
 
string linearSolve
 Fasp file.
 
vector< TuningPairtuning_T
 Tuning set.
 
TUNING tuning
 Tuning.
 
vector< OCP_DBLcriticalTime
 

Detailed Description

ParamControl contains the param referred to control of simulation, for example, which discrete method will be used, which linear solve file will be used, how will the time step change.

Definition at line 45 of file ParamControl.hpp.

Member Function Documentation

◆ DisplayTuning()

void ParamControl::DisplayTuning ( ) const

Display the Tuning.

Print TUNING parameters.

Definition at line 149 of file ParamControl.cpp.

150 {
151  cout << "\n---------------------" << endl
152  << "TUNING"
153  << "\n---------------------" << endl;
154  for (auto v : tuning_T) {
155  cout << v.d << endl;
156  for (auto v1 : v.Tuning) {
157  for (auto v2 : v1) {
158  cout << v2 << " ";
159  }
160  cout << "/ " << endl;
161  }
162  }
163 }
vector< TuningPair > tuning_T
Tuning set.

References tuning_T.

◆ Init()

void ParamControl::Init ( string &  indir)

Assign default values to parameters.

Initialize control parameters with default values.

Definition at line 15 of file ParamControl.cpp.

16 {
17  dir = indir;
18  InitMethod();
19  InitTime();
20  InitTuning();
21 }
void InitTime()
Init the critical time.
void InitTuning()
Determine the default Tuning.
string dir
Current work directory.
void InitMethod()
Determine the default discrete method.

References dir, InitMethod(), InitTime(), and InitTuning().

◆ InitMethod()

void ParamControl::InitMethod ( )

Determine the default discrete method.

Initialize with default solution method and linear solver.

Definition at line 24 of file ParamControl.cpp.

25 {
26  method = "IMPEC";
27  linearSolve = "./csr.fasp";
28 }
string method
Discretization method for fluid equations.
string linearSolve
Fasp file.

References linearSolve, and method.

◆ InitTuning()

void ParamControl::InitTuning ( )

Determine the default Tuning.

Initialize TUNING parameters.

Definition at line 31 of file ParamControl.cpp.

32 {
33  tuning.resize(3);
34 
35  // Timestepping controls, * means this param is available
36  // Limits: timestep and change factor.
37  tuning[0].resize(10);
38  tuning[0][0] = 1.0; //* Maximum initial time stepsize of next timestep
39  tuning[0][1] = 365.0; //* Maximum length of timesteps after the next
40  tuning[0][2] = 0.1; //* Minimum length of all timesteps
41  tuning[0][3] = 3.0; //* Maximum time stepsize increase factor
42  tuning[0][4] = 0.15; //* Minimum choppable timestep
43  tuning[0][5] = 0.3; //* Factor by which timestep is cut after convergence failure
44  tuning[0][6] = 0.1; // ???
45  tuning[0][7] = 1.25; // Maximum increase factor after a convergence failure
46  tuning[0][8] = (method == "IMPEC") ? 0.2 : 1E20; // ???
47  tuning[0][9] = -1; // Maximum next time stepsize following a well modification
48 
49  // Timestepping controls, * means this param is available
50  // Prediction: an ideal maximum change of variables at next time step.
51  // So they're used to calculate change factor of time step by predicting linearly.
52  tuning[1].resize(13);
53  //* dPlim: ideal maximum Pressure change at next time step.
54  tuning[1][0] = (method == "IMPEC") ? 200.0 : 300.0;
55  //* dSlim: ideal maximum Saturation change at next time step.
56  tuning[1][1] = (method == "IMPEC") ? 0.2 : 0.2;
57  //* dNlim: ideal maximum relative Ni(moles of components) change at next time step.
58  tuning[1][2] = 0.3; // Target material balance error
59  //* dVerrlim: ideal maximum relative Verr(error between fluid and pore) change at
60  // next time step.
61  tuning[1][3] = (method == "IMPEC") ? 1E-3 : 1E-3;
62 
63  tuning[1][4] = 10.0; // Maximum time truncation error
64  // Maximum non-linear convergence error
65  tuning[1][5] = (method == "IMPEC") ? 0.75 : 0.01;
66  tuning[1][6] = 1E-6; // Maximum material balance error
67  // Maximum linear convergence error
68  tuning[1][7] = (method == "IMPEC") ? 1E-4 : 1E-3;
69  tuning[1][8] = 1E-3; // Maximum well flow rate convergence error
70  tuning[1][9] = 0.025; // Target Fluid-in-place error for LGR runs
71  tuning[1][10] = -1; // Target surfactant change (Surfactant Model only)
72  tuning[1][11] = 0.01; // Threshold for damping in ion exchange calc. (Multi-Comp.
73  // Brine Model only)
74  tuning[1][12] = 1; // Weighting factor for active tracer updates
75 
76  // Nonlinear Solver controls, * means this param is available
77  tuning[2].resize(10);
78  //* Maximum number of Newton iterations in a timestep
79  tuning[2][0] = (method == "IMPEC") ? 1 : 10;
80  //* Maximum non-linear convergence error
81  tuning[2][1] = 1e-3;
82  //* Maximum Pressure change in a Newton iteration
83  tuning[2][2] = 200.0;
84  //* Maximum Saturation change in a Newton iteration
85  tuning[2][3] = 0.2;
86  //* Minimum Pressure change in a Newton iteration
87  tuning[2][4] = 1;
88  //* Minimum Saturation change in a Newton iteration
89  tuning[2][5] = 0.01;
90  //* Maximum Verr(error between fluid and pore) change in a Newton iteration
91  tuning[2][6] = 0.01;
92 
93  tuning[2][7] = 1E6; // Maximum saturation change at last Newton iteration
94  // Target maximum pressure change in a timestep
95  tuning[2][8] = (method == "IMPEC") ? 100 : 1E6;
96  tuning[2][9] = -1; // Maximum tolerable pressure change in a timestep
97 }
TUNING tuning
Tuning.

References method, and tuning.

◆ InputMETHOD()

void ParamControl::InputMETHOD ( ifstream &  ifs)

Input the Keyword: METHOD.

Initialize solution method.

Definition at line 100 of file ParamControl.cpp.

101 {
102  vector<string> vbuf;
103  ReadLine(ifs, vbuf);
104  if (vbuf[0] == "/") return;
105 
106  if (vbuf[0] == "FIM") {
107  method = "FIM";
108  linearSolve = "./bsr.fasp";
109  }
110 
111  if (vbuf.size() > 1) linearSolve = vbuf[1];
112 
113  cout << "\n---------------------" << endl
114  << "METHOD"
115  << "\n---------------------" << endl;
116  cout << " " << method << " " << linearSolve << endl;
117 }
OCP_BOOL ReadLine(ifstream &ifs, vector< string > &result)
Definition: UtilInput.cpp:14

References linearSolve, method, and ReadLine().

◆ InputTUNING()

void ParamControl::InputTUNING ( ifstream &  ifs)

Input the Keyword: TUNING.

Read TUNING parameters.

Definition at line 120 of file ParamControl.cpp.

121 {
122  assert(criticalTime.size() >= 1);
123 
124  TUNING tmp(tuning);
125  USI d = criticalTime.size() - 1;
126  USI row = 0;
127  vector<string> vbuf;
128 
129  while (ReadLine(ifs, vbuf)) {
130  DealDefault(vbuf);
131  OCP_INT len = vbuf.size();
132 
133  for (OCP_INT i = 0; i < len - 1; i++) {
134  tmp[row][i] = stod(vbuf[i]);
135  }
136  if (vbuf[len - 1] != "/") {
137  tmp[row][len - 1] = stod(vbuf[len - 1]);
138  } else {
139  row++;
140  }
141  if (row == 3) break;
142  }
143 
144  tuning_T.push_back(TuningPair(d, tmp));
145  DisplayTuning();
146 }
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
vector< vector< OCP_DBL > > TUNING
void DealDefault(vector< string > &result)
Definition: UtilInput.cpp:50
vector< OCP_DBL > criticalTime
void DisplayTuning() const
Display the Tuning.
TODO: Add Doxygen.

References criticalTime, DealDefault(), DisplayTuning(), ReadLine(), tuning, and tuning_T.

Member Data Documentation

◆ criticalTime

vector<OCP_DBL> ParamControl::criticalTime

Critical time records the important time points, at those times, the process of simulation should be carefully treated, for example, the boundary conditions will be changed.

Definition at line 59 of file ParamControl.hpp.


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