30#include "../../CNumericsSIMD.hpp"
31#include "../../util.hpp"
32#include "../variables.hpp"
34#include "../../../variables/CEulerVariable.hpp"
35#include "../../../../../Common/include/geometry/CGeometry.hpp"
49template<
class Derived,
class Base>
70 gamma(config.GetGamma()),
71 gasConst(config.GetGas_ConstantND()),
97 const bool implicit = (config.GetKind_TimeIntScheme() ==
EULER_IMPLICIT);
98 const su2double umusclRamp = config.GetMUSCLRampValue() * config.GetNewtonKrylovRelaxation();
99 const auto& solution =
static_cast<const CEulerVariable&
>(solution_);
101 const auto iPoint = geometry.edges->GetNode(iEdge,0);
102 const auto jPoint = geometry.edges->GetNode(iEdge,1);
106 const auto vector_ij = distanceVector<nDim>(iPoint, jPoint, geometry.nodes->GetCoord());
108 const auto normal = gatherVariables<nDim>(iEdge, geometry.edges->GetNormal());
109 const auto area =
norm(normal);
111 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
112 unitNormal(iDim) = normal(iDim) / area;
118 V1st.
i.all = gatherVariables<nPrimVar>(iPoint, solution.GetPrimitive());
119 V1st.
j.all = gatherVariables<nPrimVar>(jPoint, solution.GetPrimitive());
123 auto V = reconstructPrimitives<CCompressiblePrimitives<nDim,nPrimVarGrad> >(
125 typeLimiter, V1st, vector_ij, solution, nonPhysical);
135 const auto derived =
static_cast<const Derived*
>(
this);
138 derived->finalizeFlux(flux, jac_i, jac_j, implicit, area, unitNormal, normal,
139 V, U, iPoint, jPoint, nonPhysical, solution, geometry);
143 Base::viscousTerms(iEdge, iPoint, jPoint, V1st, solution_, vector_ij, geometry,
144 config, area, unitNormal, implicit, flux, jac_i, jac_j);
153 updateMask, flux, jac_i, jac_j, vector, matrix);
166template<
class Decorator>
186 template<
class... Ts>
188 kappa(config.GetRoe_Kappa()),
189 entropyFix(config.GetEntropyFix_Coeff()),
190 typeDissip(static_cast<
ENUM_ROELOWDISS>(config.GetKind_RoeLowDiss())) {
197 template<
class PrimVarType,
class ConsVarType,
class... Ts>
209 const Double& nonPhysical,
219 Double projGridVel = 0.0, projVel = roeAvg.projVel;
222 projGridVel = 0.5*(
dot(gatherVariables<nDim>(iPoint,gridVel), unitNormal)+
223 dot(gatherVariables<nDim>(jPoint,gridVel), unitNormal));
224 projVel -= projGridVel;
230 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
231 lambda(iDim) = projVel;
233 lambda(nDim) = projVel + roeAvg.speedSound;
234 lambda(nDim+1) = projVel - roeAvg.speedSound;
238 Double lambdaMin = fmax(entropyFix, nonPhysical) * (
abs(projVel) + roeAvg.speedSound);
239 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
240 lambda(iVar) = fmax(
abs(lambda(iVar)), lambdaMin);
248 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
249 flux(iVar) = 0.5 * (flux_i(iVar) + flux_j(iVar));
259 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
260 Double dFdU = projGridVel * area * 0.5;
261 flux(iVar) -= dFdU * (U.
i.all(iVar) + U.
j.all(iVar));
264 jac_i(iVar,iVar) -= dFdU;
265 jac_j(iVar,iVar) -= dFdU;
272 auto pMat =
pMatrix(
gamma, roeAvg.density, roeAvg.velocity,
273 roeAvg.projVel, roeAvg.speedSound, unitNormal);
278 roeAvg.projVel, roeAvg.speedSound, unitNormal);
283 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
284 deltaU(iVar) = U.
j.all(iVar) - U.
i.all(iVar);
291 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
292 for (
size_t jVar = 0; jVar <
nVar; ++jVar) {
295 Double projModJacTensor = 0.0;
296 for (
size_t kVar = 0; kVar <
nVar; ++kVar) {
297 projModJacTensor += pMat(iVar,kVar) * lambda(kVar) * pMatInv(kVar,jVar);
300 Double dDdU = projModJacTensor * (1-kappa) * area * dissipation;
304 flux(iVar) -= dDdU * deltaU(jVar);
307 jac_i(iVar,jVar) += dDdU;
308 jac_j(iVar,jVar) -= dDdU;
320template<
class Decorator>
338 template<
class... Ts>
340 alpha(config.GetMSW_Alpha()) {
346 template<
class PrimVarType,
class ConsVarType,
class... Ts>
358 const Double& nonPhysical,
369 const Double w = 0.25 * (1 -
sign(dp) * (1 -
exp(-100 *
abs(dp)))) * (1 - nonPhysical);
370 const Double onemw = 1 - w;
374 Vweighted.
i.all(iVar) = onemw *
V.i.all(iVar) + w *
V.j.all(iVar);
375 Vweighted.
j.all(iVar) = onemw *
V.j.all(iVar) + w *
V.i.all(iVar);
380 Double projGridVel_i = 0.0, projGridVel_j = 0.0;
383 const Double vn_i =
dot(gatherVariables<nDim>(iPoint, gridVel), unitNormal);
384 const Double vn_j =
dot(gatherVariables<nDim>(jPoint, gridVel), unitNormal);
385 projGridVel_i = onemw * vn_i + w * vn_j;
386 projGridVel_j = onemw * vn_j + w * vn_i;
388 Double projVel_i =
dot(Vweighted.
i.velocity(), unitNormal) - projGridVel_i;
389 Double projVel_j =
dot(Vweighted.
j.velocity(), unitNormal) - projGridVel_j;
394 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
395 lambda(iDim) = fmax(projVel_i, 0);
397 lambda(nDim) = fmax(projVel_i + soundSpeed_i, 0);
398 lambda(nDim+1) = fmax(projVel_i - soundSpeed_i, 0);
400 auto pMat =
pMatrix(
gamma, Vweighted.
i.density(), Vweighted.
i.velocity(),
401 projVel_i, soundSpeed_i, unitNormal);
403 projVel_i, soundSpeed_i, unitNormal);
405 auto updateFlux = [&](
const auto& u,
auto& jac) {
406 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
407 for (
size_t jVar = 0; jVar <
nVar; ++jVar) {
410 Double projModJacTensor = 0.0;
411 for (
size_t kVar = 0; kVar <
nVar; ++kVar) {
412 projModJacTensor += pMat(iVar,kVar) * lambda(kVar) * pMatInv(kVar,jVar);
414 Double dFdU = projModJacTensor * area;
416 flux(iVar) += dFdU * u(jVar);
417 jac(iVar, jVar) = dFdU;
421 updateFlux(U.
i.all, jac_i);
425 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
426 lambda(iDim) = fmin(projVel_j, 0);
428 lambda(nDim) = fmin(projVel_j + soundSpeed_j, 0);
429 lambda(nDim+1) = fmin(projVel_j - soundSpeed_j, 0);
431 pMat =
pMatrix(
gamma, Vweighted.
j.density(), Vweighted.
j.velocity(),
432 projVel_j, soundSpeed_j, unitNormal);
434 projVel_j, soundSpeed_j, unitNormal);
435 updateFlux(U.
j.all, jac_j);
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Class for defining the variables of the compressible Euler solver.
Definition CEulerVariable.hpp:46
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
CPoint * nodes
Node vector (dual grid information).
Definition CGeometry.hpp:253
MSW scheme with switch to SW based on a pressure sensor.
Definition upwind.hpp:321
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const VectorDbl< nDim > &unitNormal, const VectorDbl< nDim > &normal, const CPair< PrimVarType > &V, const CPair< ConsVarType > &U, const Int &iPoint, const Int &jPoint, const Double &nonPhysical, const CEulerVariable &solution, const CGeometry &geometry, Ts &...) const
Implementation of the flux.
Definition upwind.hpp:347
CMSWScheme(const CConfig &config, unsigned iMesh, Ts &... args)
Constructor, store some constants and forward args to base.
Definition upwind.hpp:339
const su2double alpha
Definition upwind.hpp:329
su2double * GetGridVel(unsigned long iPoint)
Get the value of the grid velocity at the point.
Definition CPoint.hpp:816
Classical Roe scheme.
Definition upwind.hpp:167
CRoeScheme(const CConfig &config, Ts &... args)
Constructor, store some constants and forward to base.
Definition upwind.hpp:187
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const VectorDbl< nDim > &unitNormal, const VectorDbl< nDim > &normal, const CPair< PrimVarType > &V, const CPair< ConsVarType > &U, const Int &iPoint, const Int &jPoint, const Double &nonPhysical, const CEulerVariable &solution, const CGeometry &geometry, Ts &...) const
Updates flux and Jacobians with standard Roe dissipation.
Definition upwind.hpp:198
Class for holding and manipulating vectors needed by linear solvers.
Definition CSysVector.hpp:195
Base class for upwind schemes, derived classes implement details of the convective flux in a const "f...
Definition upwind.hpp:50
const su2double umusclKappa
Definition upwind.hpp:62
const su2double gasConst
Definition upwind.hpp:58
static constexpr size_t nPrimVarGrad
Definition upwind.hpp:54
const bool muscl
Definition upwind.hpp:61
static constexpr size_t nPrimVar
Definition upwind.hpp:55
void ComputeFlux(const Int iEdge, const CConfig &config, const CGeometry &geometry, const CVariable &solution_, const UpdateType updateType, const Double updateMask, CSysVector< su2double > &vector, SparseMatrixType &matrix, su2activevector *edgeMassFluxes) const final
Implementation of the base Roe flux.
Definition upwind.hpp:83
CUpwindBase(const CConfig &config, unsigned iMesh, Ts &... args)
Constructor, store some constants and forward args to base.
Definition upwind.hpp:69
const bool dynamicGrid
Definition upwind.hpp:60
const LIMITER typeLimiter
Definition upwind.hpp:63
const bool finestGrid
Definition upwind.hpp:59
const su2double gamma
Definition upwind.hpp:57
static constexpr size_t nVar
Definition upwind.hpp:53
Main class for defining the variables.
Definition CVariable.hpp:50
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
#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
Helper functions for viscous methods.
FORCEINLINE ARRAY_T exp(const ARRAY_T &x)
Definition special_vectorization.hpp:156
FORCEINLINE ARRAY_T sqrt(const ARRAY_T &x)
Definition special_vectorization.hpp:116
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 StartPreacc()
Starts a new preaccumulation section and sets the input variables.
Definition ad_structure.hpp:215
UpdateType
Ways to update vectors and system matrices. COLORING is the typical i/j update, whereas for REDUCTION...
Definition util.hpp:44
void stopPreacc(Vector< Double, nVar > &x)
Stop the AD preaccumulation.
Definition util.hpp:392
constexpr size_t Max(size_t a, size_t b)
Constexpr version of max.
Definition util.hpp:124
void updateEdgeMassFlux(Int iEdge, const Double &massFlux, su2activevector *target)
Store the (scalar) mass flux of an edge, e.g. for "bounded scalar" transport equations.
Definition util.hpp:636
Double norm(const Vector< Double, nDim > &vector)
Vector norm.
Definition util.hpp:267
void updateLinearSystem(Int iEdge, Int iPoint, Int jPoint, bool implicit, UpdateType updateType, Double updateMask, const Vector< Double, nVar > &flux, const Matrix< Double, nVar, nVar > &jac_i, const Matrix< Double, nVar, nVar > &jac_j, CSysVector< su2double > &vector, SparseMatrixType &matrix)
Update the matrix and right-hand-side of a linear system with one conservative flux.
Definition util.hpp:571
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
@ EULER_IMPLICIT
Implicit Euler time integration definition.
Definition option_structure.hpp:1711
const unsigned int MESH_0
Definition of the finest grid level.
Definition option_structure.hpp:88
@ 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
Type to store compressible conservative (i.e. solution) variables.
Definition variables.hpp:70
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
CRoeVariables< nDim > roeAveragedVariables(const Double &gamma, const CPair< PrimVarType > &V, const VectorDbl< nDim > &normal)
Compute Roe-averaged variables from pair of primitive variables.
Definition variables.hpp:116
CCompressibleConservatives< nDim > compressibleConservatives(const CCompressiblePrimitives< nDim, N > &V)
Primitive to conservative conversion.
Definition variables.hpp:90