Documentation 6b54b78464
Loading...
Searching...
No Matches
species_edge_flux.hpp
Go to the documentation of this file.
1/*!
2 * \file species_edge_flux.hpp
3 * \brief Species 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 "../scalar/scalar_edge_flux.hpp"
31
32/*!
33 * \class CScalarFluxSpeciesBase
34 * \ingroup ViscDiscr
35 * \brief Convection and diffusion of a mass fraction, conservative with a diagonal,
36 * i/j-symmetric diffusion matrix. Unlike SA/SST/LM, the equation count is only known at
37 * runtime (one per transported species), so this is the framework's first Dynamic-nVar
38 * model: nEqn is passed to the base explicitly, and coefficients() loops to it rather than
39 * to a compile-time nVar.
40 * \note This carries no finalizeFlux of its own: the inherited CUpwScalarFlux one is exactly
41 * flux(iVar) = a0*rho_i*Y_i(iVar) + a1*rho_j*Y_j(iVar), Conservative weighting by density,
42 * which is the model's whole convective term.
43 * \note It takes the most derived class as a parameter so that the flamelet model, which adds a
44 * preferential diffusion term to the same coefficients, is a sibling rather than a copy.
45 */
46template <class Double, class Derived, class FlowIndices, int nDim, size_t nVar>
47class CScalarFluxSpeciesBase : public CUpwScalarBase<Double, Derived, FlowIndices, nDim, nVar> {
48 public:
49 static constexpr bool Conservative = true;
50 static constexpr bool DiagonalDiffusion = true;
51
53 using Int = typename Base::Int;
54
55 explicit CScalarFluxSpeciesBase(const CConfig& config)
56 : Base(config, config.GetnSpecies()),
57 turbulence(config.GetKind_Turb_Model() != TURB_MODEL::NONE),
58 Sc_t(config.GetSchmidt_Number_Turbulent()) {}
59
60 /*!
61 * \brief Diffusion coefficients, an i/j average of (rho * mass diffusivity) per species, plus a
62 * turbulent (mu_t/Sc_t) contribution shared by every species, when a turbulence model is
63 * active; identical for both edge sides.
64 */
65 template <class VariableType>
67 const EdgeSide<VariableType>& side_i, Int jPoint,
68 const EdgeSide<VariableType>& side_j,
69 const CPair<Double>& rho) const {
70 const Double diffTurb = turbulentDiffusivity(idx, iPoint, side_i, jPoint, side_j);
71
73 for (size_t iVar = 0; iVar < this->nEqn; ++iVar) {
74 const Double D_lam_i = gatherVariables(iPoint, side_i.scalarNodes.GetDiffusivity(), iVar);
75 const Double D_lam_j = gatherVariables(jPoint, side_j.scalarNodes.GetDiffusivity(), iVar);
76 D(iVar) = 0.5 * (rho.i * D_lam_i + rho.j * D_lam_j) + diffTurb;
77 }
78 return {D, D};
79 }
80
81 protected:
82 /*!
83 * \brief Turbulent contribution to the diffusivity, shared by every species and, in the
84 * flamelet model, by the preferential diffusion terms.
85 */
86 template <class VariableType>
87 FORCEINLINE Double turbulentDiffusivity(const FlowIndices& idx, Int iPoint, const EdgeSide<VariableType>& side_i,
88 Int jPoint, const EdgeSide<VariableType>& side_j) const {
89 if (!turbulence) return Double(0.0);
90
91 const Double muT_i = gatherVariables(iPoint, side_i.flowNodes->GetPrimitive(), idx.EddyViscosity());
92 const Double muT_j = gatherVariables(jPoint, side_j.flowNodes->GetPrimitive(), idx.EddyViscosity());
93 return 0.5 * (muT_i / Sc_t + muT_j / Sc_t);
94 }
95
96 private:
97 const bool turbulence;
98 const su2double Sc_t;
99};
100
101/*!
102 * \class CScalarFlux_Species
103 * \ingroup ViscDiscr
104 * \brief Convection and diffusion of the species transport model.
105 */
106template <class Double, class FlowIndices, int nDim, size_t nVar = Dynamic>
108 : public CScalarFluxSpeciesBase<Double, CScalarFlux_Species<Double, FlowIndices, nDim, nVar>, FlowIndices, nDim,
109 nVar> {
110 public:
112 using Base::Base;
113};
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 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
CScalarFluxSpeciesBase(const CConfig &config)
Definition species_edge_flux.hpp:55
static constexpr bool DiagonalDiffusion
Definition species_edge_flux.hpp:50
CPair< Vector< Double, Base::Size > > coefficients(const FlowIndices &idx, Int iPoint, const EdgeSide< VariableType > &side_i, Int jPoint, const EdgeSide< VariableType > &side_j, const CPair< Double > &rho) const
Diffusion coefficients, an i/j average of (rho * mass diffusivity) per species, plus a turbulent (mu_...
Definition species_edge_flux.hpp:66
static constexpr bool Conservative
Definition species_edge_flux.hpp:49
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 species transport model.
Definition species_edge_flux.hpp:109
Upwind convection and diffusion of a transported scalar, accumulated into one residual,...
Definition scalar_edge_flux.hpp:316
typename CLaneTraits< Double >::Int Int
Definition scalar_edge_flux.hpp:319
const size_t nEqn
Equations of the model, which a dynamic one gives to its base.
Definition scalar_edge_flux.hpp:339
Double Double
Definition scalar_edge_flux.hpp:318
const FlowIndices idx
Definition scalar_edge_flux.hpp:338
#define FORCEINLINE
Definition code_config.hpp:44
passivedouble su2double
Definition code_config.hpp:181
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
@ NONE
Definition option_structure.hpp:282
TURB_MODEL
Types of turbulent models.
Definition option_structure.hpp:1066
Simple pair type for i/j variables.
Definition util.hpp:130
T i
Definition util.hpp:131
T j
Definition util.hpp:131
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