Skip to content

Commit c3c6649

Browse files
lkuschpcarruscagbigfooted
authored
Source term for axisymmetry in species transport (#1785)
* Source term for axisymmetry in species transport added (need to add test case) Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Co-authored-by: Nijso <bigfootedrockmidget@hotmail.com>
1 parent 69f7911 commit c3c6649

5 files changed

Lines changed: 139 additions & 16 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5354,9 +5354,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
53545354
}
53555355
}
53565356

5357-
// For now, do not allow axisymmetric simulations
5358-
if (Axisymmetric) SU2_MPI::Error("Species transport currently not possible with axissymmetric flow.", CURRENT_FUNCTION);
5359-
53605357
if(Kind_TimeIntScheme_Species != EULER_IMPLICIT &&
53615358
Kind_TimeIntScheme_Species != EULER_EXPLICIT){
53625359
SU2_MPI::Error("Only TIME_DISCRE_TURB = EULER_IMPLICIT, EULER_EXPLICIT have been implemented in the scalar solver.", CURRENT_FUNCTION);

SU2_CFD/include/numerics/species/species_sources.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ template <class FlowIndices>
6868
class CSourceAxisymmetric_Species : public CSourceBase_Species {
6969
protected:
7070
const FlowIndices idx; /*!< \brief Object to manage the access to the flow primitives. */
71-
bool implicit;
71+
const bool implicit;
72+
const bool viscous;
73+
const bool turbulence;
74+
const bool incompressible;
75+
const su2double Sc_t;
7276

7377
public:
7478
/*!

SU2_CFD/include/solvers/CSpeciesSolver.hpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
class CSpeciesSolver : public CScalarSolver<CSpeciesVariable> {
4040
protected:
41-
unsigned short Inlet_Position; /*!< \brief Column index for scalar variables in inlet files. */
41+
unsigned short Inlet_Position; /*!< \brief Column index for scalar variables in inlet files. */
4242
vector<su2activematrix> Inlet_SpeciesVars; /*!< \brief Species variables at inlet profiles. */
4343

4444
public:
@@ -145,9 +145,20 @@ class CSpeciesSolver : public CScalarSolver<CSpeciesVariable> {
145145
void BC_Outlet(CGeometry* geometry, CSolver** solver_container, CNumerics* conv_numerics, CNumerics* visc_numerics,
146146
CConfig* config, unsigned short val_marker) final;
147147

148-
/*--- Note that BC_Sym_Plane, BC_HeatFlux_Wall, BC_Isothermal_Wall are all treated as zero-flux BC for the
149-
* mass-factions, which can be fulfilled by no additional residual contribution on these nodes.
150-
* If a specified mass-fractions flux (like BC_HeatFlux_Wall) or a constant mass-fraction on the boundary
151-
* (like BC_Isothermal_Wall) are implemented the respective CHeatSolver implementations can act as a starting
152-
* point ---*/
148+
/*--- Note that BC_Sym_Plane, BC_HeatFlux_Wall, BC_Isothermal_Wall are all treated as zero-flux BC for the
149+
* mass-factions, which can be fulfilled by no additional residual contribution on these nodes.
150+
* If a specified mass-fractions flux (like BC_HeatFlux_Wall) or a constant mass-fraction on the boundary
151+
* (like BC_Isothermal_Wall) are implemented the respective CHeatSolver implementations can act as a starting
152+
* point ---*/
153+
154+
/*!
155+
* \brief Source term computation for axisymmetric flow.
156+
* \param[in] geometry - Geometrical definition of the problem.
157+
* \param[in] solver_container - Container vector with all the solutions.
158+
* \param[in] numerics_container - Container for description of the numerical method.
159+
* \param[in] config - Definition of the particular problem.
160+
* \param[in] iMesh - Index of the mesh in multigrid computations.
161+
*/
162+
void Source_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config,
163+
unsigned short iMesh) override;
153164
};

SU2_CFD/src/numerics/species/species_sources.cpp

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,79 @@ template <class T>
5757
CSourceAxisymmetric_Species<T>::CSourceAxisymmetric_Species(unsigned short val_nDim, unsigned short val_nVar,
5858
const CConfig* config)
5959
: CSourceBase_Species(val_nDim, val_nVar, config),
60-
idx(val_nDim, config->GetnSpecies()) {
61-
implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT);
60+
idx(val_nDim, config->GetnSpecies()),
61+
implicit(config->GetKind_TimeIntScheme_Species() == EULER_IMPLICIT),
62+
viscous(config->GetViscous()),
63+
turbulence(config->GetKind_Turb_Model() != TURB_MODEL::NONE),
64+
incompressible(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE),
65+
Sc_t(config->GetSchmidt_Number_Turbulent()) {
6266
}
6367

6468
template <class T>
6569
CNumerics::ResidualType<> CSourceAxisymmetric_Species<T>::ComputeResidual(const CConfig* config) {
66-
for (unsigned short iVar = 0; iVar < nVar; iVar++) residual[iVar] = 0.0;
70+
6771

68-
if (implicit) {
69-
for (unsigned short iVar = 0; iVar < nVar; iVar++) {
70-
for (unsigned short jVar = 0; jVar < nVar; jVar++) jacobian[iVar][jVar] = 0.0;
72+
/*--- Preaccumulation ---*/
73+
AD::StartPreacc();
74+
AD::SetPreaccIn(ScalarVar_i, nVar);
75+
AD::SetPreaccIn(Volume);
76+
77+
if (incompressible) {
78+
AD::SetPreaccIn(V_i, nDim+6);
79+
}
80+
else {
81+
AD::SetPreaccIn(V_i, nDim+7);
82+
}
83+
84+
/*--- Initialization. ---*/
85+
for (auto iVar = 0u; iVar < nVar; iVar++) {
86+
residual[iVar] = 0.0;
87+
for (auto jVar = 0; jVar < nVar; jVar++) {
88+
jacobian[iVar][jVar] = 0.0;
89+
}
90+
}
91+
92+
/*--- Contribution due to 2D axisymmetric formulation ---*/
93+
if (Coord_i[1] > EPS) {
94+
95+
AD::SetPreaccIn(Coord_i[1]);
96+
AD::SetPreaccIn(Diffusion_Coeff_i, nVar);
97+
AD::SetPreaccIn(ScalarVar_Grad_i, nVar, nDim);
98+
99+
const su2double yinv = 1.0 / Coord_i[1];
100+
101+
const su2double Density_i = V_i[idx.Density()];
102+
103+
su2double Velocity_i[3];
104+
for (auto iDim = 0u; iDim < nDim; iDim++)
105+
Velocity_i[iDim] = V_i[idx.Velocity() + iDim];
106+
107+
/*--- Inviscid component of the source term. ---*/
108+
109+
for (auto iVar = 0u; iVar < nVar; iVar++)
110+
residual[iVar] -= yinv * Volume * Density_i * ScalarVar_i[iVar] * Velocity_i[1];
111+
112+
if (implicit) {
113+
for (auto iVar = 0u; iVar < nVar; iVar++) {
114+
jacobian[iVar][iVar] -= yinv * Volume * Velocity_i[1];
115+
}
116+
}
117+
118+
/*--- Add the viscous terms if necessary. ---*/
119+
120+
if (config->GetViscous()) {
121+
su2double Mass_Diffusivity_Tur = 0.0;
122+
if (turbulence)
123+
Mass_Diffusivity_Tur = V_i[idx.EddyViscosity()] / Sc_t;
124+
125+
for (auto iVar=0u; iVar < nVar; iVar++){
126+
residual[iVar] += yinv * Volume * (Density_i * Diffusion_Coeff_i[iVar] + Mass_Diffusivity_Tur) * ScalarVar_Grad_i[iVar][1];
127+
}
71128
}
72129
}
130+
131+
AD::SetPreaccOut(residual, nVar);
132+
AD::EndPreacc();
73133

74134
return ResidualType<>(residual, jacobian, nullptr);
75135
}

SU2_CFD/src/solvers/CSpeciesSolver.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,54 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container,
542542
}
543543
END_SU2_OMP_FOR
544544
}
545+
546+
void CSpeciesSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container,
547+
CConfig *config, unsigned short iMesh) {
548+
549+
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
550+
const bool axisymmetric = config->GetAxisymmetric();
551+
552+
if (axisymmetric) {
553+
CNumerics *numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS];
554+
555+
SU2_OMP_FOR_DYN(omp_chunk_size)
556+
for (auto iPoint = 0u; iPoint < nPointDomain; iPoint++) {
557+
/*--- Set primitive variables w/o reconstruction ---*/
558+
559+
numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), nullptr);
560+
561+
/*--- Set scalar variables w/o reconstruction ---*/
562+
563+
numerics->SetScalarVar(nodes->GetSolution(iPoint), nullptr);
564+
565+
numerics->SetDiffusionCoeff(nodes->GetDiffusivity(iPoint), 0);
566+
567+
/*--- Set volume of the dual cell. ---*/
568+
569+
numerics->SetVolume(geometry->nodes->GetVolume(iPoint));
570+
571+
/*--- Update scalar sources in the fluidmodel ---*/
572+
573+
/*--- Axisymmetry source term for the scalar equation. ---*/
574+
/*--- Set y coordinate ---*/
575+
576+
numerics->SetCoord(geometry->nodes->GetCoord(iPoint), nullptr);
577+
578+
/*--- Set gradients ---*/
579+
580+
numerics->SetScalarVarGradient(nodes->GetGradient(iPoint), nullptr);
581+
582+
auto residual = numerics->ComputeResidual(config);
583+
584+
/*--- Add Residual ---*/
585+
586+
LinSysRes.SubtractBlock(iPoint, residual);
587+
588+
/*--- Implicit part ---*/
589+
590+
if (implicit) Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i);
591+
592+
}
593+
END_SU2_OMP_FOR
594+
}
595+
}

0 commit comments

Comments
 (0)