Documentation 6b54b78464
Loading...
Searching...
No Matches
CIncEulerVariable.hpp
Go to the documentation of this file.
1/*!
2 * \file CIncEulerVariable.hpp
3 * \brief Class for defining the variables of the incompressible Euler solver.
4 * \author F. Palacios, T. Economon
5 * \version 8.5.0 "Harrier"
6 *
7 * SU2 Project Website: https://su2code.github.io
8 *
9 * The SU2 Project is maintained by the SU2 Foundation
10 * (http://su2foundation.org)
11 *
12 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
13 *
14 * SU2 is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SU2 is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30#include <limits>
31#include "CFlowVariable.hpp"
32
33/*!
34 * \class CIncEulerVariable
35 * \brief Class for defining the variables of the incompressible Euler solver.
36 * \note Primitive variables (P, vx, vy, vz, T, rho, h, beta, lamMu, EddyMu, Kt_eff, Cp, Cv)
37 * \note Gradients of primitives (P, vx, vy, vz, T, rho, h)
38 * \ingroup Euler_Equations
39 * \author F. Palacios, T. Economon, T. Albring
40 */
42public:
43 static constexpr size_t MAXNVAR = 13;
44
45 template <class IndexType>
46 struct CIndices {
47 const IndexType nDim;
48 CIndices(IndexType ndim, IndexType) : nDim(ndim) {}
49 inline IndexType NDim() const { return nDim; }
50 inline IndexType NSpecies() const { return 0; }
51 inline IndexType Pressure() const { return 0; }
52 inline IndexType Velocity() const { return 1; }
53 inline IndexType Temperature() const { return nDim+1; }
54 inline IndexType Density() const { return nDim+2; }
55 inline IndexType Enthalpy() const { return nDim+3; }
56 inline IndexType Beta() const { return nDim+4; }
57 inline IndexType SoundSpeed() const { return Beta(); }
58 inline IndexType LaminarViscosity() const { return nDim+5; }
59 inline IndexType EddyViscosity() const { return nDim+6; }
60 inline IndexType ThermalConductivity() const { return nDim+7; }
61 inline IndexType CpTotal() const { return nDim+8; }
62 inline IndexType CvTotal() const { return nDim+9; }
63
64 /*--- For compatible interface with NEMO. ---*/
65 inline IndexType SpeciesDensities() const { return std::numeric_limits<IndexType>::max(); }
66 inline IndexType Temperature_ve() const { return std::numeric_limits<IndexType>::max(); }
67 };
68
69 protected:
71
72 VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */
73 Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */
74 VectorType Density_time_n, /*!< \brief Density at time n for dual-time stepping. */
75 Density_time_n1; /*!< \brief Density at time n-1 for dual-time stepping. */
76 su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */
77
79 BoolVectorType strongBC; /*!< \brief Flag for boundary conditions to indicate if a strong BC has been applied, currently only used to keep track of farfield. */
80
81 public:
82 /*!
83 * \brief Constructor of the class.
84 * \param[in] val_pressure - value of the pressure.
85 * \param[in] velocity - Value of the flow velocity (initialization value).
86 * \param[in] enthalpy - Value of the enthalpy (initialization value).
87 * \param[in] npoint - Number of points/nodes/vertices in the domain.
88 * \param[in] ndim - Number of dimensions of the problem.
89 * \param[in] nvar - Number of variables of the problem.
90 * \param[in] config - Definition of the particular problem.
91 */
92
93 CIncEulerVariable(su2double pressure, const su2double *velocity, su2double enthalpy,
94 unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config);
95
96 /*!
97 * \brief Set the value of the pressure.
98 * \param[in] iPoint - Point index.
99 */
100 inline void SetPressure(unsigned long iPoint) final { Primitive(iPoint, indices.Pressure()) = Solution(iPoint,0); }
101
102 /*!
103 * \brief Set the value of the density for the incompressible flows.
104 * \param[in] iPoint - Point index.
105 */
106 inline bool SetDensity(unsigned long iPoint, su2double val_density) final {
107 Primitive(iPoint, indices.Density()) = val_density;
108 return val_density <= 0.0;
109 }
110
111 /*!
112 * \brief Set the value of the density for the incompressible flows.
113 * \param[in] iPoint - Point index.
114 */
115 inline void SetVelocity(unsigned long iPoint) final {
116 Velocity2(iPoint) = 0.0;
117 for (unsigned long iDim = 0; iDim < nDim; iDim++) {
118 Primitive(iPoint, iDim+indices.Velocity()) = Solution(iPoint,iDim+1);
119 Velocity2(iPoint) += pow(Primitive(iPoint, iDim+indices.Velocity()), 2);
120 }
121 }
122
123 /*!
124 * \brief Set the value of the temperature for incompressible flows with energy equation.
125 * \param[in] iPoint - Point index.
126 */
127 inline bool SetTemperature(unsigned long iPoint, su2double val_temperature, const su2double *val_temp_limits) {
128 Primitive(iPoint, indices.Temperature()) = val_temperature;
129 return (val_temperature <= val_temp_limits[0]) || (val_temperature >= val_temp_limits[1]);
130 }
131
132 /*!
133 * \brief Set the value of the enthalpy for incompressible flows with energy equation.
134 * \param[in] iPoint - Point index.
135 */
136 inline void SetEnthalpy(unsigned long iPoint, su2double val_enthalpy) {
137 Primitive(iPoint, indices.Enthalpy()) = val_enthalpy;
138 }
139
140 /*!
141 * \brief Set the value of the beta coeffient for incompressible flows.
142 * \param[in] iPoint - Point index.
143 */
144 inline void SetBetaInc2(unsigned long iPoint, su2double betainc2) final {
145 Primitive(iPoint, indices.Beta()) = betainc2;
146 }
147
148 /*!
149 * \brief Get the flow pressure.
150 * \return Value of the flow pressure.
151 */
152 inline su2double GetPressure(unsigned long iPoint) const final { return Primitive(iPoint, indices.Pressure()); }
153
154 /*!
155 * \brief Get the value of beta squared for the incompressible flow
156 * \return Value of beta squared.
157 */
158 inline su2double GetBetaInc2(unsigned long iPoint) const final { return Primitive(iPoint, indices.Beta()); }
159
160 /*!
161 * \brief Get the density of the flow.
162 * \return Value of the density of the flow.
163 */
164 inline su2double GetDensity(unsigned long iPoint) const final { return Primitive(iPoint, indices.Density()); }
165
166 /*!
167 * \brief Get the temperature of the flow.
168 * \return Value of the temperature of the flow.
169 */
170 inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint, indices.Temperature()); }
171
172 /*!
173 * \brief Get the enthalpy of the flow.
174 * \return Value of the enthalpy of the flow.
175 */
176 inline su2double GetEnthalpy(unsigned long iPoint) const final { return Primitive(iPoint, indices.Enthalpy()); }
177
178 /*!
179 * \brief Get the velocity of the flow.
180 * \param[in] iDim - Index of the dimension.
181 * \return Value of the velocity for the dimension <i>iDim</i>.
182 */
183 inline su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const final {
184 return Primitive(iPoint, iDim+indices.Velocity());
185 }
186
187 /*!
188 * \brief Get the velocity gradient.
189 * \return Value of the velocity gradient.
190 */
191 inline CMatrixView<const su2double> GetVelocityGradient(unsigned long iPoint) const final {
192 return Gradient_Primitive(iPoint, indices.Velocity());
193 }
194
195 /*!
196 * \brief Get the projected velocity in a unitary vector direction (compressible solver).
197 * \param[in] val_vector - Direction of projection.
198 * \return Value of the projected velocity.
199 */
200 inline su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final {
201 su2double ProjVel = 0.0;
202 for (unsigned long iDim = 0; iDim < nDim; iDim++)
203 ProjVel += Primitive(iPoint, iDim+indices.Velocity())*val_vector[iDim];
204 return ProjVel;
205 }
206
207 /*!
208 * \brief Set the velocity vector from the old solution.
209 * \param[in] val_velocity - Pointer to the velocity.
210 */
211 inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final {
212 for (unsigned long iDim = 0; iDim < nDim; iDim++)
213 Solution_Old(iPoint,iDim+1) = val_velocity[iDim];
214 }
215
216 /*!
217 * \brief Set the momentum part of the truncation error to zero.
218 * \param[in] iPoint - Point index.
219 */
220 inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
221 for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
222 }
223
224 /*!
225 * \brief Set all the primitive variables for incompressible flows.
226 */
227 bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) final;
228
229 /*!
230 * \brief Set the specific heat Cp.
231 */
232 inline void SetSpecificHeatCp(unsigned long iPoint, su2double val_Cp) final {
233 Primitive(iPoint, indices.CpTotal()) = val_Cp;
234 }
235
236 /*!
237 * \brief Set the specific heat Cv.
238 */
239 inline void SetSpecificHeatCv(unsigned long iPoint, su2double val_Cv) final {
240 Primitive(iPoint, indices.CvTotal()) = val_Cv;
241 }
242
243 /*!
244 * \brief Get the specific heat at constant P of the flow.
245 * \return Value of the specific heat at constant P of the flow.
246 */
247 inline su2double GetSpecificHeatCp(unsigned long iPoint) const final { return Primitive(iPoint, indices.CpTotal()); }
248
249 /*!
250 * \brief Get the specific heat at constant V of the flow.
251 * \return Value of the specific heat at constant V of the flow.
252 */
253 inline su2double GetSpecificHeatCv(unsigned long iPoint) const final { return Primitive(iPoint, indices.CvTotal()); }
254
255 /*!
256 * \brief Set the recovered pressure for streamwise periodic flow.
257 * \param[in] iPoint - Point index.
258 * \param[in] val_pressure - pressure value.
259 */
260 inline void SetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint, su2double val_pressure) final {
261 Streamwise_Periodic_RecoveredPressure(iPoint) = val_pressure;
262 }
263
264 /*!
265 * \brief Get the recovered pressure for streamwise periodic flow.
266 * \param[in] iPoint - Point index.
267 * \return Recovered/Physical pressure for streamwise periodic flow.
268 */
269 inline su2double GetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint) const final {
271 }
272
273 /*!
274 * \brief Set the recovered temperature for streamwise periodic flow.
275 * \param[in] iPoint - Point index.
276 * \param[in] val_temperature - temperature value.
277 */
278 inline void SetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint, su2double val_temperature) final {
279 Streamwise_Periodic_RecoveredTemperature(iPoint) = val_temperature;
280 }
281
282 /*!
283 * \brief Get the recovered temperature for streamwise periodic flow.
284 * \param[in] iPoint - Point index.
285 * \return Recovered/Physical temperature for streamwise periodic flow.
286 */
287 inline su2double GetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint) const final {
289 }
290
291 /*!
292 * \brief Specify a vector to set the velocity components of the solution.
293 * \param[in] iPoint - Point index.
294 * \param[in] val_vector - Pointer to the vector.
295 */
296 inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
297 for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim];
298 }
299
300 /*!
301 * \brief Get the density at time level n for dual-time stepping.
302 * \param[in] iPoint - Point index.
303 * \return Density at time level n.
304 */
305 inline su2double GetDensity_time_n(unsigned long iPoint) const final {
306 return Density_time_n.size() > 0 ? Density_time_n(iPoint) : GetDensity(iPoint);
307 }
308
309 /*!
310 * \brief Get the density at time level n-1 for dual-time stepping.
311 * \param[in] iPoint - Point index.
312 * \return Density at time level n-1.
313 */
314 inline su2double GetDensity_time_n1(unsigned long iPoint) const final {
315 return Density_time_n1.size() > 0 ? Density_time_n1(iPoint) : GetDensity(iPoint);
316 }
317
318 /*!
319 * \brief Set the density at time level n for dual-time stepping.
320 * \param[in] iPoint - Point index.
321 * \param[in] val_density - Density value.
322 */
323 inline void SetDensity_time_n(unsigned long iPoint, su2double val_density) { Density_time_n(iPoint) = val_density; }
324
325 /*!
326 * \brief Set the density at time level n-1 for dual-time stepping.
327 * \param[in] iPoint - Point index.
328 * \param[in] val_density - Density value.
329 */
330 inline void SetDensity_time_n1(unsigned long iPoint, su2double val_density) { Density_time_n1(iPoint) = val_density; }
331
332 /*!
333 * \brief Set the BC flag to true of the point.
334 * \param[in] iPoint - Point index.
335 */
336 inline void SetStrongBC(unsigned long iPoint) { strongBC(iPoint) = true; }
337
338 /*!
339 * \brief Get the BC flag of the point
340 * \param[in] iPoint - Point index.
341 * \return The boolean flag of the strong boundary condition.
342 */
343 inline bool GetStrongBC(unsigned long iPoint) const final { return strongBC(iPoint); }
344
345 /*!
346 * \brief Set the BC flag to false of the point.
347 * \param[in] iPoint - Point index.
348 */
349 inline void ResetStrongBC(unsigned long iPoint) { strongBC(iPoint) = false; }
350
351};
Class for defining the common variables of flow solvers.
size_t size() const noexcept
Definition C2DContainer.hpp:222
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Class for defining the common variables of flow solvers.
Definition CFlowVariable.hpp:38
CVectorOfMatrix Gradient_Primitive
Gradient of the primitive variables.
Definition CFlowVariable.hpp:42
MatrixType Primitive
Primitive variables.
Definition CFlowVariable.hpp:41
VectorType Velocity2
Squared norm of velocity.
Definition CFlowVariable.hpp:48
Main class for defining the Thermo-Physical Model.
Definition CFluidModel.hpp:47
Class for defining the variables of the incompressible Euler solver.
Definition CIncEulerVariable.hpp:41
su2double TemperatureLimits[2]
Temperature limits [K].
Definition CIncEulerVariable.hpp:76
CMatrixView< const su2double > GetVelocityGradient(unsigned long iPoint) const final
Get the velocity gradient.
Definition CIncEulerVariable.hpp:191
bool GetStrongBC(unsigned long iPoint) const final
Get the BC flag of the point.
Definition CIncEulerVariable.hpp:343
bool SetTemperature(unsigned long iPoint, su2double val_temperature, const su2double *val_temp_limits)
Set the value of the temperature for incompressible flows with energy equation.
Definition CIncEulerVariable.hpp:127
BoolVectorType strongBC
Flag for boundary conditions to indicate if a strong BC has been applied, currently only used to keep...
Definition CIncEulerVariable.hpp:79
su2double GetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint) const final
Get the recovered pressure for streamwise periodic flow.
Definition CIncEulerVariable.hpp:269
void SetVel_ResTruncError_Zero(unsigned long iPoint) final
Set the momentum part of the truncation error to zero.
Definition CIncEulerVariable.hpp:220
VectorType Density_time_n1
Density at time n-1 for dual-time stepping.
Definition CIncEulerVariable.hpp:75
su2double GetDensity_time_n(unsigned long iPoint) const final
Get the density at time level n for dual-time stepping.
Definition CIncEulerVariable.hpp:305
VectorType Streamwise_Periodic_RecoveredPressure
Recovered/Physical pressure [Pa] for streamwise periodic flow.
Definition CIncEulerVariable.hpp:72
su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final
Get the projected velocity in a unitary vector direction (compressible solver).
Definition CIncEulerVariable.hpp:200
void SetEnthalpy(unsigned long iPoint, su2double val_enthalpy)
Set the value of the enthalpy for incompressible flows with energy equation.
Definition CIncEulerVariable.hpp:136
void SetBetaInc2(unsigned long iPoint, su2double betainc2) final
Set the value of the beta coeffient for incompressible flows.
Definition CIncEulerVariable.hpp:144
static constexpr size_t MAXNVAR
Definition CIncEulerVariable.hpp:43
void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final
Specify a vector to set the velocity components of the solution.
Definition CIncEulerVariable.hpp:296
void SetDensity_time_n1(unsigned long iPoint, su2double val_density)
Set the density at time level n-1 for dual-time stepping.
Definition CIncEulerVariable.hpp:330
su2double GetTemperature(unsigned long iPoint) const final
Get the temperature of the flow.
Definition CIncEulerVariable.hpp:170
void SetSpecificHeatCp(unsigned long iPoint, su2double val_Cp) final
Set the specific heat Cp.
Definition CIncEulerVariable.hpp:232
void SetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint, su2double val_temperature) final
Set the recovered temperature for streamwise periodic flow.
Definition CIncEulerVariable.hpp:278
VectorType Streamwise_Periodic_RecoveredTemperature
Recovered/Physical temperature [K] for streamwise periodic flow.
Definition CIncEulerVariable.hpp:73
su2double GetPressure(unsigned long iPoint) const final
Get the flow pressure.
Definition CIncEulerVariable.hpp:152
void SetVelocity(unsigned long iPoint) final
Set the value of the density for the incompressible flows.
Definition CIncEulerVariable.hpp:115
su2double GetEnthalpy(unsigned long iPoint) const final
Get the enthalpy of the flow.
Definition CIncEulerVariable.hpp:176
void SetStrongBC(unsigned long iPoint)
Set the BC flag to true of the point.
Definition CIncEulerVariable.hpp:336
su2double GetStreamwise_Periodic_RecoveredTemperature(unsigned long iPoint) const final
Get the recovered temperature for streamwise periodic flow.
Definition CIncEulerVariable.hpp:287
su2double GetDensity(unsigned long iPoint) const final
Get the density of the flow.
Definition CIncEulerVariable.hpp:164
void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final
Set the velocity vector from the old solution.
Definition CIncEulerVariable.hpp:211
su2double GetBetaInc2(unsigned long iPoint) const final
Get the value of beta squared for the incompressible flow.
Definition CIncEulerVariable.hpp:158
su2double GetSpecificHeatCp(unsigned long iPoint) const final
Get the specific heat at constant P of the flow.
Definition CIncEulerVariable.hpp:247
void ResetStrongBC(unsigned long iPoint)
Set the BC flag to false of the point.
Definition CIncEulerVariable.hpp:349
su2double GetDensity_time_n1(unsigned long iPoint) const final
Get the density at time level n-1 for dual-time stepping.
Definition CIncEulerVariable.hpp:314
su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const final
Get the velocity of the flow.
Definition CIncEulerVariable.hpp:183
bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) final
Set all the primitive variables for incompressible flows.
Definition CIncEulerVariable.cpp:82
void SetStreamwise_Periodic_RecoveredPressure(unsigned long iPoint, su2double val_pressure) final
Set the recovered pressure for streamwise periodic flow.
Definition CIncEulerVariable.hpp:260
su2double GetSpecificHeatCv(unsigned long iPoint) const final
Get the specific heat at constant V of the flow.
Definition CIncEulerVariable.hpp:253
void SetPressure(unsigned long iPoint) final
Set the value of the pressure.
Definition CIncEulerVariable.hpp:100
void SetSpecificHeatCv(unsigned long iPoint, su2double val_Cv) final
Set the specific heat Cv.
Definition CIncEulerVariable.hpp:239
bool SetDensity(unsigned long iPoint, su2double val_density) final
Set the value of the density for the incompressible flows.
Definition CIncEulerVariable.hpp:106
VectorType Density_time_n
Density at time n for dual-time stepping.
Definition CIncEulerVariable.hpp:74
void SetDensity_time_n(unsigned long iPoint, su2double val_density)
Set the density at time level n for dual-time stepping.
Definition CIncEulerVariable.hpp:323
const CIndices< unsigned long > indices
Definition CIncEulerVariable.hpp:70
Class to represent a matrix (without owning the data, this just wraps a pointer).
Definition container_decorators.hpp:40
MatrixType Solution
Solution of the problem.
Definition CVariable.hpp:55
MatrixType Solution_Old
Old solution of the problem R-K.
Definition CVariable.hpp:56
MatrixType Res_TruncError
Truncation error for multigrid cycle.
Definition CVariable.hpp:91
unsigned long nDim
Number of dimension of the problem.
Definition CVariable.hpp:107
passivedouble su2double
Definition code_config.hpp:181
FORCEINLINE ARRAY_T pow(const ARRAY_T &a, const ARRAY_T &b)
Definition special_vectorization.hpp:179
IndexType CpTotal() const
Definition CEulerVariable.hpp:65
IndexType Velocity() const
Definition CEulerVariable.hpp:57
IndexType Density() const
Definition CEulerVariable.hpp:59
IndexType Enthalpy() const
Definition CEulerVariable.hpp:60
IndexType Pressure() const
Definition CEulerVariable.hpp:58
IndexType Temperature() const
Definition CEulerVariable.hpp:56
Definition CIncEulerVariable.hpp:46
IndexType CpTotal() const
Definition CIncEulerVariable.hpp:61
IndexType NSpecies() const
Definition CIncEulerVariable.hpp:50
IndexType NDim() const
Definition CIncEulerVariable.hpp:49
IndexType Temperature() const
Definition CIncEulerVariable.hpp:53
IndexType Beta() const
Definition CIncEulerVariable.hpp:56
IndexType Velocity() const
Definition CIncEulerVariable.hpp:52
IndexType Density() const
Definition CIncEulerVariable.hpp:54
IndexType Enthalpy() const
Definition CIncEulerVariable.hpp:55
CIndices(IndexType ndim, IndexType)
Definition CIncEulerVariable.hpp:48
IndexType LaminarViscosity() const
Definition CIncEulerVariable.hpp:58
IndexType SpeciesDensities() const
Definition CIncEulerVariable.hpp:65
IndexType EddyViscosity() const
Definition CIncEulerVariable.hpp:59
IndexType ThermalConductivity() const
Definition CIncEulerVariable.hpp:60
const IndexType nDim
Definition CIncEulerVariable.hpp:47
IndexType Pressure() const
Definition CIncEulerVariable.hpp:51
IndexType SoundSpeed() const
Definition CIncEulerVariable.hpp:57
IndexType Temperature_ve() const
Definition CIncEulerVariable.hpp:66
IndexType CvTotal() const
Definition CIncEulerVariable.hpp:62