-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransportEquation.hxx
executable file
·262 lines (230 loc) · 9.65 KB
/
TransportEquation.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
//============================================================================
/**
* \file TransportEquation.hxx
* \author Michael NDJINGA
* \version 1.0
* \date 24 March 2015
* \brief Fluid enthalpy transport equation
* */
//============================================================================
/*! \class TransportEquation TransportEquation.hxx "TransportEquation.hxx"
* \brief Scalar advection equation for a fluid enthalpy
* \details see \ref TransportEqPage for more details
*/
#ifndef TransportEquation_HXX_
#define TransportEquation_HXX_
#include "ProblemCoreFlows.hxx"
using namespace std;
//! enumeration BoundaryType
/*! Boundary condition type */
enum BoundaryTypeTransport {InletTransport, OutletTransport, NeumannTransport, DirichletTransport, NoneBCTransport};//Actually Inlet=Dirichlet and Outlet=Neumann
//! enumeration phaseType
/*! The material phase can be Solid, Gas or liquid */
enum FluidMaterial
{
Air,/**< Material considered is air */
Water/**< Material considered is water */
};
/** \struct LimitField
* \brief value of some fields on the boundary */
struct LimitFieldTransport{
LimitFieldTransport(){bcType=NoneBCTransport; T=0; h=0; flux=0; }
LimitFieldTransport(BoundaryTypeTransport _bcType, double _T, double _h,double _flux ){
bcType=_bcType; T=_T; h=_h; flux=_flux;
}
BoundaryTypeTransport bcType;
double T; //for inlet or Dirichlet
double h; //for inlet or Dirichlet
double flux; //for Neumann or outlet
};
class TransportEquation: public ProblemCoreFlows
{
public :
/** \fn TransportEquation
* \brief Constructor for the enthalpy transport in a fluid
* \param [in] phase : \ref Liquid or \ref Gas
* \param [in] pressureEstimate : \ref around1bar or \ref around155bars
* \param [in] vector<double> : fluid velocity (assumed constant)
* */
TransportEquation(FluidMaterial fluid, pressureEstimate pEstimate,vector<double> vitesseTransport, MPI_Comm comm = MPI_COMM_WORLD);
//Gestion du calcul
virtual void initialize();
virtual void terminate();//vide la mémoire et enregistre le résultat final
bool initTimeStep(double dt);
double computeTimeStep(bool & stop);//propose un pas de temps pour le calcul. Celà nécessite de discrétiser les opérateur (convection, diffusion, sources) et pour chacun d'employer la condition cfl. En cas de problème durant ce calcul (exemple t=tmax), renvoie stop=true
void abortTimeStep();//efface les inconnues calculées par solveTimeStep() et reinitialise dt à 0
bool iterateTimeStep(bool &ok);
virtual void save();
virtual void validateTimeStep();
/* Boundary conditions */
/** \fn setIntletBoundaryCondition
* \brief adds a new boundary condition of type Inlet
* \details same as setDirichletBoundaryCondition
* \param [in] string : the name of the boundary
* \param [in] double : the value of the enthalpy at the boundary
* \param [out] void
* */
void setInletBoundaryCondition(string groupName,double enthalpy){
_limitField[groupName]=LimitFieldTransport(InletTransport,-1,enthalpy,-1);
};
/** \fn setDirichletBoundaryCondition
* \brief adds a new boundary condition of type Dirichlet
* \details same as setInletBoundaryCondition
* \param [in] string : the name of the boundary
* \param [in] double : the value of the enthalpy at the boundary
* \param [out] void
* */
void setDirichletBoundaryCondition(string groupName,double enthalpy){
_limitField[groupName]=LimitFieldTransport(DirichletTransport,-1,enthalpy,-1);
};
/** \fn setDirichletBoundaryCondition
* \brief adds a new boundary condition of type Inlet
* \details Reads the boundary field in a med file
* \param [in] string : the name of the boundary
* \param [in] string : the file name
* \param [in] string : the field name
* \param [in] int : the time step number
* \param [in] int : int corresponding to the enum CELLS or NODES
* \param [out] void
* */
void setDirichletBoundaryCondition(string groupName, string fileName, string fieldName, int timeStepNumber, int order, int meshLevel, EntityType field_support_type);
void setDirichletBoundaryCondition(string groupName, Field bc_field){
_limitField[groupName]=LimitFieldTransport(DirichletTransport, -1, 0, -1);
};
/** \fn setNeumannBoundaryCondition
* \brief adds a new boundary condition of type Neumann
* \details same as setOutletBoundaryCondition
* \param [in] string the name of the boundary
* \param [in] double : the value of the enthalpy flux at the boundary
* \param [out] void
* */
void setNeumannBoundaryCondition(string groupName, double flux=0){
_limitField[groupName]=LimitFieldTransport(NeumannTransport,-1,-1,flux);
};
/** \fn setOutletBoundaryCondition
* \brief adds a new boundary condition of type Outlet
* \details same as setNeumannBoundaryCondition
* \param [in] string the name of the boundary
* \param [in] double : the value of the enthalpy flux at the boundary
* \param [out] void
* */
void setOutletBoundaryCondition(string groupName, double flux=0){
_limitField[groupName]=LimitFieldTransport(OutletTransport,-1,-1,flux);
};
/** \fn setNeumannBoundaryCondition
* \brief adds a new boundary condition of type Neumann
* \details Reads the boundary field in a med file
* \param [in] string : the name of the boundary
* \param [in] string : the file name
* \param [in] string : the field name
* \param [in] int : the time step number
* \param [in] int : int corresponding to the enum CELLS or NODES
* \param [out] void
* */
void setNeumannBoundaryCondition(string groupName, string fileName, string fieldName, int timeStepNumber, int order, int meshLevel, EntityType field_support_type);
void setNeumannBoundaryCondition(string groupName, Field bc_field){
_limitField[groupName]=LimitFieldTransport(NeumannTransport,-1,-1, 0);
};
/** \fn setBoundaryFields
* \brief met à jour _limitField ( le type de condition limite )
* \details
* \param [in] string
* \param [out] void
* */
void setBoundaryFields(map<string, LimitFieldTransport> boundaryFields){
_limitField = boundaryFields;
};
/*Physical parameters*/
void setLiqSatEnthalpy(double hsatl){
_hsatl=hsatl;
};
void setVapSatEnthalpy(double hsatv){
_hsatv=hsatv;
};
void setLiqSatDensity(double rhosatl){
_rhosatl=rhosatl;
};
void setVapSatDensity(double rhosatv){
_rhosatv=rhosatv;
};
void setTransportVelocity(Vector v){
_vitesseTransport=v;
};
/* set input fields to prepare the simulation */
vector<string> getInputFieldsNames();
void setInputField(const string& nameField, Field& inputField );//supply of a required input field
/** \fn setRodTemperatureField
* \brief Set the rod temperature field
* \details
* \param [in] Field
* \param [out] void
* */
void setRodTemperatureField(Field rodTemperature);
/** \fn setRodTemperature
* \brief Set a constant rod temperature field
* \details
* \param [in] double
* \param [out] void
* */
void setRodTemperature(double rodTemp){
_rodTemperature=rodTemp;
_isStationary=false;//Source term may be changed after previously reaching a stationary state
}
/** \fn getRodTemperatureField
* \brief
* \details
* \param [in] void
* \param [out] Field
* */
Field& getRodTemperatureField(){ // ?? je ne retrouve pas cet attribut dans le file.cxx
return _rodTemperatureField;
}
/* get output fields for postprocessing or coupling */
vector<string> getOutputFieldsNames() ;//liste tous les champs que peut fournir le code pour le postraitement
Field& getOutputField(const string& nameField );//Renvoie un champs pour le postraitement
Field& getFluidTemperatureField(){
return _TT;
}
Field& getEnthalpyField(){
return _VV;
}
Field& getVoidFractionField(){
return _Alpha;
}
Field& getDensityField(){
return _Rho;
}
protected :
double computeTransportMatrix();
double computeRHS();
void updatePrimitives();
/* Postprocessing fields */
Field _TT, _Alpha, _Rho;//Fields of temperature, void fraction, density. Unknown field is enthalpy (_VV)
double _rhosatv, _rhosatl;
double _Tref, _href, _cpref;
double temperature(double h){
return _Tref+(h-_href)/_cpref;
};
double voidFraction(double h){
double titre=(h-_hsatl)/(_hsatv-_hsatl);
if (titre<0)
return 0;
else if (titre>1)
return 1;
else return titre*_rhosatl/(titre*_rhosatl+(1-titre)*_rhosatv);
};
double density(double alpha){
return alpha*_rhosatv+(1-alpha)*_rhosatl;
};
Vector _vitesseTransport, _normale;
bool _transportMatrixSet;
Vec _Hn, _deltaH, _Hk, _Hkm1, _b0;
Vec _Hn_seq; // Local sequential copy of the parallel vector _Hn, used for saving result files
double _dt_transport, _dt_src;
map<string, LimitFieldTransport> _limitField;
/* source terms */
bool _rodTemperatureFieldSet;
Field _rodTemperatureField;
double _rodTemperature;
};
#endif /* TransportEquation_HXX_ */