Documentation 6b54b78464
Loading...
Searching...
No Matches
flamelet_edge_flux.hpp
Go to the documentation of this file.
1/*!
2 * \file flamelet_edge_flux.hpp
3 * \brief Flamelet transport as a third-layer scalar flux, see numerics/scalar/scalar_edge_flux.hpp.
4 * \author P. Gomes
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 "species_edge_flux.hpp"
31
32/*!
33 * \class CScalarFlux_Flamelet
34 * \ingroup ViscDiscr
35 * \brief Convection and diffusion of the flamelet controlling variables and passive species,
36 * which is species transport plus two preferential diffusion terms.
37 * \note The preferential diffusion terms read the beta scalars and their gradients from the
38 * auxiliary variables of the solver's own containers, which the per-marker ghost containers
39 * of a boundary do not carry. They are an interior edge term: boundaries instantiate
40 * CScalarFlux_Species, as they did before this model existed.
41 */
42template <class Double, class FlowIndices, int nDim, size_t nVar = Dynamic>
44 : public CScalarFluxSpeciesBase<Double, CScalarFlux_Flamelet<Double, FlowIndices, nDim, nVar>, FlowIndices, nDim,
45 nVar> {
46 public:
48 using Int = typename Base::Int;
49
50 explicit CScalarFlux_Flamelet(const CConfig& config)
51 : Base(config),
52 preferentialDiffusion(config.GetFlameletParsedOptions().preferential_diffusion),
53 nControlVars(config.GetFlameletParsedOptions().n_control_vars) {}
54
55 /*!
56 * \brief Preferential diffusion, two terms with the shape of the ordinary diffusion but of
57 * states the model synthesises: div(D grad(beta - phi)) for each controlling variable,
58 * and a thermal term div(beta_T D grad(T)) on the enthalpy equation.
59 * \note The thermal term has no implicit part, matching the treatment of the heat flux it
60 * models; the first term has the same thin shear layer Jacobian as the ordinary diffusion,
61 * because it is the same operator applied to a shifted state.
62 */
63 template <class VariableType>
64 FORCEINLINE void extraDiffusionTerms(const FlowIndices& idx, const ScalarFluxOptions& opt, Int iPoint,
65 const EdgeSide<VariableType>& side_i, Int jPoint,
66 const EdgeSide<VariableType>& side_j, const CPair<Double>& rho,
67 const Vector<Double, nDim>& normal, const Vector<Double, nDim>& vector_ij,
68 EdgeResidual<Double, nVar>& res) const {
69 if (!preferentialDiffusion) return;
70
71 const Double dist2_ij = fmax(squaredNorm(vector_ij), EPS);
72 const Double proj_vector_ij = dot(vector_ij, normal) / dist2_ij;
73 const Double proj_on_rho_i = proj_vector_ij / rho.i;
74 const Double proj_on_rho_j = proj_vector_ij / rho.j;
75
76 const Double diffTurb = Base::turbulentDiffusivity(idx, iPoint, side_i, jPoint, side_j);
77
78 /*--- The gradient of a controlling variable is subtracted from that of its beta scalar, so
79 * that what is added here is the difference from the ordinary diffusion already applied. ---*/
80 for (auto iScalar = 0u; iScalar < nControlVars; ++iScalar) {
81 const auto iBeta = betaIndex(iScalar);
82
83 const Double phi_i = gatherVariables(iPoint, side_i.scalarNodes.GetAuxVar(), iBeta) -
84 gatherVariables(iPoint, side_i.scalarNodes.GetSolution(), iScalar);
85 const Double phi_j = gatherVariables(jPoint, side_j.scalarNodes.GetAuxVar(), iBeta) -
86 gatherVariables(jPoint, side_j.scalarNodes.GetSolution(), iScalar);
87
88 auto grad_i = gatherVariables<nDim>(iPoint, side_i.scalarNodes.GetAuxVarGradient(), iBeta);
89 auto grad_j = gatherVariables<nDim>(jPoint, side_j.scalarNodes.GetAuxVarGradient(), iBeta);
90 const auto gradPhi_i = gatherVariables<nDim>(iPoint, side_i.scalarNodes.GetGradient(), iScalar);
91 const auto gradPhi_j = gatherVariables<nDim>(jPoint, side_j.scalarNodes.GetGradient(), iScalar);
92 for (int iDim = 0; iDim < nDim; ++iDim) {
93 grad_i(iDim) -= gradPhi_i(iDim);
94 grad_j(iDim) -= gradPhi_j(iDim);
95 }
96
97 const Double D_i = gatherVariables(iPoint, side_i.scalarNodes.GetDiffusivity(), iScalar);
98 const Double D_j = gatherVariables(jPoint, side_j.scalarNodes.GetDiffusivity(), iScalar);
99 const Double D = 0.5 * (rho.i * D_i + rho.j * D_j) + diffTurb;
100
101 const Double projGrad = projectedGradient(opt, grad_i, grad_j, phi_i, phi_j, normal, vector_ij, dist2_ij);
102
103 res.flux_i(iScalar) -= D * projGrad;
104 if (!opt.oneSided) res.flux_j(iScalar) += D * projGrad;
105
106 if (opt.implicit) {
107 res.jac_ii(iScalar, iScalar) += D * proj_on_rho_i;
108 if (!opt.oneSided) {
109 res.jac_ij(iScalar, iScalar) -= D * proj_on_rho_j;
110 res.jac_ji(iScalar, iScalar) -= D * proj_on_rho_i;
111 res.jac_jj(iScalar, iScalar) += D * proj_on_rho_j;
112 }
113 }
114 }
115
116 /*--- Thermal term, on the enthalpy equation alone, driven by the temperature gradient. ---*/
117 if (nControlVars <= I_ENTH) return;
118
119 const Double T_i = gatherVariables(iPoint, side_i.flowNodes->GetPrimitive(), idx.Temperature());
120 const Double T_j = gatherVariables(jPoint, side_j.flowNodes->GetPrimitive(), idx.Temperature());
121
122 const auto gradT_i = gatherVariables<nDim>(iPoint, side_i.flowNodes->GetGradient_Primitive(), idx.Temperature());
123 const auto gradT_j = gatherVariables<nDim>(jPoint, side_j.flowNodes->GetGradient_Primitive(), idx.Temperature());
124
125 const Double Dth_i = gatherVariables(iPoint, side_i.scalarNodes.GetAuxVar(), I_BETA_ENTH_THERMAL) *
126 gatherVariables(iPoint, side_i.scalarNodes.GetDiffusivity(), I_ENTH);
127 const Double Dth_j = gatherVariables(jPoint, side_j.scalarNodes.GetAuxVar(), I_BETA_ENTH_THERMAL) *
128 gatherVariables(jPoint, side_j.scalarNodes.GetDiffusivity(), I_ENTH);
129 const Double Dth = 0.5 * (rho.i * Dth_i + rho.j * Dth_j) + diffTurb;
130
131 const Double projGradT = projectedGradient(opt, gradT_i, gradT_j, T_i, T_j, normal, vector_ij, dist2_ij);
132
133 res.flux_i(I_ENTH) -= Dth * projGradT;
134 if (!opt.oneSided) res.flux_j(I_ENTH) += Dth * projGradT;
135 }
136
137 private:
138 const bool preferentialDiffusion;
139 const unsigned short nControlVars;
140
141 /*!
142 * \brief Auxiliary variable holding the beta scalar of a controlling variable.
143 */
144 static FORCEINLINE unsigned short betaIndex(unsigned short iScalar) {
145 switch (iScalar) {
146 case I_PROGVAR:
147 return I_BETA_PROGVAR;
148 case I_ENTH:
149 return I_BETA_ENTH;
150 default:
151 return I_BETA_MIXFRAC;
152 }
153 }
154
155 /*!
156 * \brief Average gradient of one synthesised state projected on the normal, corrected for
157 * skewness when asked, which is what the ordinary diffusion does for a transported one.
158 */
159 FORCEINLINE Double projectedGradient(const ScalarFluxOptions& opt, const Vector<Double, nDim>& grad_i,
160 const Vector<Double, nDim>& grad_j, const Double& phi_i, const Double& phi_j,
161 const Vector<Double, nDim>& normal, const Vector<Double, nDim>& vector_ij,
162 const Double& dist2_ij) const {
163 Vector<Double, nDim> avgGrad;
164 for (int iDim = 0; iDim < nDim; ++iDim) avgGrad(iDim) = 0.5 * (grad_i(iDim) + grad_j(iDim));
165
166 if (opt.correctGradient) {
167 const Double corr = (dot(avgGrad, vector_ij) - phi_j + phi_i) / dist2_ij;
168 for (int iDim = 0; iDim < nDim; ++iDim) avgGrad(iDim) -= corr * vector_ij(iDim);
169 }
170 return dot(avgGrad, normal);
171 }
172};
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
su2double GetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final
Get the value of the primitive variables gradient.
Definition CFlowVariable.hpp:147
su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const final
Get a primitive variable.
Definition CFlowVariable.hpp:95
Convection and diffusion of a mass fraction, conservative with a diagonal, i/j-symmetric diffusion ma...
Definition species_edge_flux.hpp:47
Double turbulentDiffusivity(const FlowIndices &idx, Int iPoint, const EdgeSide< VariableType > &side_i, Int jPoint, const EdgeSide< VariableType > &side_j) const
Turbulent contribution to the diffusivity, shared by every species and, in the flamelet model,...
Definition species_edge_flux.hpp:87
typename Base::Int Int
Definition species_edge_flux.hpp:53
Convection and diffusion of the flamelet controlling variables and passive species,...
Definition flamelet_edge_flux.hpp:45
CScalarFlux_Flamelet(const CConfig &config)
Definition flamelet_edge_flux.hpp:50
typename Base::Int Int
Definition flamelet_edge_flux.hpp:48
void extraDiffusionTerms(const FlowIndices &idx, const ScalarFluxOptions &opt, Int iPoint, const EdgeSide< VariableType > &side_i, Int jPoint, const EdgeSide< VariableType > &side_j, const CPair< Double > &rho, const Vector< Double, nDim > &normal, const Vector< Double, nDim > &vector_ij, EdgeResidual< Double, nVar > &res) const
Preferential diffusion, two terms with the shape of the ordinary diffusion but of states the model sy...
Definition flamelet_edge_flux.hpp:64
Double Double
Definition scalar_edge_flux.hpp:318
const FlowIndices idx
Definition scalar_edge_flux.hpp:338
static constexpr int nDim
Definition scalar_edge_flux.hpp:320
#define FORCEINLINE
Definition code_config.hpp:44
auto squaredNorm(ForwardIterator iterator) -> typename std::decay< decltype(*iterator)>::type
Squared norm.
Definition util.hpp:231
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
@ I_BETA_ENTH_THERMAL
Preferential diffusion scalar for temperature.
Definition option_structure.hpp:1543
@ I_BETA_MIXFRAC
Preferential diffusion scalar for mixture fraction.
Definition option_structure.hpp:1545
@ I_BETA_ENTH
Preferential diffusion scalar for total enthalpy.
Definition option_structure.hpp:1544
@ I_BETA_PROGVAR
Preferential diffusion scalar for the progress variable.
Definition option_structure.hpp:1542
constexpr passivedouble EPS
Error scale.
Definition option_structure.hpp:100
@ I_PROGVAR
Definition option_structure.hpp:1516
@ I_ENTH
Definition option_structure.hpp:1517
Species transport as a third-layer scalar flux, see numerics/scalar/scalar_edge_flux....
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
Residual of one edge, accumulated by the convective and the diffusive terms.
Definition util.hpp:169
Vector< Double, Size > flux_j
Definition util.hpp:176
Matrix< Double, Size, Size > jac_jj
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ji
Definition util.hpp:177
Vector< Double, Size > flux_i
Definition util.hpp:176
Matrix< Double, Size, Size > jac_ii
Definition util.hpp:177
Matrix< Double, Size, Size > jac_ij
Definition util.hpp:177
Locates the data of one endpoint of an edge.
Definition scalar_edge_flux.hpp:42
const CFlowVariable * flowNodes
Flow variables, null for solid heat transfer.
Definition scalar_edge_flux.hpp:44
const VariableType & scalarNodes
Scalar solver variables.
Definition scalar_edge_flux.hpp:43
Loop invariant flags for a scalar edge flux, built once outside the edge loop so the compiler can uns...
Definition scalar_edge_flux.hpp:55
bool implicit
Whether the Jacobians are assembled, and so computed.
Definition scalar_edge_flux.hpp:60
bool oneSided
Whether only the row of i is assembled.
Definition scalar_edge_flux.hpp:63
bool correctGradient
Definition scalar_edge_flux.hpp:58