Skip to content

Commit 31d7a95

Browse files
committed
Add Avg surf Species_0 OF.
Only Species_0 because one can of course always shift the species functions around. In case more than one avg surf Spec is needed at once, the one has to add it manually
1 parent f7b8e44 commit 31d7a95

5 files changed

Lines changed: 40 additions & 5 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ 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. */
381382
su2double* Surface_Species_Variance; /*!< \brief Species Variance at the boundaries. */
382383
su2double *Surface_DC60; /*!< \brief Specified surface DC60 for nacelle boundaries. */
383384
su2double *Surface_IDC; /*!< \brief Specified IDC for nacelle boundaries. */
@@ -7581,7 +7582,14 @@ class CConfig {
75817582
*/
75827583
void SetSurface_PressureDrop(unsigned short val_marker, su2double val_surface_pressuredrop) { Surface_PressureDrop[val_marker] = val_surface_pressuredrop; }
75837584

7584-
/*!
7585+
/*!
7586+
* \brief Set the average of species_0 at the surface.
7587+
* \param[in] val_marker - Index corresponding to boundary.
7588+
* \param[in] val_surface_species_0 - Value of avg species_0.
7589+
*/
7590+
void SetSurface_Species_0(unsigned short val_marker, su2double val_surface_species_0) { Surface_Species_0[val_marker] = val_surface_species_0; }
7591+
7592+
/*!
75857593
* \brief Set the species variance at the surface.
75867594
* \param[in] val_marker - Index corresponding to boundary.
75877595
* \param[in] val_surface_species_variance - Value of the species variance.
@@ -7854,6 +7862,13 @@ class CConfig {
78547862
*/
78557863
su2double GetSurface_PressureDrop(unsigned short val_marker) const { return Surface_PressureDrop[val_marker]; }
78567864

7865+
/*!
7866+
* \brief Get avg species_0 at a boundary.
7867+
* \param[in] val_index - Index corresponding to the boundary.
7868+
* \return The avg species_0.
7869+
*/
7870+
su2double GetSurface_Species_0(unsigned short val_marker) const { return Surface_Species_0[val_marker]; }
7871+
78577872
/*!
78587873
* \brief Get the species variance at a boundary.
78597874
* \param[in] val_index - Index corresponding to the boundary.

Common/include/option_structure.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,8 @@ enum ENUM_OBJECTIVE {
15641564
SURFACE_MOM_DISTORTION = 54, /*!< \brief Momentum distortion objective function definition. */
15651565
SURFACE_SECOND_OVER_UNIFORM = 55, /*!< \brief Secondary over uniformity (relative secondary strength) objective function definition. */
15661566
SURFACE_PRESSURE_DROP = 56, /*!< \brief Pressure drop objective function definition. */
1567-
SURFACE_SPECIES_VARIANCE = 58,/*!< \brief Species Variance objective function definition. */
1567+
SURFACE_SPECIES_0 = 58, /*!< \brief Surface Avg. Species_0 objective function definition. */
1568+
SURFACE_SPECIES_VARIANCE = 59,/*!< \brief Species Variance objective function definition. */
15681569
CUSTOM_OBJFUNC = 31, /*!< \brief Custom objective function definition. */
15691570
TOTAL_PRESSURE_LOSS = 39,
15701571
KINETIC_ENERGY_LOSS = 40,
@@ -1617,6 +1618,7 @@ static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
16171618
MakePair("SURFACE_MOM_DISTORTION", SURFACE_MOM_DISTORTION)
16181619
MakePair("SURFACE_SECOND_OVER_UNIFORM", SURFACE_SECOND_OVER_UNIFORM)
16191620
MakePair("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP)
1621+
MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0)
16201622
MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE)
16211623
MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC)
16221624
MakePair("TOTAL_EFFICIENCY", TOTAL_EFFICIENCY)

Common/src/CConfig.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ void CConfig::SetPointersNull(void) {
910910
ActDisk_ReverseMassFlow = nullptr; Surface_MassFlow = nullptr; Surface_Mach = nullptr;
911911
Surface_Temperature = nullptr; Surface_Pressure = nullptr; Surface_Density = nullptr; Surface_Enthalpy = nullptr;
912912
Surface_NormalVelocity = nullptr; Surface_TotalTemperature = nullptr; Surface_TotalPressure = nullptr; Surface_PressureDrop = nullptr;
913-
Surface_DC60 = nullptr; Surface_IDC = nullptr; Surface_Species_Variance = nullptr;
913+
Surface_DC60 = nullptr; Surface_IDC = nullptr;
914+
Surface_Species_Variance = nullptr; Surface_Species_0 = nullptr;
914915

915916
Outlet_MassFlow = nullptr; Outlet_Density = nullptr; Outlet_Area = nullptr;
916917

@@ -3530,6 +3531,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
35303531
case SURFACE_MOM_DISTORTION:
35313532
case SURFACE_SECOND_OVER_UNIFORM:
35323533
case SURFACE_PRESSURE_DROP:
3534+
case SURFACE_SPECIES_0:
35333535
case SURFACE_SPECIES_VARIANCE:
35343536
case CUSTOM_OBJFUNC:
35353537
if (Kind_ObjFunc[iObj] != Obj_0) {
@@ -3538,7 +3540,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
35383540
string("INVERSE_DESIGN_PRESSURE, INVERSE_DESIGN_HEATFLUX, THRUST_COEFFICIENT, TORQUE_COEFFICIENT\n")+
35393541
string("FIGURE_OF_MERIT, SURFACE_TOTAL_PRESSURE, SURFACE_STATIC_PRESSURE, SURFACE_MASSFLOW\n")+
35403542
string("SURFACE_UNIFORMITY, SURFACE_SECONDARY, SURFACE_MOM_DISTORTION, SURFACE_SECOND_OVER_UNIFORM\n")+
3541-
string("SURFACE_PRESSURE_DROP, SURFACE_STATIC_TEMPERATURE, SURFACE_SPECIES_VARIANCE, CUSTOM_OBJFUNC.\n"), CURRENT_FUNCTION);
3543+
string("SURFACE_PRESSURE_DROP, SURFACE_STATIC_TEMPERATURE, SURFACE_SPECIES_0, SURFACE_SPECIES_VARIANCE, CUSTOM_OBJFUNC.\n"), CURRENT_FUNCTION);
35423544
}
35433545
break;
35443546
default:
@@ -5160,6 +5162,15 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
51605162
Kind_Solver != MAIN_SOLVER::DISC_ADJ_RANS)
51615163
SU2_MPI::Error("Species transport currently only avaialble for compressible and incompressible flow.", CURRENT_FUNCTION);
51625164

5165+
/*--- Species specific OF currently can only handle one entry in Marker_Analyze. ---*/
5166+
for (unsigned short iObj = 0; iObj < nObj; iObj++) {
5167+
if ((Kind_ObjFunc[iObj] == SURFACE_SPECIES_0 ||
5168+
Kind_ObjFunc[iObj] == SURFACE_SPECIES_VARIANCE) &&
5169+
nMarker_Analyze > 1) {
5170+
SU2_MPI::Error("SURFACE_SPECIES_0 and SURFACE_SPECIES_VARIANCE currently can only handle one entry to MARKER_ANALYZE.", CURRENT_FUNCTION);
5171+
}
5172+
}
5173+
51635174
// For now, do not allow axisymmetric simulations
51645175
if (Axisymmetric) SU2_MPI::Error("Species transport currently not possible with axissymmetric flow.", CURRENT_FUNCTION);
51655176

@@ -5335,6 +5346,7 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) {
53355346
Surface_TotalTemperature = new su2double[nMarker_Analyze] ();
53365347
Surface_TotalPressure = new su2double[nMarker_Analyze] ();
53375348
Surface_PressureDrop = new su2double[nMarker_Analyze] ();
5349+
Surface_Species_0 = new su2double[nMarker_Analyze] ();
53385350
Surface_Species_Variance = new su2double[nMarker_Analyze] ();
53395351
Surface_DC60 = new su2double[nMarker_Analyze] ();
53405352
Surface_IDC = new su2double[nMarker_Analyze] ();
@@ -7878,6 +7890,7 @@ CConfig::~CConfig(void) {
78787890
delete[] Surface_TotalTemperature;
78797891
delete[] Surface_TotalPressure;
78807892
delete[] Surface_PressureDrop;
7893+
delete[] Surface_Species_0;
78817894
delete[] Surface_Species_Variance;
78827895
delete[] Surface_DC60;
78837896
delete[] Surface_IDC;
@@ -8225,6 +8238,7 @@ string CConfig::GetObjFunc_Extension(string val_filename) const {
82258238
case SURFACE_MOM_DISTORTION: AdjExt = "_distort"; break;
82268239
case SURFACE_SECOND_OVER_UNIFORM: AdjExt = "_sou"; break;
82278240
case SURFACE_PRESSURE_DROP: AdjExt = "_dp"; break;
8241+
case SURFACE_SPECIES_0: AdjExt = "_avgspec0"; break;
82288242
case SURFACE_SPECIES_VARIANCE: AdjExt = "_specvar"; break;
82298243
case SURFACE_MACH: AdjExt = "_mach"; break;
82308244
case CUSTOM_OBJFUNC: AdjExt = "_custom"; break;

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,6 +3015,9 @@ 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;
30183021
case SURFACE_SPECIES_VARIANCE:
30193022
objFun += weight * config.GetSurface_Species_Variance(0);
30203023
break;

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry
509509
su2double Species = Surface_Species_Total(iMarker_Analyze, iVar);
510510
SetHistoryOutputPerSurfaceValue("SURFACE_SPECIES_" + std::to_string(iVar), Species, iMarker_Analyze);
511511
Tot_Surface_Species[iVar] += Species;
512-
// Set value into config. Necessary to access as an OF.
512+
if (iVar == 0)
513+
config->SetSurface_Species_0(iMarker_Analyze, Species);
513514
}
514515

515516
}

0 commit comments

Comments
 (0)