-
Notifications
You must be signed in to change notification settings - Fork 976
Expand file tree
/
Copy pathCIncEulerVariable.hpp
More file actions
290 lines (255 loc) · 10.8 KB
/
CIncEulerVariable.hpp
File metadata and controls
290 lines (255 loc) · 10.8 KB
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*!
* \file CIncEulerVariable.hpp
* \brief Class for defining the variables of the incompressible Euler solver.
* \author F. Palacios, T. Economon
* \version 8.1.0 "Harrier"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <limits>
#include "CFlowVariable.hpp"
/*!
* \class CIncEulerVariable
* \brief Class for defining the variables of the incompressible Euler solver.
* \note Primitive variables (P, vx, vy, vz, T, rho, beta, lamMu, EddyMu, Kt_eff, Cp, Cv)
* \note Gradients of primitives (P, vx, vy, vz, T, rho, beta)
* \ingroup Euler_Equations
* \author F. Palacios, T. Economon, T. Albring
*/
class CIncEulerVariable : public CFlowVariable {
public:
static constexpr size_t MAXNVAR = 12;
template <class IndexType>
struct CIndices {
const IndexType nDim;
CIndices(IndexType ndim, IndexType) : nDim(ndim) {}
inline IndexType NDim() const { return nDim; }
inline IndexType NSpecies() const { return 0; }
inline IndexType Pressure() const { return 0; }
inline IndexType Velocity() const { return 1; }
inline IndexType Temperature() const { return nDim+1; }
inline IndexType Density() const { return nDim+2; }
inline IndexType Beta() const { return nDim+3; }
inline IndexType SoundSpeed() const { return Beta(); }
inline IndexType LaminarViscosity() const { return nDim+4; }
inline IndexType EddyViscosity() const { return nDim+5; }
inline IndexType ThermalConductivity() const { return nDim+6; }
inline IndexType CpTotal() const { return nDim+7; }
inline IndexType CvTotal() const { return nDim+8; }
/*--- For compatible interface with NEMO. ---*/
inline IndexType SpeciesDensities() const { return std::numeric_limits<IndexType>::max(); }
inline IndexType Temperature_ve() const { return std::numeric_limits<IndexType>::max(); }
inline IndexType Enthalpy() const { return std::numeric_limits<IndexType>::max(); }
};
protected:
const CIndices<unsigned long> indices;
VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */
Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */
public:
/*!
* \brief Constructor of the class.
* \param[in] val_pressure - value of the pressure.
* \param[in] velocity - Value of the flow velocity (initialization value).
* \param[in] temperature - Value of the temperature (initialization value).
* \param[in] npoint - Number of points/nodes/vertices in the domain.
* \param[in] ndim - Number of dimensions of the problem.
* \param[in] nvar - Number of variables of the problem.
* \param[in] config - Definition of the particular problem.
*/
CIncEulerVariable(su2double density, su2double pressure, const su2double *velocity, su2double temperature,
unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config);
/*!
* \brief Set the value of the pressure.
* \param[in] iPoint - Point index.
*/
inline void SetPressure(unsigned long iPoint) final { Primitive(iPoint, indices.Pressure()) = Solution(iPoint,0); }
/*!
* \brief Set the value of the density for the incompressible flows.
* \param[in] iPoint - Point index.
*/
inline bool SetDensity(unsigned long iPoint, su2double val_density) final {
Primitive(iPoint, indices.Density()) = val_density;
return val_density <= 0.0;
}
inline void Set_Density_time_n(unsigned long iPoint, su2double val) {
Density_time_n[iPoint] = val;
}
inline void Set_Density_unsteady(unsigned long iPoint, su2double val) {
Density_unsteady[iPoint] = val;
}
inline su2double GetDensity_time_n(unsigned long iPoint) const {
return Density_time_n[iPoint];
}
/*!
* \brief Set the value of the density for the incompressible flows.
* \param[in] iPoint - Point index.
*/
inline void SetVelocity(unsigned long iPoint) final {
Velocity2(iPoint) = 0.0;
for (unsigned long iDim = 0; iDim < nDim; iDim++) {
Primitive(iPoint, iDim+indices.Velocity()) = Solution(iPoint,iDim+1);
Velocity2(iPoint) += pow(Primitive(iPoint, iDim+indices.Velocity()), 2);
}
}
/*!
* \brief Set the value of the temperature for incompressible flows with energy equation.
* \param[in] iPoint - Point index.
*/
inline bool SetTemperature(unsigned long iPoint, su2double val_temperature) final {
Primitive(iPoint, indices.Temperature()) = val_temperature;
return val_temperature <= 0.0;
}
/*!
* \brief Set the value of the beta coeffient for incompressible flows.
* \param[in] iPoint - Point index.
*/
inline void SetBetaInc2(unsigned long iPoint, su2double betainc2) final {
Primitive(iPoint, indices.Beta()) = betainc2;
}
/*!
* \brief Get the flow pressure.
* \return Value of the flow pressure.
*/
inline su2double GetPressure(unsigned long iPoint) const final { return Primitive(iPoint, indices.Pressure()); }
/*!
* \brief Get the value of beta squared for the incompressible flow
* \return Value of beta squared.
*/
inline su2double GetBetaInc2(unsigned long iPoint) const final { return Primitive(iPoint, indices.Beta()); }
/*!
* \brief Get the density of the flow.
* \return Value of the density of the flow.
*/
inline su2double GetDensity(unsigned long iPoint) const final { return Primitive(iPoint, indices.Density()); }
/*!
* \brief Get the temperature of the flow.
* \return Value of the temperature of the flow.
*/
inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint, indices.Temperature()); }
/*!
* \brief Get the velocity of the flow.
* \param[in] iDim - Index of the dimension.
* \return Value of the velocity for the dimension <i>iDim</i>.
*/
inline su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const final {
return Primitive(iPoint, iDim+indices.Velocity());
}
/*!
* \brief Get the velocity gradient.
* \return Value of the velocity gradient.
*/
inline CMatrixView<const su2double> GetVelocityGradient(unsigned long iPoint) const final {
return Gradient_Primitive(iPoint, indices.Velocity());
}
/*!
* \brief Get the projected velocity in a unitary vector direction (compressible solver).
* \param[in] val_vector - Direction of projection.
* \return Value of the projected velocity.
*/
inline su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final {
su2double ProjVel = 0.0;
for (unsigned long iDim = 0; iDim < nDim; iDim++)
ProjVel += Primitive(iPoint, iDim+indices.Velocity())*val_vector[iDim];
return ProjVel;
}
/*!
* \brief Set the velocity vector from the old solution.
* \param[in] val_velocity - Pointer to the velocity.
*/
inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final {
for (unsigned long iDim = 0; iDim < nDim; iDim++)
Solution_Old(iPoint,iDim+1) = val_velocity[iDim];
}
/*!
* \brief Set the momentum part of the truncation error to zero.
* \param[in] iPoint - Point index.
*/
inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
}
/*!
* \brief Set all the primitive variables for incompressible flows.
*/
bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) final;
/*!
* \brief Set the specific heat Cp.
*/
inline void SetSpecificHeatCp(unsigned long iPoint, su2double val_Cp) final {
Primitive(iPoint, indices.CpTotal()) = val_Cp;
}
/*!
* \brief Set the specific heat Cv.
*/
inline void SetSpecificHeatCv(unsigned long iPoint, su2double val_Cv) final {
Primitive(iPoint, indices.CvTotal()) = val_Cv;
}
/*!
* \brief Get the specific heat at constant P of the flow.
* \return Value of the specific heat at constant P of the flow.
*/
inline su2double GetSpecificHeatCp(unsigned long iPoint) const final { return Primitive(iPoint, indices.CpTotal()); }
/*!
* \brief Get the specific heat at constant V of the flow.
* \return Value of the specific heat at constant V of the flow.
*/
inline su2double GetSpecificHeatCv(unsigned long iPoint) const final { return Primitive(iPoint, indices.CvTotal()); }
/*!
* \brief Set the recovered pressure for streamwise periodic flow.
* \param[in] iPoint - Point index.
* \param[in] val_pressure - pressure value.
*/
inline void SetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint, su2double val_pressure) final {
Streamwise_Periodic_RecoveredPressure(iPoint) = val_pressure;
}
/*!
* \brief Get the recovered pressure for streamwise periodic flow.
* \param[in] iPoint - Point index.
* \return Recovered/Physical pressure for streamwise periodic flow.
*/
inline su2double GetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint) const final {
return Streamwise_Periodic_RecoveredPressure(iPoint);
}
/*!
* \brief Set the recovered temperature for streamwise periodic flow.
* \param[in] iPoint - Point index.
* \param[in] val_temperature - temperature value.
*/
inline void SetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint, su2double val_temperature) final {
Streamwise_Periodic_RecoveredTemperature(iPoint) = val_temperature;
}
/*!
* \brief Get the recovered temperature for streamwise periodic flow.
* \param[in] iPoint - Point index.
* \return Recovered/Physical temperature for streamwise periodic flow.
*/
inline su2double GetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint) const final {
return Streamwise_Periodic_RecoveredTemperature(iPoint);
}
/*!
* \brief Specify a vector to set the velocity components of the solution.
* \param[in] iPoint - Point index.
* \param[in] val_vector - Pointer to the vector.
*/
inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim];
}
};