OpenCAEPoro  v0.5.0
A simulator for multicomponent porous media flow
IsothermalSolver.cpp
Go to the documentation of this file.
1 
12 #include "IsothermalSolver.hpp"
13 
16 {
17  method = ctrl.GetMethod();
18 
19  switch (method) {
20  case IMPEC:
21  impec.Setup(rs, LSolver, ctrl);
22  break;
23  case AIMc:
24  aimc.Setup(rs, LSolver, ctrl);
25  break;
26  case FIMn:
27  fim_n.Setup(rs, LSolver, ctrl);
28  break;
29  case FIM:
30  default:
31  fim.Setup(rs, LSolver, ctrl);
32  break;
33  }
34 }
35 
38 {
39  switch (method) {
40  case IMPEC:
41  impec.InitReservoir(rs);
42  break;
43  case FIM:
44  fim.InitReservoir(rs);
45  break;
46  case FIMn:
47  fim_n.InitReservoir(rs);
48  break;
49  case AIMc:
50  aimc.InitReservoir(rs);
51  break;
52  default:
53  OCP_ABORT("Wrong method type!");
54  }
55 }
56 
59 {
60  switch (method) {
61  case IMPEC:
62  impec.Prepare(rs, ctrl);
63  break;
64  case FIMn:
65  fim_n.Prepare(rs, ctrl.GetCurDt());
66  break;
67  case FIM:
68  fim.Prepare(rs, ctrl.GetCurDt());
69  break;
70  case AIMc:
71  aimc.Prepare(rs, ctrl.GetCurDt());
72  break;
73  default:
74  OCP_ABORT("Wrong method type!");
75  }
76 }
77 
80 {
81  const OCP_DBL dt = ctrl.GetCurDt();
82 
83  GetWallTime timer;
84  timer.Start();
85 
86  switch (method) {
87  case IMPEC:
88  impec.AssembleMat(LSolver, rs, dt);
89  break;
90  case FIMn:
91  fim_n.AssembleMat(LSolver, rs, dt);
92  break;
93  case FIM:
94  fim.AssembleMat(LSolver, rs, dt);
95  break;
96  case AIMc:
97  aimc.AssembleMat(LSolver, rs, dt);
98  break;
99  default:
100  OCP_ABORT("Wrong method type!");
101  }
102 
103  ctrl.RecordTimeAssembleMat(timer.Stop() / 1000);
104 }
105 
108 {
109  switch (method) {
110  case IMPEC:
111  impec.SolveLinearSystem(LSolver, rs, ctrl);
112  break;
113  case FIMn:
114  fim_n.SolveLinearSystem(LSolver, rs, ctrl);
115  break;
116  case FIM:
117  fim.SolveLinearSystem(LSolver, rs, ctrl);
118  break;
119  case AIMc:
120  aimc.SolveLinearSystem(LSolver, rs, ctrl);
121  break;
122  default:
123  OCP_ABORT("Wrong method type!");
124  }
125 }
126 
129 {
130  OCP_BOOL flag;
131 
132  GetWallTime timer;
133  timer.Start();
134 
135  switch (method) {
136  case IMPEC:
137  flag = impec.UpdateProperty(rs, ctrl);
138  break;
139  case FIMn:
140  flag = fim_n.UpdateProperty(rs, ctrl);
141  break;
142  case FIM:
143  flag = fim.UpdateProperty(rs, ctrl);
144  break;
145  case AIMc:
146  flag = aimc.UpdateProperty(rs, ctrl);
147  break;
148  default:
149  OCP_ABORT("Wrong method type!");
150  }
151 
152  ctrl.RecordTimeUpdateProperty(timer.Stop() / 1000);
153 
154  return flag;
155 }
156 
159 {
160  switch (method) {
161  case IMPEC:
162  return impec.FinishNR(rs);
163  case FIMn:
164  return fim_n.FinishNR(rs, ctrl);
165  case FIM:
166  return fim.FinishNR(rs, ctrl);
167  case AIMc:
168  return aimc.FinishNR(rs, ctrl);
169  default:
170  OCP_ABORT("Wrong method type!");
171  }
172 }
173 
176 {
177  switch (method) {
178  case IMPEC:
179  impec.FinishStep(rs, ctrl);
180  break;
181  case FIMn:
182  fim_n.FinishStep(rs, ctrl);
183  break;
184  case FIM:
185  fim.FinishStep(rs, ctrl);
186  break;
187  case AIMc:
188  aimc.FinishStep(rs, ctrl);
189  break;
190  default:
191  OCP_ABORT("Wrong method type!");
192  }
193  ctrl.UpdateIters();
194 }
195 
196 /*----------------------------------------------------------------------------*/
197 /* Brief Change History of This File */
198 /*----------------------------------------------------------------------------*/
199 /* Author Date Actions */
200 /*----------------------------------------------------------------------------*/
201 /* Shizhe Li Oct/21/2021 Create file */
202 /* Chensong Zhang Jan/08/2022 Update Doxygen */
203 /*----------------------------------------------------------------------------*/
IsothermalSolver class declaration.
double OCP_DBL
Double precision.
Definition: OCPConst.hpp:27
const USI FIMn
Solution method = FIM.
Definition: OCPConst.hpp:84
const USI FIM
Solution method = FIM.
Definition: OCPConst.hpp:82
const USI AIMc
Adaptive implicit -— Collins.
Definition: OCPConst.hpp:83
const USI IMPEC
Solution method = IMPEC.
Definition: OCPConst.hpp:81
unsigned int OCP_BOOL
OCP_BOOL in OCP.
Definition: OCPConst.hpp:29
#define OCP_ABORT(msg)
Abort if critical error happens.
Definition: UtilError.hpp:47
Get elapsed wall-time in millisecond.
Definition: UtilTiming.hpp:32
__inline__ double Stop() const
Stop the timer and return duration from start() in ms.
Definition: UtilTiming.hpp:54
__inline__ void Start()
Start the timer.
Definition: UtilTiming.hpp:51
void SolveLinearSystem(LinearSystem &ls, Reservoir &rs, OCPControl &ctrl)
Solve the linear system.
void Setup(Reservoir &rs, LinearSystem &ls, const OCPControl &ctrl)
Setup AIMc.
void AssembleMat(LinearSystem &ls, const Reservoir &rs, const OCP_DBL &dt) const
Assemble Matrix.
OCP_BOOL FinishNR(Reservoir &rs, OCPControl &ctrl)
Finish a Newton-Raphson iteration.
OCP_BOOL UpdateProperty(Reservoir &rs, OCPControl &ctrl)
Update properties of fluids.
void Prepare(Reservoir &rs, const OCP_DBL &dt)
Prepare for Assembling matrix.
void InitReservoir(Reservoir &rs) const
Init.
void FinishStep(Reservoir &rs, OCPControl &ctrl) const
Finish a time step.
void Setup(Reservoir &rs, LinearSystem &ls, const OCPControl &ctrl)
Setup FIM.
void AssembleMat(LinearSystem &ls, const Reservoir &rs, const OCP_DBL &dt) const
Assemble Matrix.
void InitReservoir(Reservoir &rs) const
Init.
OCP_BOOL FinishNR(Reservoir &rs, OCPControl &ctrl)
Finish a Newton-Raphson iteration.
void Prepare(Reservoir &rs, const OCP_DBL &dt)
Prepare for Assembling matrix.
void FinishStep(Reservoir &rs, OCPControl &ctrl)
Finish a time step.
void SolveLinearSystem(LinearSystem &ls, Reservoir &rs, OCPControl &ctrl) const
Solve the linear system.
OCP_BOOL UpdateProperty(Reservoir &rs, OCPControl &ctrl)
Update properties of fluids.
void FinishStep(Reservoir &rs, OCPControl &ctrl) const
Finish a time step.
void Prepare(Reservoir &rs, const OCP_DBL &dt)
Prepare for Assembling matrix.
OCP_BOOL UpdateProperty(Reservoir &rs, OCPControl &ctrl)
Update properties of fluids.
void AssembleMat(LinearSystem &ls, const Reservoir &rs, const OCP_DBL &dt) const
Assemble Matrix.
void Setup(Reservoir &rs, LinearSystem &ls, const OCPControl &ctrl)
Setup FIM.
void InitReservoir(Reservoir &rs) const
Init.
void SolveLinearSystem(LinearSystem &ls, Reservoir &rs, OCPControl &ctrl) const
Solve the linear system.
OCP_BOOL FinishNR(Reservoir &rs, OCPControl &ctrl)
Finish a Newton-Raphson iteration.
void Prepare(Reservoir &rs, OCPControl &ctrl)
Prepare for Assembling matrix.
void SolveLinearSystem(LinearSystem &ls, Reservoir &rs, OCPControl &ctrl)
Solve the linear system.
void AssembleMat(LinearSystem &ls, const Reservoir &rs, const OCP_DBL &dt) const
Assemble Matrix.
void Setup(Reservoir &rs, LinearSystem &ls, const OCPControl &ctrl)
Setup IMPEC.
OCP_BOOL UpdateProperty(Reservoir &rs, OCPControl &ctrl)
Update properties of fluids.
OCP_BOOL FinishNR(const Reservoir &rs)
Determine if NR iteration finishes.
void InitReservoir(Reservoir &rs) const
Init.
void SolveLinearSystem(Reservoir &rs, OCPControl &ctrl)
Solve the linear system in single problem.
void InitReservoir(Reservoir &rs) const
Initialize the Reservoir and prepare variables for some method.
OCP_BOOL UpdateProperty(Reservoir &rs, OCPControl &ctrl)
Update properties of fluid.
void SetupMethod(Reservoir &rs, const OCPControl &ctrl)
Setup the fluid solver.
void FinishStep(Reservoir &rs, OCPControl &ctrl)
Finish the current time step.
void Prepare(Reservoir &rs, OCPControl &ctrl)
Prepare for assembling Mat.
void AssembleMat(const Reservoir &rs, OCPControl &ctrl)
Assemble Mat.
OCP_BOOL FinishNR(Reservoir &rs, OCPControl &ctrl)
Finish the Newton-Raphson iteration.
All control parameters except for well controllers.
Definition: OCPControl.hpp:94
OCP_DBL GetCurDt() const
Return current time step size.
Definition: OCPControl.hpp:133
void UpdateIters()
Update the number of iterations.
Definition: OCPControl.cpp:225
void RecordTimeUpdateProperty(const OCP_DBL &t)
Record time used for update property.
Definition: OCPControl.hpp:169
void RecordTimeAssembleMat(const OCP_DBL &t)
Record time used for assemble matrix.
Definition: OCPControl.hpp:166
USI GetMethod() const
Return type of the solution method.
Definition: OCPControl.hpp:124