Skip to content

Commit 6df5603

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into feature_Sobolev_smoothing_solver
2 parents 02de958 + 4f85841 commit 6df5603

38 files changed

Lines changed: 865 additions & 513 deletions

Common/include/CConfig.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ class CConfig {
378378
su2double *Surface_TotalTemperature; /*!< \brief Total temperature at the boundaries. */
379379
su2double *Surface_TotalPressure; /*!< \brief Total pressure at the boundaries. */
380380
su2double *Surface_PressureDrop; /*!< \brief Pressure drop between boundaries. */
381+
su2double* Surface_Species_0; /*!< \brief Average Species_0 at the boundaries. */
382+
su2double* Surface_Species_Variance; /*!< \brief Species Variance at the boundaries. */
381383
su2double *Surface_DC60; /*!< \brief Specified surface DC60 for nacelle boundaries. */
382384
su2double *Surface_IDC; /*!< \brief Specified IDC for nacelle boundaries. */
383385
su2double *Surface_IDC_Mach; /*!< \brief Specified IDC mach for nacelle boundaries. */
@@ -7631,6 +7633,20 @@ class CConfig {
76317633
*/
76327634
void SetSurface_PressureDrop(unsigned short val_marker, su2double val_surface_pressuredrop) { Surface_PressureDrop[val_marker] = val_surface_pressuredrop; }
76337635

7636+
/*!
7637+
* \brief Set the average of species_0 at the surface.
7638+
* \param[in] val_marker - Index corresponding to boundary.
7639+
* \param[in] val_surface_species_0 - Value of avg species_0.
7640+
*/
7641+
void SetSurface_Species_0(unsigned short val_marker, su2double val_surface_species_0) { Surface_Species_0[val_marker] = val_surface_species_0; }
7642+
7643+
/*!
7644+
* \brief Set the species variance at the surface.
7645+
* \param[in] val_marker - Index corresponding to boundary.
7646+
* \param[in] val_surface_species_variance - Value of the species variance.
7647+
*/
7648+
void SetSurface_Species_Variance(unsigned short val_marker, su2double val_surface_species_variance) { Surface_Species_Variance[val_marker] = val_surface_species_variance; }
7649+
76347650
/*!
76357651
* \brief Get the back pressure (static) at an outlet boundary.
76367652
* \param[in] val_index - Index corresponding to the outlet boundary.
@@ -7897,6 +7913,20 @@ class CConfig {
78977913
*/
78987914
su2double GetSurface_PressureDrop(unsigned short val_marker) const { return Surface_PressureDrop[val_marker]; }
78997915

7916+
/*!
7917+
* \brief Get avg species_0 at a boundary.
7918+
* \param[in] val_index - Index corresponding to the boundary.
7919+
* \return The avg species_0.
7920+
*/
7921+
su2double GetSurface_Species_0(unsigned short val_marker) const { return Surface_Species_0[val_marker]; }
7922+
7923+
/*!
7924+
* \brief Get the species variance at a boundary.
7925+
* \param[in] val_index - Index corresponding to the boundary.
7926+
* \return The species variance.
7927+
*/
7928+
su2double GetSurface_Species_Variance(unsigned short val_marker) const { return Surface_Species_Variance[val_marker]; }
7929+
79007930
/*!
79017931
* \brief Get the back pressure (static) at an outlet boundary.
79027932
* \param[in] val_index - Index corresponding to the outlet boundary.

Common/include/option_structure.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,34 @@ static const MapType<std::string, TURB_MODEL> Turb_Model_Map = {
934934
MakePair("SST_SUST", TURB_MODEL::SST_SUST)
935935
};
936936

937+
/*!
938+
* \brief Families of turbulence models
939+
*/
940+
enum class TURB_FAMILY {
941+
NONE, /*!< \brief No turbulence model. */
942+
SA, /*!< \brief Spalart-Allmaras variants. */
943+
KW, /*!< \brief k-w models. */
944+
};
945+
/*!
946+
* \brief Associate turb models with their family
947+
*/
948+
inline TURB_FAMILY TurbModelFamily(TURB_MODEL model) {
949+
switch (model) {
950+
case TURB_MODEL::NONE:
951+
return TURB_FAMILY::NONE;
952+
case TURB_MODEL::SA:
953+
case TURB_MODEL::SA_NEG:
954+
case TURB_MODEL::SA_E:
955+
case TURB_MODEL::SA_COMP:
956+
case TURB_MODEL::SA_E_COMP:
957+
return TURB_FAMILY::SA;
958+
case TURB_MODEL::SST:
959+
case TURB_MODEL::SST_SUST:
960+
return TURB_FAMILY::KW;
961+
}
962+
return TURB_FAMILY::NONE;
963+
}
964+
937965
/*!
938966
* \brief Types of transition models
939967
*/
@@ -1542,6 +1570,8 @@ enum ENUM_OBJECTIVE {
15421570
SURFACE_MOM_DISTORTION = 54, /*!< \brief Momentum distortion objective function definition. */
15431571
SURFACE_SECOND_OVER_UNIFORM = 55, /*!< \brief Secondary over uniformity (relative secondary strength) objective function definition. */
15441572
SURFACE_PRESSURE_DROP = 56, /*!< \brief Pressure drop objective function definition. */
1573+
SURFACE_SPECIES_0 = 58, /*!< \brief Surface Avg. Species_0 objective function definition. */
1574+
SURFACE_SPECIES_VARIANCE = 59,/*!< \brief Species Variance objective function definition. */
15451575
CUSTOM_OBJFUNC = 31, /*!< \brief Custom objective function definition. */
15461576
TOTAL_PRESSURE_LOSS = 39,
15471577
KINETIC_ENERGY_LOSS = 40,
@@ -1594,6 +1624,8 @@ static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
15941624
MakePair("SURFACE_MOM_DISTORTION", SURFACE_MOM_DISTORTION)
15951625
MakePair("SURFACE_SECOND_OVER_UNIFORM", SURFACE_SECOND_OVER_UNIFORM)
15961626
MakePair("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP)
1627+
MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0)
1628+
MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE)
15971629
MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC)
15981630
MakePair("TOTAL_EFFICIENCY", TOTAL_EFFICIENCY)
15991631
MakePair("TOTAL_STATIC_EFFICIENCY", TOTAL_STATIC_EFFICIENCY)

Common/src/CConfig.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,8 @@ void CConfig::SetPointersNull(void) {
911911
ActDisk_ReverseMassFlow = nullptr; Surface_MassFlow = nullptr; Surface_Mach = nullptr;
912912
Surface_Temperature = nullptr; Surface_Pressure = nullptr; Surface_Density = nullptr; Surface_Enthalpy = nullptr;
913913
Surface_NormalVelocity = nullptr; Surface_TotalTemperature = nullptr; Surface_TotalPressure = nullptr; Surface_PressureDrop = nullptr;
914-
Surface_DC60 = nullptr; Surface_IDC = nullptr;
914+
Surface_DC60 = nullptr; Surface_IDC = nullptr;
915+
Surface_Species_Variance = nullptr; Surface_Species_0 = nullptr;
915916

916917
Outlet_MassFlow = nullptr; Outlet_Density = nullptr; Outlet_Area = nullptr;
917918

@@ -3563,14 +3564,17 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
35633564
case SURFACE_MOM_DISTORTION:
35643565
case SURFACE_SECOND_OVER_UNIFORM:
35653566
case SURFACE_PRESSURE_DROP:
3567+
case SURFACE_SPECIES_0:
3568+
case SURFACE_SPECIES_VARIANCE:
35663569
case CUSTOM_OBJFUNC:
35673570
if (Kind_ObjFunc[iObj] != Obj_0) {
35683571
SU2_MPI::Error(string("The following objectives can only be used for the first surface in a multi-objective \n")+
35693572
string("problem or as a single objective applied to multiple monitoring markers:\n")+
35703573
string("INVERSE_DESIGN_PRESSURE, INVERSE_DESIGN_HEATFLUX, THRUST_COEFFICIENT, TORQUE_COEFFICIENT\n")+
35713574
string("FIGURE_OF_MERIT, SURFACE_TOTAL_PRESSURE, SURFACE_STATIC_PRESSURE, SURFACE_MASSFLOW\n")+
35723575
string("SURFACE_UNIFORMITY, SURFACE_SECONDARY, SURFACE_MOM_DISTORTION, SURFACE_SECOND_OVER_UNIFORM\n")+
3573-
string("SURFACE_PRESSURE_DROP, SURFACE_STATIC_TEMPERATURE, CUSTOM_OBJFUNC.\n"), CURRENT_FUNCTION);
3576+
string("SURFACE_PRESSURE_DROP, SURFACE_STATIC_TEMPERATURE, SURFACE_SPECIES_0\n")+
3577+
string("SURFACE_SPECIES_VARIANCE, CUSTOM_OBJFUNC.\n"), CURRENT_FUNCTION);
35743578
}
35753579
break;
35763580
default:
@@ -5171,13 +5175,12 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
51715175
else {monoatomic = false;}
51725176

51735177
/*--- Set number of Turbulence Variables. ---*/
5174-
switch(Kind_Turb_Model) {
5175-
case TURB_MODEL::NONE:
5178+
switch (TurbModelFamily(Kind_Turb_Model)) {
5179+
case TURB_FAMILY::NONE:
51765180
nTurbVar = 0; break;
5177-
case TURB_MODEL::SA: case TURB_MODEL::SA_COMP: case TURB_MODEL::SA_E_COMP: case TURB_MODEL::SA_E:
5178-
case TURB_MODEL::SA_NEG:
5181+
case TURB_FAMILY::SA:
51795182
nTurbVar = 1; break;
5180-
case TURB_MODEL::SST: case TURB_MODEL::SST_SUST:
5183+
case TURB_FAMILY::KW:
51815184
nTurbVar = 2; break;
51825185
}
51835186

@@ -5193,6 +5196,15 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
51935196
Kind_Solver != MAIN_SOLVER::DISC_ADJ_RANS)
51945197
SU2_MPI::Error("Species transport currently only avaialble for compressible and incompressible flow.", CURRENT_FUNCTION);
51955198

5199+
/*--- Species specific OF currently can only handle one entry in Marker_Analyze. ---*/
5200+
for (unsigned short iObj = 0; iObj < nObj; iObj++) {
5201+
if ((Kind_ObjFunc[iObj] == SURFACE_SPECIES_0 ||
5202+
Kind_ObjFunc[iObj] == SURFACE_SPECIES_VARIANCE) &&
5203+
nMarker_Analyze > 1) {
5204+
SU2_MPI::Error("SURFACE_SPECIES_0 and SURFACE_SPECIES_VARIANCE currently can only handle one entry to MARKER_ANALYZE.", CURRENT_FUNCTION);
5205+
}
5206+
}
5207+
51965208
// For now, do not allow axisymmetric simulations
51975209
if (Axisymmetric) SU2_MPI::Error("Species transport currently not possible with axissymmetric flow.", CURRENT_FUNCTION);
51985210

@@ -5370,6 +5382,8 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) {
53705382
Surface_TotalTemperature = new su2double[nMarker_Analyze] ();
53715383
Surface_TotalPressure = new su2double[nMarker_Analyze] ();
53725384
Surface_PressureDrop = new su2double[nMarker_Analyze] ();
5385+
Surface_Species_0 = new su2double[nMarker_Analyze] ();
5386+
Surface_Species_Variance = new su2double[nMarker_Analyze] ();
53735387
Surface_DC60 = new su2double[nMarker_Analyze] ();
53745388
Surface_IDC = new su2double[nMarker_Analyze] ();
53755389
Surface_IDC_Mach = new su2double[nMarker_Analyze] ();
@@ -5905,7 +5919,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
59055919
break;
59065920
case MAIN_SOLVER::MULTIPHYSICS:
59075921
cout << "Multiphysics solver" << endl;
5908-
break;
5922+
break;
59095923
default:
59105924
SU2_MPI::Error("No valid solver was chosen", CURRENT_FUNCTION);
59115925

@@ -7940,6 +7954,8 @@ CConfig::~CConfig(void) {
79407954
delete[] Surface_TotalTemperature;
79417955
delete[] Surface_TotalPressure;
79427956
delete[] Surface_PressureDrop;
7957+
delete[] Surface_Species_0;
7958+
delete[] Surface_Species_Variance;
79437959
delete[] Surface_DC60;
79447960
delete[] Surface_IDC;
79457961
delete[] Surface_IDC_Mach;
@@ -8286,6 +8302,8 @@ string CConfig::GetObjFunc_Extension(string val_filename) const {
82868302
case SURFACE_MOM_DISTORTION: AdjExt = "_distort"; break;
82878303
case SURFACE_SECOND_OVER_UNIFORM: AdjExt = "_sou"; break;
82888304
case SURFACE_PRESSURE_DROP: AdjExt = "_dp"; break;
8305+
case SURFACE_SPECIES_0: AdjExt = "_avgspec0"; break;
8306+
case SURFACE_SPECIES_VARIANCE: AdjExt = "_specvar"; break;
82898307
case SURFACE_MACH: AdjExt = "_mach"; break;
82908308
case CUSTOM_OBJFUNC: AdjExt = "_custom"; break;
82918309
case KINETIC_ENERGY_LOSS: AdjExt = "_ke"; break;
@@ -8515,7 +8533,7 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver,
85158533
break;
85168534

85178535
default:
8518-
break;
8536+
break;
85198537
}
85208538
}
85218539

SU2_CFD/include/output/CAdjFlowCompOutput.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@
2727

2828
#pragma once
2929

30-
#include "COutput.hpp"
30+
#include "CAdjFlowOutput.hpp"
3131

3232
/*! \class CAdjFlowCompOutput
3333
* \brief Output class for compressible flow adjoint problems.
3434
* \author R. Sanchez, T. Albring.
3535
* \date June 5, 2018.
3636
*/
37-
class CAdjFlowCompOutput final: public COutput {
38-
private:
39-
40-
bool cont_adj; /*!< \brief Boolean indicating whether we run a cont. adjoint problem */
41-
bool frozen_visc; /*!< \brief Boolean indicating whether frozen viscosity/turbulence is used. */
42-
TURB_MODEL turb_model; /*!< \brief The kind of turbulence model*/
43-
37+
class CAdjFlowCompOutput final: public CAdjFlowOutput {
4438
public:
4539

4640
/*!

SU2_CFD/include/output/CAdjFlowIncOutput.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,19 @@
2727

2828
#pragma once
2929

30-
#include "COutput.hpp"
30+
#include "CAdjFlowOutput.hpp"
3131

3232
/*! \class CAdjFlowIncOutput
3333
* \brief Output class for incompressible flow discrete adjoint problems.
3434
* \author R. Sanchez, T. Albring.
3535
* \date June 5, 2018.
3636
*/
37-
class CAdjFlowIncOutput final: public COutput {
37+
class CAdjFlowIncOutput final: public CAdjFlowOutput {
3838
private:
3939

40-
TURB_MODEL turb_model; /*!< \brief The kind of turbulence model*/
4140
RADIATION_MODEL rad_model; /*!< \brief The kind of radiation model */
4241
bool heat; /*!< \brief Boolean indicating whether have a heat problem*/
4342
bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/
44-
bool cont_adj; /*!< \brief Boolean indicating whether we run a cont. adjoint problem */
45-
bool frozen_visc; /*!< \brief Boolean indicating whether frozen viscosity/turbulence is used. */
4643

4744
public:
4845

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*!
2+
* \file CAdjFlowOutput.hpp
3+
* \brief Headers of the adjoint flow output.
4+
* \author T. Kattmann
5+
* \version 7.2.1 "Blackbird"
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-2021, 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 "COutput.hpp"
31+
32+
/*! \class CAdjFlowOutput
33+
* \brief Output class for flow discrete adjoint problems.
34+
* \author T. Kattmann
35+
* \date December 3, 2021.
36+
*/
37+
class CAdjFlowOutput : public COutput {
38+
protected:
39+
const TURB_MODEL turb_model; /*!< \brief The kind of turbulence model*/
40+
const bool cont_adj; /*!< \brief Boolean indicating whether we run a cont. adjoint problem */
41+
const bool frozen_visc; /*!< \brief Boolean indicating whether frozen viscosity/turbulence is used. */
42+
43+
public:
44+
/*!
45+
* \brief Constructor of the class
46+
* \param[in] config - Definition of the particular problem.
47+
*/
48+
CAdjFlowOutput(CConfig* config, unsigned short nDim);
49+
50+
/*!
51+
* \brief Add scalar (turbulence/species) history fields for the Residual RMS (FVMComp, FVMInc, FVMNEMO).
52+
*/
53+
void AddHistoryOutputFields_AdjScalarRMS_RES(const CConfig* config);
54+
55+
/*!
56+
* \brief Add scalar (turbulence/species) history fields for the max Residual (FVMComp, FVMInc, FVMNEMO).
57+
*/
58+
void AddHistoryOutputFields_AdjScalarMAX_RES(const CConfig* config);
59+
60+
/*!
61+
* \brief Add scalar (turbulence/species) history fields for the BGS Residual (FVMComp, FVMInc, FVMNEMO).
62+
*/
63+
void AddHistoryOutputFields_AdjScalarBGS_RES(const CConfig* config);
64+
65+
/*!
66+
* \brief Add scalar (turbulence/species) history fields for the linear solver (FVMComp, FVMInc, FVMNEMO).
67+
*/
68+
void AddHistoryOutputFields_AdjScalarLinsol(const CConfig* config);
69+
70+
/*!
71+
* \brief Set all scalar (turbulence/species) history field values.
72+
*/
73+
void LoadHistoryData_AdjScalar(const CConfig* config, const CSolver* const* solver);
74+
75+
/*!
76+
* \brief Add scalar (turbulence/species) volume solution fields for a point (FVMComp, FVMInc, FVMNEMO).
77+
* \note The order of fields in restart files is fixed. Therefore the split-up.
78+
* \param[in] config - Definition of the particular problem.
79+
*/
80+
void SetVolumeOutputFields_AdjScalarSolution(const CConfig* config);
81+
82+
/*!
83+
* \brief Add scalar (turbulence/species) volume solution fields for a point (FVMComp, FVMInc, FVMNEMO).
84+
* \note The order of fields in restart files is fixed. Therefore the split-up.
85+
* \param[in] config - Definition of the particular problem.
86+
*/
87+
void SetVolumeOutputFields_AdjScalarResidual(const CConfig* config);
88+
89+
/*!
90+
* \brief Set all scalar (turbulence/species) volume field values for a point.
91+
* \param[in] config - Definition of the particular problem.
92+
* \param[in] solver - The container holding all solution data.
93+
* \param[in] iPoint - Index of the point.
94+
*/
95+
void LoadVolumeData_AdjScalar(const CConfig* config, const CSolver* const* solver, const unsigned long iPoint);
96+
};

SU2_CFD/include/output/CFlowOutput.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ class CFlowOutput : public CFVMOutput{
8282
const vector<su2double>& Surface_Area_Total);
8383

8484
/*!
85-
* \brief Add scalar (turbulence/species) history fields for the linear solver (FVMComp, FVMInc, FVMNEMO).
85+
* \brief Add scalar (turbulence/species) history fields for the Residual RMS (FVMComp, FVMInc, FVMNEMO).
8686
*/
8787
void AddHistoryOutputFields_ScalarRMS_RES(const CConfig* config);
8888

8989
/*!
90-
* \brief Add scalar (turbulence/species) history fields for the linear solver (FVMComp, FVMInc, FVMNEMO).
90+
* \brief Add scalar (turbulence/species) history fields for the max Residual (FVMComp, FVMInc, FVMNEMO).
9191
*/
9292
void AddHistoryOutputFields_ScalarMAX_RES(const CConfig* config);
9393

9494
/*!
95-
* \brief Add scalar (turbulence/species) history fields for the linear solver (FVMComp, FVMInc, FVMNEMO).
95+
* \brief Add scalar (turbulence/species) history fields for the BGS Residual (FVMComp, FVMInc, FVMNEMO).
9696
*/
9797
void AddHistoryOutputFields_ScalarBGS_RES(const CConfig* config);
9898

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,6 +3015,12 @@ su2double CFVMFlowSolverBase<V,R>::EvaluateCommonObjFunc(const CConfig& config)
30153015
case SURFACE_PRESSURE_DROP:
30163016
objFun += weight * config.GetSurface_PressureDrop(0);
30173017
break;
3018+
case SURFACE_SPECIES_0:
3019+
objFun += weight * config.GetSurface_Species_0(0);
3020+
break;
3021+
case SURFACE_SPECIES_VARIANCE:
3022+
objFun += weight * config.GetSurface_Species_Variance(0);
3023+
break;
30183024
case CUSTOM_OBJFUNC:
30193025
objFun += weight * Total_Custom_ObjFunc;
30203026
break;

0 commit comments

Comments
 (0)