ECOGEN 6.0
Evolutive, Compressible, Open, Genuine, Easy, N-phase
Loading...
Searching...
No Matches
Tools.h
Go to the documentation of this file.
1//
2// ,---. ,--, .---. ,--, ,---. .-. .-.
3// | .-' .' .') / .-. ) .' .' | .-' | \| |
4// | `-. | |(_) | | |(_) | | __ | `-. | | |
5// | .-' \ \ | | | | \ \ ( _) | .-' | |\ |
6// | `--. \ `-. \ `-' / \ `-) ) | `--. | | |)|
7// /( __.' \____\ )---' )\____/ /( __.' /( (_)
8// (__) (_) (__) (__) (__)
9// Official webSite: https://code-mphi.github.io/ECOGEN/
10//
11// This file is part of ECOGEN.
12//
13// ECOGEN is the legal property of its developers, whose names
14// are listed in the copyright file included with this source
15// distribution.
16//
17// ECOGEN is free software: you can redistribute it and/or modify
18// it under the terms of the GNU General Public License as published
19// by the Free Software Foundation, either version 3 of the License,
20// or (at your option) any later version.
21//
22// ECOGEN is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25// GNU General Public License for more details.
26//
27// You should have received a copy of the GNU General Public License
28// along with ECOGEN (file LICENSE).
29// If not, see <http://www.gnu.org/licenses/>.
30
31#ifndef TOOLS_H
32#define TOOLS_H
33
34#include "Eos/Eos.h"
35
36//#define DEBUG
37
46
48enum Axis
49{
53};
54
62
65{
69};
70
79
87
103
114
122
125{
126 U = 0,
127 P = 1,
128 PT = 2,
130};
131
134{
137};
138
141{
142 LIQ = 0,
143 VAP = 1
144};
145
148{
151};
152
155{
156 NONE = 0,
159};
160
185
192
194template <class Type> using TypeMeshContainer = std::vector<Type>;
195
197template <typename T> int sign(T val) { return (val < T(0)) ? -1 : 1; } //This sign function can take the value -1 or 1
198// template <typename T> int sign(T val) { return (T(0) < val) - (val < T(0)); } //This sign function can take the value -1, 1 or 0
199
201template <class T> inline void destroy(T*& p)
202{
203 delete p;
204 p = nullptr;
205}
206
208template <class T> inline void destroy_array(T*& p)
209{
210 delete[] p;
211 p = nullptr;
212}
213
216class Tools
217{
218 public:
223 Tools(const int& numbPhases, const int& numbSolids, const int& numbTransports);
224 ~Tools();
225
228 static void uppercase(std::string& string);
229
232 static void lowercase(std::string& string);
233
237 static void swap(double& a, double& b);
238
241 double returnNonZeroValue(double a);
242
243 std::vector<double> ak;
244 std::vector<double> Yk;
245 std::vector<double> rhok;
246 std::vector<double> pk;
247 std::vector<double> ek;
248 std::vector<double> Ek;
249 std::vector<double> akS;
250 std::vector<double> rhokS;
251 std::vector<double> rhokStar;
252 std::vector<double> pkStar;
253 std::vector<double> ekStar;
254 std::vector<double> EkStar;
255 std::vector<double> vkStar;
256 std::vector<double> YkStar;
257 std::vector<double> Deltapk;
258 std::vector<double> zk;
259 std::vector<double> rho_cIksquare;
260 std::vector<Eos*> eos;
261 std::vector<double> Hk0;
262 std::vector<double> Yk0;
263 std::vector<double> compactionPk_dkappadxi;
264 std::vector<double> compactionPk_dkappadalpha;
265 std::vector<double> dlambda;
266 std::vector<Tensor> dplast;
267 std::vector<Tensor> LogCobase;
268 std::vector<double> LogLambda;
269 std::vector<bool> alphaNull;
270 std::vector<bool> relaxSolidPlast;
271
272 //Variables for RK45 solver (visco-plastic relaxation)
273 std::vector<double> ak4;
274 std::vector<double> ak5;
275 std::vector<double> ek4;
276 std::vector<double> ek5;
277 std::vector<Tensor> LogCobase4;
278 std::vector<Tensor> LogCobase5;
279 std::vector<double> LogLambda4;
280 std::vector<double> LogLambda5;
281 std::vector<Tensor> dLogCobaseDt1;
282 std::vector<Tensor> dLogCobaseDt2;
283 std::vector<Tensor> dLogCobaseDt3;
284 std::vector<Tensor> dLogCobaseDt4;
285 std::vector<Tensor> dLogCobaseDt5;
286 std::vector<Tensor> dLogCobaseDt6;
287 std::vector<double> dLogLambdaDt1;
288 std::vector<double> dLogLambdaDt2;
289 std::vector<double> dLogLambdaDt3;
290 std::vector<double> dLogLambdaDt4;
291 std::vector<double> dLogLambdaDt5;
292 std::vector<double> dLogLambdaDt6;
293 std::vector<double> dakDt1;
294 std::vector<double> dakDt2;
295 std::vector<double> dakDt3;
296 std::vector<double> dakDt4;
297 std::vector<double> dakDt5;
298 std::vector<double> dakDt6;
299 std::vector<double> dekDt1;
300 std::vector<double> dekDt2;
301 std::vector<double> dekDt3;
302 std::vector<double> dekDt4;
303 std::vector<double> dekDt5;
304 std::vector<double> dekDt6;
305
306 static double uselessDouble;
308};
309
310extern Tools* TB;
312extern int numberPhases;
313extern int numberSolids;
314extern int numberTransports;
315extern bool turbulenceActivated;
316extern int turbulenceNumQPA;
317extern double sum_u2v2w2;
318extern long nCells;
319extern double initialSoundSpeed;
320extern double initialConductivity;
321extern double initialViscosity;
322
323#endif // TOOLS_H
int numberSolids
Definition Cell.cpp:34
int numberTransports
Definition Cell.cpp:35
int numberPhases
Definition Cell.cpp:33
Tools * TB
Definition Tools.cpp:33
SimulationOrder simulationOrder
Precision of the scheme (first order or second order).
Definition Tools.cpp:35
bool turbulenceActivated
Definition Tools.cpp:36
double initialViscosity
Definition Tools.cpp:42
double initialConductivity
Definition Tools.cpp:41
long nCells
Definition Tools.cpp:39
int turbulenceNumQPA
Definition Tools.cpp:37
double sum_u2v2w2
Definition Tools.cpp:38
double initialSoundSpeed
Definition Tools.cpp:40
TypeOutput
Enumeration for the type of output (GNU, VTK, VTKDF).
Definition Tools.h:57
@ VTK
Definition Tools.h:59
@ VTKHDF
Definition Tools.h:60
@ GNU
Definition Tools.h:58
TypeM
Enumeration for the type of mesh (REC: rectilinear, UNS: unstructured, AMR: adaptative mesh refinemen...
Definition Tools.h:65
@ AMR
Definition Tools.h:68
@ REC
Definition Tools.h:66
@ UNS
Definition Tools.h:67
void destroy(T *&p)
Template for deallocation with pointer zeroing.
Definition Tools.h:201
TypeData
Enumeration for the type of data (FLOAT, DOUBLE, INT, CHAR).
Definition Tools.h:73
@ DOUBLE
Definition Tools.h:75
@ CHAR
Definition Tools.h:77
@ FLOAT
Definition Tools.h:74
@ INT
Definition Tools.h:76
Prim
Enumeration for the primitive-variable type (usefull for second order, slopes, etc....
Definition Tools.h:40
@ vecPhases
Definition Tools.h:41
@ vecSlopes
Definition Tools.h:43
@ vecPhasesO2
Definition Tools.h:42
@ resume
Definition Tools.h:44
TypeBC
Enumeration for the type of boundary.
Definition Tools.h:90
@ NULLFLUX
Definition Tools.h:98
@ MOVINGWALL
Definition Tools.h:101
@ NONREFLECTING
Definition Tools.h:91
@ INLETINJTEMP
Definition Tools.h:97
@ INLETINJSTAGSTATE
Definition Tools.h:94
@ OUTLETMASSFLOW
Definition Tools.h:99
@ INLETTANK
Definition Tools.h:95
@ OUTLETPRESSURE
Definition Tools.h:93
@ SYMMETRY
Definition Tools.h:96
@ PERIODIC
Definition Tools.h:100
@ WALL
Definition Tools.h:92
TypeContactAreas
Enumeration for the type of contact areas for the DEM.
Definition Tools.h:188
@ nonsymmetric
Definition Tools.h:190
@ symmetric
Definition Tools.h:189
TypeGrad
Enumeration for the gradient method (Finite-Difference (FD), Green-Gauss (GG)).
Definition Tools.h:134
@ GG
Definition Tools.h:136
@ FD
Definition Tools.h:135
TypeGO
Enumeration for the type of geometric object (VERTEX, LINE, PLAN).
Definition Tools.h:82
@ VERTEX
Definition Tools.h:83
@ PLAN
Definition Tools.h:85
@ LINE
Definition Tools.h:84
LimiterType
Enumeration for the type of second order limiter (NS only).
Definition Tools.h:155
@ SUPERBEE
Definition Tools.h:158
@ MINMOD
Definition Tools.h:157
@ NONE
Definition Tools.h:156
int sign(T val)
Template for type-safe sign function.
Definition Tools.h:197
std::vector< Type > TypeMeshContainer
Template for the type of the mesh container (std::list for now, but may change to something else if w...
Definition Tools.h:194
SimulationOrder
Enumeration for the scheme order of the simulation.
Definition Tools.h:148
@ first
Definition Tools.h:149
@ second
Definition Tools.h:150
void destroy_array(T *&p)
Template for deallocation with pointer zeroing.
Definition Tools.h:208
TypeRelax
Enumeration for the type of relaxation (P, PT, PTMu).
Definition Tools.h:125
@ PTMU
Definition Tools.h:129
@ P
Definition Tools.h:127
@ PT
Definition Tools.h:128
@ U
Definition Tools.h:126
VarBoundary
Enumeration for the variable to extract on a boundary.
Definition Tools.h:106
@ velU
Definition Tools.h:109
@ p
Definition Tools.h:107
@ velW
Definition Tools.h:111
@ SIZE
Definition Tools.h:112
@ rho
Definition Tools.h:108
@ velV
Definition Tools.h:110
Variable
Enumeration for the flow variables.
Definition Tools.h:163
@ cobaseXZ
Definition Tools.h:177
@ cobaseZX
Definition Tools.h:181
@ velocityV
Definition Tools.h:170
@ QPA
Definition Tools.h:173
@ cobaseZY
Definition Tools.h:182
@ cobaseYX
Definition Tools.h:178
@ alpha
Definition Tools.h:167
@ density
Definition Tools.h:166
@ cobaseYY
Definition Tools.h:179
@ cobaseXY
Definition Tools.h:176
@ cobaseZZ
Definition Tools.h:183
@ velocityW
Definition Tools.h:171
@ transport
Definition Tools.h:164
@ lambda
Definition Tools.h:174
@ velocityU
Definition Tools.h:169
@ cobaseYZ
Definition Tools.h:180
@ cobaseXX
Definition Tools.h:175
@ pressure
Definition Tools.h:165
@ temperature
Definition Tools.h:172
@ velocityMag
Definition Tools.h:168
Axis
Enumeration for the axes (X, Y and Z for the axes in the x-, y- and z-direction).
Definition Tools.h:49
@ Y
Definition Tools.h:51
@ X
Definition Tools.h:50
@ Z
Definition Tools.h:52
TypeBCHeat
Enumeration for the heat type of wall boundary (ADIABATIC, IMPOSEDTEMP, IMPOSEDFLUX).
Definition Tools.h:117
@ IMPOSEDTEMP
Definition Tools.h:119
@ IMPOSEDFLUX
Definition Tools.h:120
@ ADIABATIC
Definition Tools.h:118
PhaseType
Enumeration for the phase index of a liquid/vapor couple.
Definition Tools.h:141
@ VAP
Definition Tools.h:143
@ LIQ
Definition Tools.h:142
Class for tools.
Definition Tools.h:217
static void swap(double &a, double &b)
Swap two numbers.
Definition Tools.cpp:148
std::vector< double > dLogLambdaDt5
Definition Tools.h:291
std::vector< Tensor > dLogCobaseDt5
Definition Tools.h:285
std::vector< double > ek
Definition Tools.h:247
std::vector< bool > relaxSolidPlast
Parameter to know if we need the solid plastic relaxation.
Definition Tools.h:270
~Tools()
Definition Tools.cpp:126
std::vector< Tensor > dplast
Plastic shear term, one for each phase.
Definition Tools.h:266
static void uppercase(std::string &string)
Modify the string of characters to uppercase it.
Definition Tools.cpp:130
std::vector< Tensor > dLogCobaseDt1
Definition Tools.h:281
std::vector< double > ek5
Definition Tools.h:276
std::vector< double > YkStar
Definition Tools.h:256
std::vector< double > dekDt2
Definition Tools.h:300
std::vector< double > dLogLambdaDt2
Definition Tools.h:288
std::vector< double > Yk0
Definition Tools.h:262
static double uselessDouble
Definition Tools.h:306
std::vector< Tensor > dLogCobaseDt4
Definition Tools.h:284
std::vector< double > Deltapk
Pressure differences, one for each phase.
Definition Tools.h:257
Tools(const int &numbPhases, const int &numbSolids, const int &numbTransports)
Generic model constructor.
Definition Tools.cpp:46
std::vector< double > dakDt1
Definition Tools.h:293
std::vector< double > Hk0
Definition Tools.h:261
std::vector< double > dekDt6
Definition Tools.h:304
std::vector< double > LogLambda5
Log of lambda.
Definition Tools.h:280
std::vector< double > ek4
Definition Tools.h:275
std::vector< double > akS
Definition Tools.h:249
std::vector< double > pkStar
Definition Tools.h:252
std::vector< Tensor > dLogCobaseDt3
Definition Tools.h:283
std::vector< double > dakDt4
Definition Tools.h:296
std::vector< double > dLogLambdaDt4
Definition Tools.h:290
std::vector< double > dakDt2
Definition Tools.h:294
std::vector< double > LogLambda
Log of lambda.
Definition Tools.h:268
std::vector< double > dlambda
Plastic compaction term, one for each phase.
Definition Tools.h:265
std::vector< double > dakDt3
Definition Tools.h:295
std::vector< Tensor > dLogCobaseDt2
Definition Tools.h:282
std::vector< double > Ek
Definition Tools.h:248
std::vector< double > rhokStar
Definition Tools.h:251
std::vector< bool > alphaNull
Parameter to know if we consider the volume fraction as null or not.
Definition Tools.h:269
std::vector< double > dakDt5
Definition Tools.h:297
std::vector< double > dakDt6
Definition Tools.h:298
std::vector< double > dLogLambdaDt3
Definition Tools.h:289
std::vector< double > ekStar
Definition Tools.h:253
std::vector< double > dLogLambdaDt1
Definition Tools.h:287
std::vector< Tensor > LogCobase4
Log of the cobase.
Definition Tools.h:277
std::vector< double > dekDt1
Definition Tools.h:299
std::vector< double > rhok
Definition Tools.h:245
std::vector< double > dekDt3
Definition Tools.h:301
std::vector< double > zk
Acoustic impedance of each phase.
Definition Tools.h:258
std::vector< double > compactionPk_dkappadxi
Compaction pressure including the term d kappa_k / d xi_k, one for each phase.
Definition Tools.h:263
std::vector< Tensor > LogCobase
Log of the cobase.
Definition Tools.h:267
std::vector< double > Yk
Definition Tools.h:244
std::vector< double > pk
Definition Tools.h:246
std::vector< Tensor > LogCobase5
Log of the cobase.
Definition Tools.h:278
std::vector< double > vkStar
Definition Tools.h:255
double returnNonZeroValue(double a)
Return a non-zero value of a float.
Definition Tools.cpp:157
std::vector< double > dekDt5
Definition Tools.h:303
std::vector< double > EkStar
Definition Tools.h:254
std::vector< double > dLogLambdaDt6
Definition Tools.h:292
std::vector< double > ak5
Definition Tools.h:274
std::vector< double > ak4
Definition Tools.h:273
std::vector< Eos * > eos
Definition Tools.h:260
std::vector< double > rhokS
Definition Tools.h:250
std::vector< double > LogLambda4
Log of lambda.
Definition Tools.h:279
double physicalTime
Current physical time.
Definition Tools.h:307
static void lowercase(std::string &string)
Modify the string of characters to lowercase it.
Definition Tools.cpp:139
std::vector< double > rho_cIksquare
Density times interface sound speed square, one for each phase.
Definition Tools.h:259
std::vector< Tensor > dLogCobaseDt6
Definition Tools.h:286
std::vector< double > dekDt4
Definition Tools.h:302
std::vector< double > compactionPk_dkappadalpha
Compaction pressure including the term d kappa_k / d alpha_k, one for each phase.
Definition Tools.h:264
std::vector< double > ak
Definition Tools.h:243