OpenCAEPoro  0.2.0 Sep/22/2022
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

string dir
 Current work directory.
 
string method
 Decide which method to use to discrete the fluid equations.
 
string linearSolve
 Fasp file.
 
vector< TuningPairtuning_T
 Tuning set.
 
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 timestep 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 152 of file ParamControl.cpp.

153 {
154  cout << "---------------------\n";
155  cout << "TUNING" << endl;
156  cout << "---------------------\n";
157  for (auto v : tuning_T) {
158  cout << v.d << endl;
159  for (auto v1 : v.Tuning) {
160  for (auto v2 : v1) {
161  cout << v2 << " ";
162  }
163  cout << "/ " << endl;
164  }
165  }
166 }
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
Decide which method to use to discrete the 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 }

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  if (vbuf[0] == "AIMt") {
111  method = "AIMt";
112  }
113 
114  if (vbuf.size() > 1) linearSolve = vbuf[1];
115 
116 #ifdef DEBUG
117  cout << "METHOD" << endl;
118  cout << method << " " << linearSolve << endl;
119 #endif // DEBUG
120 }
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 123 of file ParamControl.cpp.

124 {
125  assert(criticalTime.size() >= 1);
126 
127  TUNING tmp(tuning);
128  USI d = criticalTime.size() - 1;
129  USI row = 0;
130  vector<string> vbuf;
131 
132  while (ReadLine(ifs, vbuf)) {
133  DealDefault(vbuf);
134  OCP_INT len = vbuf.size();
135 
136  for (OCP_INT i = 0; i < len - 1; i++) {
137  tmp[row][i] = stod(vbuf[i]);
138  }
139  if (vbuf[len - 1] != "/") {
140  tmp[row][len - 1] = stod(vbuf[len - 1]);
141  } else {
142  row++;
143  }
144  if (row == 3) break;
145  }
146 
147  tuning_T.push_back(TuningPair(d, tmp));
148  DisplayTuning();
149 }
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
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 56 of file ParamControl.hpp.

◆ tuning

TUNING ParamControl::tuning

Tuning.

Definition at line 52 of file ParamControl.hpp.


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