Skip to content

Commit e4b1579

Browse files
authored
Merge pull request #1167 from su2code/fix_objective_functions
Fix objective functions (for shape_optimization.py)
2 parents 916a99d + e4dc3aa commit e4b1579

48 files changed

Lines changed: 730 additions & 1079 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/include/CConfig.hpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ class CConfig {
141141
Sens_Remove_Sharp, /*!< \brief Flag for removing or not the sharp edges from the sensitivity computation. */
142142
Hold_GridFixed, /*!< \brief Flag hold fixed some part of the mesh during the deformation. */
143143
Axisymmetric, /*!< \brief Flag for axisymmetric calculations */
144-
Integrated_HeatFlux, /*!< \brief Flag for heat flux BC whether it deals with integrated values.*/
145-
Buffet_Monitoring; /*!< \brief Flag for computing the buffet sensor.*/
144+
Integrated_HeatFlux; /*!< \brief Flag for heat flux BC whether it deals with integrated values.*/
146145
su2double Buffet_k; /*!< \brief Sharpness coefficient for buffet sensor.*/
147146
su2double Buffet_lambda; /*!< \brief Offset parameter for buffet sensor.*/
148147
su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */
@@ -5034,11 +5033,6 @@ class CConfig {
50345033
*/
50355034
unsigned short GetKind_ObjFunc(unsigned short val_obj = 0) const { return Kind_ObjFunc[val_obj]; }
50365035

5037-
/*!
5038-
* \brief Similar to GetKind_ObjFunc but returns the corresponding string.
5039-
*/
5040-
string GetName_ObjFunc(unsigned short val_obj = 0) const;
5041-
50425036
/*!
50435037
* \author H. Kline
50445038
* \brief Get the weight of objective function. There are several options: Drag coefficient,
@@ -5867,12 +5861,6 @@ class CConfig {
58675861
*/
58685862
unsigned short GetDesign_Variable(unsigned short val_dv) const { return Design_Variable[val_dv]; }
58695863

5870-
/*!
5871-
* \brief Provides the buffet monitoring information.
5872-
* \return Buffet monitoring information, if <code>TRUE</code> then the code will compute the buffet sensor.
5873-
*/
5874-
bool GetBuffet_Monitoring(void) const { return Buffet_Monitoring; }
5875-
58765864
/*!
58775865
* \brief Get the buffet sensor sharpness coefficient.
58785866
* \return Sharpness coefficient for buffet sensor.

Common/include/option_structure.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ enum ENUM_OBJECTIVE {
14851485
INVERSE_DESIGN_HEATFLUX = 6, /*!< \brief Heat flux objective function definition (inverse design). */
14861486
TOTAL_HEATFLUX = 7, /*!< \brief Total heat flux. */
14871487
MAXIMUM_HEATFLUX = 8, /*!< \brief Maximum heat flux. */
1488-
TOTAL_AVG_TEMPERATURE = 70, /*!< \brief Total averaged temperature. */
1488+
AVG_TEMPERATURE = 70, /*!< \brief Total averaged temperature. */
14891489
MOMENT_X_COEFFICIENT = 9, /*!< \brief Pitching moment objective function definition. */
14901490
MOMENT_Y_COEFFICIENT = 10, /*!< \brief Rolling moment objective function definition. */
14911491
MOMENT_Z_COEFFICIENT = 11, /*!< \brief Yawing objective function definition. */
@@ -1545,7 +1545,7 @@ static const MapType<string, ENUM_OBJECTIVE> Objective_Map = {
15451545
MakePair("TORQUE", TORQUE_COEFFICIENT)
15461546
MakePair("TOTAL_HEATFLUX", TOTAL_HEATFLUX)
15471547
MakePair("MAXIMUM_HEATFLUX", MAXIMUM_HEATFLUX)
1548-
MakePair("TOTAL_AVG_TEMPERATURE", TOTAL_AVG_TEMPERATURE)
1548+
MakePair("AVG_TEMPERATURE", AVG_TEMPERATURE)
15491549
MakePair("FIGURE_OF_MERIT", FIGURE_OF_MERIT)
15501550
MakePair("BUFFET", BUFFET_SENSOR)
15511551
MakePair("SURFACE_TOTAL_PRESSURE", SURFACE_TOTAL_PRESSURE)

Common/src/CConfig.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,6 @@ void CConfig::SetConfig_Options() {
15941594
/* DESCRIPTION: Evaluate a problem with engines */
15951595
addBoolOption("ENGINE", Engine, false);
15961596

1597-
/* DESCRIPTION: Compute buffet sensor */
1598-
addBoolOption("BUFFET_MONITORING", Buffet_Monitoring, false);
15991597
/* DESCRIPTION: Sharpness coefficient for the buffet sensor */
16001598
addDoubleOption("BUFFET_K", Buffet_k, 10.0);
16011599
/* DESCRIPTION: Offset parameter for the buffet sensor */
@@ -3502,10 +3500,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
35023500
SU2_MPI::Error("Harmonic Balance not yet implemented for the incompressible solver.", CURRENT_FUNCTION);
35033501
}
35043502

3505-
if ((Kind_Solver != NAVIER_STOKES && Kind_Solver != RANS) && (Buffet_Monitoring == true)){
3506-
SU2_MPI::Error("Buffet monitoring incompatible with solvers other than NAVIER_STOKES and RANS", CURRENT_FUNCTION);
3507-
}
3508-
35093503
/*--- Check for Fluid model consistency ---*/
35103504

35113505
if (standard_air) {
@@ -7996,9 +7990,9 @@ string CConfig::GetObjFunc_Extension(string val_filename) const {
79967990
case TORQUE_COEFFICIENT: AdjExt = "_cq"; break;
79977991
case TOTAL_HEATFLUX: AdjExt = "_totheat"; break;
79987992
case MAXIMUM_HEATFLUX: AdjExt = "_maxheat"; break;
7999-
case TOTAL_AVG_TEMPERATURE: AdjExt = "_avtp"; break;
7993+
case AVG_TEMPERATURE: AdjExt = "_avtp"; break;
80007994
case FIGURE_OF_MERIT: AdjExt = "_merit"; break;
8001-
case BUFFET_SENSOR: AdjExt = "_buffet"; break;
7995+
case BUFFET_SENSOR: AdjExt = "_buffet"; break;
80027996
case SURFACE_TOTAL_PRESSURE: AdjExt = "_pt"; break;
80037997
case SURFACE_STATIC_PRESSURE: AdjExt = "_pe"; break;
80047998
case SURFACE_MASSFLOW: AdjExt = "_mfr"; break;
@@ -9305,13 +9299,6 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const {
93059299
return -1;
93069300
}
93079301

9308-
string CConfig::GetName_ObjFunc(unsigned short val_obj) const {
9309-
for (auto item : Objective_Map)
9310-
if (item.second == static_cast<ENUM_OBJECTIVE>(Kind_ObjFunc[val_obj]))
9311-
return item.first;
9312-
return string();
9313-
}
9314-
93159302
void CConfig::Tick(double *val_start_time) {
93169303

93179304
#ifdef PROFILE

Common/src/grid_movement/CVolumetricMovement.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void CVolumetricMovement::ComputenNonconvexElements(CGeometry *geometry, bool Sc
353353
nNonconvexElements++;
354354
}
355355
}
356-
} else {
356+
} else if (false) {
357357

358358
/*--- 3D elements ---*/
359359
unsigned short iNode, iFace, nFaceNodes;
@@ -371,6 +371,8 @@ void CVolumetricMovement::ComputenNonconvexElements(CGeometry *geometry, bool Sc
371371

372372
face_point_i = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, iNode));
373373

374+
/// TODO: Faces may have up to 4 nodes, not all posibilities are covered
375+
374376
if (iNode == 0) {
375377
face_point_j = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, nFaceNodes-1));
376378
face_point_k = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, iNode+1));
@@ -391,6 +393,9 @@ void CVolumetricMovement::ComputenNonconvexElements(CGeometry *geometry, bool Sc
391393
/*--- Calculate cross product of edge vectors and its length---*/
392394
su2double crossProduct[3];
393395
GeometryToolbox::CrossProduct(edgeVector_i, edgeVector_j, crossProduct);
396+
397+
/// TODO: This logic is incorrect, the norm will never be less than 0
398+
394399
crossProductLength = GeometryToolbox::Norm(nDim, crossProduct);
395400

396401
/*--- Check if length is minimum or maximum ---*/

SU2_CFD/include/numerics/NEMO/NEMO_diffusion.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
*/
3939
class CAvgGrad_NEMO : public CNEMONumerics {
4040
private:
41-
unsigned short iDim, iVar; /*!< \brief Iterators in dimension an variable. */
42-
su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */
41+
unsigned short iVar; /*!< \brief Iterators in dimension an variable. */
42+
su2double *Mean_PrimVar, /*!< \brief Mean primitive variables. */
4343
*Mean_U,
4444
**Mean_GU,
4545
*Mean_dTdU,
@@ -54,9 +54,8 @@ class CAvgGrad_NEMO : public CNEMONumerics {
5454
Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */
5555
Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */
5656
Mean_Thermal_Conductivity_ve, /*!< \brief Mean value of the vib-el. thermal conductivity. */
57-
*ProjFlux, /*!< \brief Projection of the viscous fluxes. */
5857
dist_ij; /*!< \brief Length of the edge and face. */
59-
58+
6059
public:
6160

6261
/*!
@@ -109,13 +108,11 @@ class CAvgGradCorrected_NEMO : public CNEMONumerics {
109108
Mean_Eddy_Viscosity, /*!< \brief Mean value of the eddy viscosity. */
110109
Mean_Thermal_Conductivity, /*!< \brief Mean value of the thermal conductivity. */
111110
Mean_Thermal_Conductivity_ve, /*!< \brief Mean value of the vib-el. thermal conductivity. */
112-
113-
*ProjFlux, /*!< \brief Projection of the viscous fluxes. */
114111
dist_ij; /*!< \brief Length of the edge and face. */
115112
bool implicit; /*!< \brief Implicit calculus. */
116113

117114
su2double* Flux = nullptr; /*!< \brief The flux / residual across the edge. */
118-
115+
119116
public:
120117

121118
/*!
@@ -142,5 +139,5 @@ class CAvgGradCorrected_NEMO : public CNEMONumerics {
142139
* \param[in] config - Definition of the particular problem.
143140
*/
144141
ResidualType<> ComputeResidual(const CConfig* config) final;
145-
142+
146143
};

SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class CDiscAdjFEASolver final : public CSolver {
4848
su2double *Solution_Vel = nullptr, /*!< \brief Velocity componenent of the solution. */
4949
*Solution_Accel = nullptr; /*!< \brief Acceleration componenent of the solution. */
5050

51-
su2double ObjFunc_Value = 0.0; /*!< \brief Value of the objective function. */
5251
su2double *normalLoads = nullptr; /*!< \brief Values of the normal loads for each marker iMarker_nL. */
5352

5453
unsigned short nMPROP = 0; /*!< \brief Number of material properties */
@@ -160,12 +159,6 @@ class CDiscAdjFEASolver final : public CSolver {
160159
*/
161160
void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config) override;
162161

163-
/*!
164-
* \brief Register the objective function as output.
165-
* \param[in] geometry - The geometrical definition of the problem.
166-
*/
167-
void RegisterObj_Func(CConfig *config) override;
168-
169162
/*!
170163
* \brief Set the surface sensitivity.
171164
* \param[in] geometry - Geometrical definition of the problem.
@@ -180,13 +173,6 @@ class CDiscAdjFEASolver final : public CSolver {
180173
*/
181174
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*) override;
182175

183-
/*!
184-
* \brief Set the objective function.
185-
* \param[in] geometry - Geometrical definition of the problem.
186-
* \param[in] config - Definition of the particular problem.
187-
*/
188-
void SetAdj_ObjFunc(CGeometry *geometry, CConfig* config) override;
189-
190176
/*!
191177
* \brief Provide the total Young's modulus sensitivity
192178
* \return Value of the total Young's modulus sensitivity

SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
*/
4040
class CDiscAdjMeshSolver final : public CSolver {
4141
private:
42-
unsigned short KindDirect_Solver = 0;
4342
CSolver *direct_solver = nullptr;
4443

4544
CDiscAdjMeshBoundVariable* nodes = nullptr; /*!< \brief Variables of the discrete adjoint mesh solver. */

SU2_CFD/include/solvers/CDiscAdjSolver.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class CDiscAdjSolver final : public CSolver {
4949
su2double Total_Sens_BPress; /*!< \brief Total sensitivity to outlet pressure. */
5050
su2double Total_Sens_Density; /*!< \brief Total sensitivity to initial density (incompressible). */
5151
su2double Total_Sens_ModVel; /*!< \brief Total sensitivity to inlet velocity (incompressible). */
52-
su2double ObjFunc_Value; /*!< \brief Value of the objective function. */
5352
su2double Mach, Alpha, Beta, Pressure, Temperature, BPressure, ModVel;
5453
su2double TemperatureRad, Total_Sens_Temp_Rad;
5554

@@ -140,12 +139,6 @@ class CDiscAdjSolver final : public CSolver {
140139
*/
141140
void ExtractAdjoint_Geometry(CGeometry *geometry, CConfig *config) override;
142141

143-
/*!
144-
* \brief Register the objective function as output.
145-
* \param[in] geometry - The geometrical definition of the problem.
146-
*/
147-
void RegisterObj_Func(CConfig *config) override;
148-
149142
/*!
150143
* \brief Set the surface sensitivity.
151144
* \param[in] geometry - Geometrical definition of the problem.
@@ -160,13 +153,6 @@ class CDiscAdjSolver final : public CSolver {
160153
*/
161154
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*) override;
162155

163-
/*!
164-
* \brief Set the objective function.
165-
* \param[in] geometry - Geometrical definition of the problem.
166-
* \param[in] config - Definition of the particular problem.
167-
*/
168-
void SetAdj_ObjFunc(CGeometry *geometry, CConfig* config) override;
169-
170156
/*!
171157
* \brief Provide the total shape sensitivity coefficient.
172158
* \return Value of the geometrical sensitivity coefficient

SU2_CFD/include/solvers/CEulerSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
474474
* \brief Compute weighted-sum "combo" objective output
475475
* \param[in] config - Definition of the particular problem.
476476
*/
477-
void Evaluate_ObjFunc(CConfig *config) override;
477+
void Evaluate_ObjFunc(const CConfig *config) override;
478478

479479
/*!
480480
* \brief Impose the far-field boundary condition using characteristics.

0 commit comments

Comments
 (0)