30#include "../../CNumericsSIMD.hpp"
31#include "../../util.hpp"
32#include "../variables.hpp"
34#include "../../../variables/CEulerVariable.hpp"
35#include "../../../../../Common/include/geometry/CGeometry.hpp"
44template<
class Derived,
class Base>
49 static constexpr size_t nPrimVar =
Max(Base::nPrimVar, nDim+5);
61 gamma(config.GetGamma()),
62 fixFactor(config.GetCent_Jac_Fix_Factor()),
69 template<
class T,
size_t N>
97 const bool implicit = (config.GetKind_TimeIntScheme() ==
EULER_IMPLICIT);
98 const auto& solution =
static_cast<const CEulerVariable&
>(solution_);
100 const auto iPoint = geometry.edges->GetNode(iEdge,0);
101 const auto jPoint = geometry.edges->GetNode(iEdge,1);
105 const auto normal = gatherVariables<nDim>(iEdge, geometry.edges->GetNormal());
106 const auto area =
norm(normal);
108 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
109 unitNormal(iDim) = normal(iDim) / area;
115 V.
i.all = gatherVariables<nPrimVar>(iPoint, solution.GetPrimitive());
116 V.j.all = gatherVariables<nPrimVar>(jPoint, solution.GetPrimitive());
119 for (
size_t iVar = 0; iVar <
nPrimVar; ++iVar) {
120 avgV.
all(iVar) = 0.5 * (
V.i.all(iVar) +
V.j.all(iVar));
132 for (
size_t iVar = 0; iVar <
nVar-1; ++iVar) {
133 diffU(iVar) = U.
i.all(iVar) - U.
j.all(iVar);
135 diffU(
nVar-1) =
V.i.density()*
V.i.enthalpy() -
V.j.density()*
V.j.enthalpy();
151 const auto& gridVel = geometry.nodes->GetGridVel();
152 projGridVel = 0.5*(
dot(gatherVariables<nDim>(iPoint,gridVel), normal)+
153 dot(gatherVariables<nDim>(jPoint,gridVel), normal));
155 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
156 flux(iVar) -= projGridVel * avgU.all(iVar);
158 jac_i(iVar,iVar) -= 0.5 * projGridVel;
159 jac_j(iVar,iVar) -= 0.5 * projGridVel;
168 const auto derived =
static_cast<const Derived*
>(
this);
170 derived->finalizeFlux(flux, jac_i, jac_j, implicit, area, projVel, avgV,
V,
171 diffU, iPoint, jPoint, geometry, solution, unitNormal);
175 Base::viscousTerms(iEdge, iPoint, jPoint, avgV,
V, solution_, geometry,
176 config, area, unitNormal, implicit, flux, jac_i, jac_j);
185 updateMask, flux, jac_i, jac_j, vector, matrix);
198template<
class Decorator>
214 template<
class... Ts>
216 kappa2(config.GetKappa_2nd_Flow()),
217 kappa4(config.GetKappa_4th_Flow()) {
224 template<
class PrimVarType,
class... Ts>
231 const PrimVarType& avgV,
240 Double lambda =
abs(projVel) + avgV.speedSound()*area;
247 const Double sc2 = 3 * (ni+nj) / (ni*nj);
252 const Double eps2 = kappa2 * 0.5*(si+sj) * sc2;
253 const Double eps4 = fmax(0.0, kappa4-eps2) * sc4;
260 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
261 flux(iVar) += (eps2*diffU(iVar) - eps4*(lapl_i(iVar)-lapl_j(iVar))) * lambda;
278template<
class Decorator>
294 template<
class... Ts>
296 kappa2(config.GetKappa_2nd_Flow()),
297 kappa4(config.GetKappa_4th_Flow()),
298 entropyFix(config.GetEntropyFix_Coeff()) {
305 template<
class PrimVarType,
class... Ts>
312 const PrimVarType& avgV,
326 const Double sc2 = 3 * (ni+nj) / (ni*nj);
331 const Double eps2 = kappa2 * 0.5*(si+sj) * sc2;
332 const Double eps4 = fmax(0.0, kappa4-eps2) * sc4;
338 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
339 scalarDissip(iVar) = eps2*diffU(iVar) - eps4*(lapl_i(iVar)-lapl_j(iVar));
351 const auto unitProjVel =
dot(avgV.velocity(), unitNormal);
353 auto pMat =
pMatrix(
gamma, avgV.density(), avgV.velocity(),
354 unitProjVel, avgV.speedSound(), unitNormal);
357 unitProjVel, avgV.speedSound(), unitNormal);
362 for (
size_t iDim = 0; iDim < nDim; ++iDim) {
363 lambda(iDim) = projVel;
365 lambda(nDim) = projVel + avgV.speedSound()*area;
366 lambda(nDim+1) = projVel - avgV.speedSound()*area;
368 const Double maxLambda = fmax(lambda(nDim), -lambda(nDim+1));
370 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
371 lambda(iVar) = fmax(
abs(lambda(iVar)), entropyFix*maxLambda);
376 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
377 for (
size_t jVar = 0; jVar <
nVar; ++jVar) {
381 for (
size_t kVar = 0; kVar <
nVar; ++kVar) {
382 scale += pMat(iVar,kVar) * lambda(kVar) * pMatInv(kVar,jVar);
387 flux(iVar) += scale * scalarDissip(jVar);
390 for (
size_t kVar = 0; kVar <
nVar; ++kVar) {
391 jac_i(iVar,kVar) += scale * scalarJac(jVar,kVar);
392 jac_j(iVar,kVar) -= scale * scalarJac(jVar,kVar);
405template<
class Decorator>
420 template<
class... Ts>
422 kappa2(config.GetKappa_2nd_Flow()) {
429 template<
class PrimVarType,
class... Ts>
436 const PrimVarType& avgV,
445 Double lambda =
abs(projVel) + avgV.speedSound()*area;
452 const Double sc2 = 3 * (ni+nj) / (ni*nj);
456 const Double dissip = kappa2 * 0.5*(si+sj) * sc2 * lambda;
460 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
461 flux(iVar) += dissip * diffU(iVar);
476template<
class Decorator>
491 template<
class... Ts>
493 kappa0(config.GetKappa_1st_Flow()) {
500 template<
class PrimVarType,
class... Ts>
507 const PrimVarType& avgV,
516 Double lambda =
abs(projVel) + avgV.speedSound()*area;
523 const Double dissip = kappa0 * nDim * (ni+nj) / (ni*nj) * lambda;
527 for (
size_t iVar = 0; iVar <
nVar; ++iVar) {
528 flux(iVar) += dissip * diffU(iVar);
simd::Array< su2double > Double
Define Double and Int SIMD types.
Definition CNumericsSIMD.hpp:36
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Base class for Centered schemes, derived classes implement the dissipation term in a const "finalizeF...
Definition centered.hpp:45
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 centered flux.
Definition centered.hpp:83
CCenteredBase(const CConfig &config, Ts &... args)
Constructor, store some constants and forward args to base.
Definition centered.hpp:60
const bool dynamicGrid
Definition centered.hpp:53
const su2double fixFactor
Definition centered.hpp:52
static constexpr size_t nVar
Definition centered.hpp:48
const su2double gamma
Definition centered.hpp:51
static Double numNeighbor(const simd::Array< T, N > &idx, const CGeometry &geometry)
Special treatment needed to fetch integer data.
Definition centered.hpp:70
static constexpr size_t nPrimVar
Definition centered.hpp:49
static Double numNeighbor(unsigned long idx, const CGeometry &geometry)
Definition centered.hpp:75
const su2double stretchParam
Definition centered.hpp:54
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
Classical JST scheme with scalar dissipation.
Definition centered.hpp:199
CJSTScheme(const CConfig &config, Ts &... args)
Constructor, forward everything to base.
Definition centered.hpp:215
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const Double &projVel, const PrimVarType &avgV, const CPair< PrimVarType > &V, const VectorDbl< nVar > &diffU, const Int &iPoint, const Int &jPoint, const CGeometry &geometry, const CEulerVariable &solution, Ts &...) const
Updates flux and Jacobians with JST dissipation.
Definition centered.hpp:225
JST scheme without 4th order dissipation.
Definition centered.hpp:406
CJSTkeScheme(const CConfig &config, Ts &... args)
Constructor, forward everything to base.
Definition centered.hpp:421
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const Double &projVel, const PrimVarType &avgV, const CPair< PrimVarType > &V, const VectorDbl< nVar > &diffU, const Int &iPoint, const Int &jPoint, const CGeometry &geometry, const CEulerVariable &solution, Ts &...) const
Updates flux and Jacobians with 2nd order dissipation.
Definition centered.hpp:430
JST scheme with matrix dissipation.
Definition centered.hpp:279
CJSTmatScheme(const CConfig &config, Ts &... args)
Constructor, forward everything to base.
Definition centered.hpp:295
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const Double &projVel, const PrimVarType &avgV, const CPair< PrimVarType > &V, const VectorDbl< nVar > &diffU, const Int &iPoint, const Int &jPoint, const CGeometry &geometry, const CEulerVariable &solution, const VectorDbl< nDim > &unitNormal, Ts &...) const
Updates flux and Jacobians.
Definition centered.hpp:306
Lax–Friedrichs 1st order scheme.
Definition centered.hpp:477
void finalizeFlux(VectorDbl< nVar > &flux, MatrixDbl< nVar > &jac_i, MatrixDbl< nVar > &jac_j, const bool implicit, const Double &area, const Double &projVel, const PrimVarType &avgV, const CPair< PrimVarType > &V, const VectorDbl< nVar > &diffU, const Int &iPoint, const Int &jPoint, const CGeometry &geometry, const CEulerVariable &solution, Ts &...) const
Updates flux and Jacobians with 1st order scalar dissipation.
Definition centered.hpp:501
CLaxScheme(const CConfig &config, Ts &... args)
Constructor, forward everything to base.
Definition centered.hpp:492
unsigned short GetnNeighbor(unsigned long iPoint) const
Get the number of neighbor of a point.
Definition CPoint.hpp:466
Class for holding and manipulating vectors needed by linear solvers.
Definition CSysVector.hpp:195
Main class for defining the variables.
Definition CVariable.hpp:50
su2double * GetUndivided_Laplacian(unsigned long iPoint)
Get the undivided laplacian of the solution.
Definition CVariable.hpp:993
su2double GetSensor(unsigned long iPoint) const
Get the pressure sensor.
Definition CVariable.hpp:965
#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 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
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
Helper functions for viscous methods.
FORCEINLINE ARRAY_T pow(const ARRAY_T &a, const ARRAY_T &b)
Definition special_vectorization.hpp:179
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
@ V
Menter k-w SST model with vorticity production terms.
Type to store compressible conservative (i.e. solution) variables.
Definition variables.hpp:70
Type to store compressible primitive variables and access them by name.
Definition variables.hpp:37
VectorDbl< nVar > all
Definition variables.hpp:40
Double & velocity(size_t iDim)
Definition variables.hpp:45
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
CCompressibleConservatives< nDim > compressibleConservatives(const CCompressiblePrimitives< nDim, N > &V)
Primitive to conservative conversion.
Definition variables.hpp:90