30#include "../../CNumericsSIMD.hpp"
31#include "../../util.hpp"
32#include "../variables.hpp"
33#include "../../../variables/CNSVariable.hpp"
51template<
class ReconVarType,
class PrimVarType,
size_t nDim,
class VariableType>
53 const Int& iPoint,
const Int& jPoint,
62 const VariableType& solution,
64 static_assert(ReconVarType::nVar <= PrimVarType::nVar);
66 const auto& gradients = solution.GetGradient_Reconstruction();
67 const auto& limiters = solution.GetLimiter_Primitive();
71 for (
size_t iVar = 0; iVar < ReconVarType::nVar; ++iVar) {
72 V.
i.all(iVar) = V1st.
i.all(iVar);
73 V.j.all(iVar) = V1st.
j.all(iVar);
78 constexpr auto nVarGrad = ReconVarType::nVar - 2;
79 reconstruct<nVarGrad>(iPoint, jPoint, vector_ij, gradients, limiters, limiterType, 0,
V, kappa, umusclRamp);
81 V.i.density() =
V.i.pressure() / (gasConst *
V.i.temperature());
82 V.j.density() =
V.j.pressure() / (gasConst *
V.j.temperature());
90 const su2double cp = gasConst * gamma / (gamma - 1);
91 V.i.enthalpy() += cp * (
V.i.temperature() - V1st.
i.temperature());
92 V.j.enthalpy() += cp * (
V.j.temperature() - V1st.
j.temperature());
93 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
94 V.i.enthalpy() += 0.5 * (
pow(
V.i.velocity(iDim), 2) -
pow(V1st.
i.velocity(iDim), 2));
95 V.j.enthalpy() += 0.5 * (
pow(
V.j.velocity(iDim), 2) -
pow(V1st.
j.velocity(iDim), 2));
99 const Double neg_p_or_rho = fmax(fmin(
V.i.pressure(),
V.j.pressure()) < 0.0,
100 fmin(
V.i.density(),
V.j.density()) < 0.0);
104 const Double enthalpy = R*
V.j.enthalpy() +
V.i.enthalpy();
106 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
107 v_squared +=
pow(R*
V.j.velocity(iDim) +
V.i.velocity(iDim), 2);
111 const Double neg_sound_speed = enthalpy * (R+1) < 0.5 * v_squared;
114 nonPhysical = fmax(neg_p_or_rho, neg_sound_speed);
117 nonPhysical[k] = solution.UpdateNonPhysicalEdgeCounter(iEdge[k], nonPhysical[k]);
118 nonPhysical[k] = fmax(nonPhysical[k],
119 fmax(solution.OutlierMitigation(iPoint[k]),
120 solution.OutlierMitigation(jPoint[k])) / VariableType::MAX_OUTLIER_MITIGATION);
122 for (
size_t iVar = 0; iVar < ReconVarType::nVar; ++iVar) {
123 V.i.all(iVar) = nonPhysical * V1st.
i.all(iVar) + (1-nonPhysical) *
V.i.all(iVar);
124 V.j.all(iVar) = nonPhysical * V1st.
j.all(iVar) + (1-nonPhysical) *
V.j.all(iVar);
135template<
size_t nDim,
class RandomAccessIterator>
139 const Double vel2 = 0.5*squaredNorm<nDim>(velocity);
145 pMat(1,0) = velocity[0];
146 pMat(1,1) = density*normal(1);
148 pMat(2,0) = velocity[1];
149 pMat(2,1) = -density*normal(0);
152 pMat(3,1) = density*(velocity[0]*normal(1) - velocity[1]*normal(0));
155 pMat(0,0) = normal(0);
156 pMat(0,1) = normal(1);
157 pMat(0,2) = normal(2);
159 pMat(1,0) = velocity[0]*normal(0);
160 pMat(1,1) = velocity[0]*normal(1) - density*normal(2);
161 pMat(1,2) = velocity[0]*normal(2) + density*normal(1);
163 pMat(2,0) = velocity[1]*normal(0) + density*normal(2);
164 pMat(2,1) = velocity[1]*normal(1);
165 pMat(2,2) = velocity[1]*normal(2) - density*normal(0);
167 pMat(3,0) = velocity[2]*normal(0) - density*normal(1);
168 pMat(3,1) = velocity[2]*normal(1) + density*normal(0);
169 pMat(3,2) = velocity[2]*normal(2);
171 pMat(4,0) = vel2*normal(0) + density*(velocity[1]*normal(2) - velocity[2]*normal(1));
172 pMat(4,1) = vel2*normal(1) - density*(velocity[0]*normal(2) - velocity[2]*normal(0));
173 pMat(4,2) = vel2*normal(2) + density*(velocity[0]*normal(1) - velocity[1]*normal(0));
178 const Double rhoOn2 = 0.5*density;
179 const Double rhoOnTwoC = rhoOn2 / speedSound;
180 pMat(0,nDim) = rhoOnTwoC;
181 pMat(0,nDim+1) = rhoOnTwoC;
183 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
184 pMat(iDim+1,nDim) = rhoOnTwoC * velocity[iDim] + rhoOn2 * normal(iDim);
185 pMat(iDim+1,nDim+1) = rhoOnTwoC * velocity[iDim] - rhoOn2 * normal(iDim);
188 pMat(nDim+1,nDim) = rhoOnTwoC * vel2 + rhoOn2 * (projVel + speedSound/(gamma-1));
189 pMat(nDim+1,nDim+1) = rhoOnTwoC * vel2 - rhoOn2 * (projVel - speedSound/(gamma-1));
197template<
size_t nDim,
class RandomAccessIterator>
199 const RandomAccessIterator& velocity,
const Double& projVel,
204 const Double vel2 = 0.5*squaredNorm<nDim>(velocity);
205 const Double oneOnRho = 1 / density;
208 Double tmp = (gamma-1)/c2;
209 pMatInv(0,0) = 1.0 - tmp*vel2;
210 pMatInv(0,1) = tmp*velocity[0];
211 pMatInv(0,2) = tmp*velocity[1];
214 pMatInv(1,0) = (normal(0)*velocity[1]-normal(1)*velocity[0])*oneOnRho;
215 pMatInv(1,1) = normal(1)*oneOnRho;
216 pMatInv(1,2) = -normal(0)*oneOnRho;
220 Double tmp = (gamma-1)/c2 * normal(0);
221 pMatInv(0,0) = normal(0) - tmp*vel2 - (normal(2)*velocity[1]-normal(1)*velocity[2])*oneOnRho;
222 pMatInv(0,1) = tmp*velocity[0];
223 pMatInv(0,2) = tmp*velocity[1] + normal(2)*oneOnRho;
224 pMatInv(0,3) = tmp*velocity[2] - normal(1)*oneOnRho;
227 tmp = (gamma-1)/c2 * normal(1);
228 pMatInv(1,0) = normal(1) - tmp*vel2 + (normal(2)*velocity[0]-normal(0)*velocity[2])*oneOnRho;
229 pMatInv(1,1) = tmp*velocity[0] - normal(2)*oneOnRho;
230 pMatInv(1,2) = tmp*velocity[1];
231 pMatInv(1,3) = tmp*velocity[2] + normal(0)*oneOnRho;
234 tmp = (gamma-1)/c2 * normal(2);
235 pMatInv(2,0) = normal(2) - tmp*vel2 - (normal(1)*velocity[0]-normal(0)*velocity[1])*oneOnRho;
236 pMatInv(2,1) = tmp*velocity[0] + normal(1)*oneOnRho;
237 pMatInv(2,2) = tmp*velocity[1] - normal(0)*oneOnRho;
238 pMatInv(2,3) = tmp*velocity[2];
244 const Double gamma_minus_1_on_rho_times_c = (gamma-1) / (density*speedSound);
246 for (
size_t iVar = nDim; iVar < nDim+2; ++iVar) {
248 pMatInv(iVar,0) = -
sign*projVel*oneOnRho + gamma_minus_1_on_rho_times_c * vel2;
249 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
250 pMatInv(iVar,iDim+1) =
sign*normal(iDim)*oneOnRho - gamma_minus_1_on_rho_times_c * velocity[iDim];
252 pMatInv(iVar,nDim+1) = gamma_minus_1_on_rho_times_c;
261template<
class PrimVarType,
class ConsVarType,
size_t nDim>
263 const ConsVarType& U,
265 static_assert(ConsVarType::nVar == nDim+2);
269 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
270 flux(iDim+1) = mdot*
V.velocity(iDim) + normal(iDim)*
V.pressure();
272 flux(nDim+1) = mdot*
V.enthalpy();
279template<
size_t nDim,
class RandomAccessIterator>
286 Double gamma_m_1 = gamma-1;
287 Double phi = 0.5*gamma_m_1*squaredNorm<nDim>(velocity);
288 Double a1 = gamma*energy - phi;
291 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
292 jac(0,iDim+1) = scale * normal(iDim);
296 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
297 jac(iDim+1,0) = scale * (normal(iDim)*phi - velocity[iDim]*projVel);
298 for (
size_t jDim = 0; jDim < nDim; ++jDim) {
299 jac(iDim+1,jDim+1) = scale * (normal(jDim)*velocity[iDim] - gamma_m_1*normal(iDim)*velocity[jDim]);
301 jac(iDim+1,iDim+1) += scale * projVel;
302 jac(iDim+1,nDim+1) = scale * gamma_m_1 * normal(iDim);
305 jac(nDim+1,0) = scale * projVel * (phi-a1);
306 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
307 jac(nDim+1,iDim+1) = scale * (normal(iDim)*a1 - gamma_m_1*velocity[iDim]*projVel);
309 jac(nDim+1,nDim+1) = scale * gamma * projVel;
317template<
class VariableType>
321 const VariableType& solution) {
326 const auto& sol =
static_cast<const CNSVariable&
>(solution);
328 const auto& dissip = sol.GetRoe_Dissipation();
332 const Double avgSensor = 0.5 * (si + sj);
336 const Double avgDissip = 0.5 * (di + dj);
344 Double d = fmax(minDissip, 1.0 - avgDissip);
348 d = fmax(d, 0.05 + 0.95*(avgSensor > 0.65));
353 return fmax(minDissip, avgDissip);
358 return fmax(minDissip, avgSensor+avgDissip - avgSensor*avgDissip);
369template<
class VariableType,
class T>
373 const T& stretchParam,
374 const VariableType& solution) {
377 const Double phi_i =
pow(0.25*lambda_i/avgLambda, stretchParam);
380 const Double phi_j =
pow(0.25*lambda_j/avgLambda, stretchParam);
382 return 4*phi_i*phi_j / (phi_i + phi_j) * avgLambda;
388template<
class VariableType,
size_t nVar>
394 for (
size_t iVar = 0; iVar < nVar-1; ++iVar) {
395 jac(iVar,iVar) += dissipConst;
397 jac(nVar-1,nVar-1) += dissipConst * gamma;
400 dissipConst *= gamma-1.0;
401 for (
size_t iDim = 0; iDim < VariableType::nDim; ++iDim) {
402 jac(nVar-1,iDim+1) -= dissipConst *
V.velocity(iDim);
403 jac(nVar-1,0) += dissipConst *
pow(
V.velocity(iDim), 2);
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Class for defining the variables of the compressible Navier-Stokes solver.
Definition CNSVariable.hpp:38
su2double GetSensor(unsigned long iPoint) const
Get the pressure sensor.
Definition CVariable.hpp:965
A simple SIMD type relying on implicit vectorization, i.e. done by the compiler, explicitly vectorize...
Definition vectorization.hpp:89
@ Size
Definition vectorization.hpp:95
double passivedouble
Definition code_config.hpp:129
#define FORCEINLINE
Definition code_config.hpp:44
passivedouble su2double
Definition code_config.hpp:181
MatrixDbl< nDim+2 > pMatrix(const Double &gamma, const Double &density, const RandomAccessIterator &velocity, const Double &projVel, const Double &speedSound, const VectorDbl< nDim > &normal)
Compute and return the P tensor (compressible flow, ideal gas).
Definition common.hpp:136
MatrixDbl< nDim+2 > inviscidProjJac(const Double &gamma, RandomAccessIterator velocity, const Double &energy, const VectorDbl< nDim > &normal, const Double &scale)
Jacobian of the convective flux (compressible flow, ideal gas).
Definition common.hpp:280
MatrixDbl< nDim+2 > pMatrixInv(const Double &gamma, const Double &density, const RandomAccessIterator &velocity, const Double &projVel, const Double &speedSound, const VectorDbl< nDim > &normal)
Compute and return the inverse P tensor (compressible flow, ideal gas).
Definition common.hpp:198
VectorDbl< nDim+2 > inviscidProjFlux(const PrimVarType &V, const ConsVarType &U, const VectorDbl< nDim > &normal)
Convective projected (onto normal) flux (compressible flow).
Definition common.hpp:262
Double roeDissipation(const Int &iPoint, const Int &jPoint, const ENUM_ROELOWDISS type, const VariableType &solution)
(Low) Dissipation coefficient for Roe schemes.
Definition common.hpp:318
Double correctedSpectralRadius(const Int &iPoint, const Int &jPoint, const Double &avgLambda, const T &stretchParam, const VariableType &solution)
Correct spectral radius (avgLambda) for stretching.
Definition common.hpp:370
CPair< ReconVarType > reconstructPrimitives(const Int &iEdge, const Int &iPoint, const Int &jPoint, const su2double &gamma, const su2double &gasConst, const bool muscl, const su2double &kappa, const su2double &umusclRamp, const LIMITER limiterType, const CPair< PrimVarType > &V1st, const VectorDbl< nDim > &vector_ij, const VariableType &solution, Double &nonPhysical)
Retrieve primitive variables for points i/j, reconstructing them if needed.
Definition common.hpp:52
void scalarDissipationJacobian(const VariableType &V, const Double &gamma, Double dissipConst, MatrixDbl< nVar > &jac)
Update of a flux Jacobian due to a scalar dissipation term.
Definition common.hpp:389
FORCEINLINE ARRAY_T sqrt(const ARRAY_T &x)
Definition special_vectorization.hpp:116
FORCEINLINE ARRAY_T pow(const ARRAY_T &a, const ARRAY_T &b)
Definition special_vectorization.hpp:179
FORCEINLINE ARRAY_T sign(const ARRAY_T &x)
Definition special_vectorization.hpp:118
FORCEINLINE ARRAY_T abs(const ARRAY_T &x)
Definition special_vectorization.hpp:117
void muscl(typename CLaneTraits< Double >::Int iPoint, typename CLaneTraits< Double >::Int jPoint, const Vector< Double, nDim > &vector_ij, const Gradient_t &gradient, const Limiter_t &limiter, size_t iRow, CPair< VarType > &V, const CNonDeduced< Double > &kappa, const CNonDeduced< Double > &umusclRamp, size_t nVarGradRuntime)
U-MUSCL reconstruction of nVarGrad variables, from the gradient rows starting at iRow.
Definition util.hpp:508
auto dot(ForwardIterator iterator, const T *ptr) -> typename std::decay< decltype(*ptr)>::type
Dot product.
Definition util.hpp:203
Double gatherVariables(Int iPoint, const Container &vars, size_t iVar=0)
Gather a single variable, from column iVar (0 by default) of row iPoint of a 2D container,...
Definition util.hpp:277
@ V
Menter k-w SST model with vorticity production terms.
LIMITER
Types of slope limiters.
Definition option_structure.hpp:1038
ENUM_ROELOWDISS
Types of Roe Low Dissipation Schemes.
Definition option_structure.hpp:1668
@ NTS
Numerical Blending of Travin and Shur.
Definition option_structure.hpp:1671
@ NO_ROELOWDISS
No Roe Low Dissipation model.
Definition option_structure.hpp:1669
@ NTS_DUCROS
Numerical Blending of Travin and Shur + Ducros' Shock Sensor.
Definition option_structure.hpp:1672
@ FD_DUCROS
Numerical Blending based on DDES's F_d function + Ducros' Shock Sensor.
Definition option_structure.hpp:1673
@ FD
Numerical Blending based on DDES's F_d function.
Definition option_structure.hpp:1670
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131