Skip to content

Commit 93822d4

Browse files
committed
push to 10k
1 parent e2697ee commit 93822d4

9 files changed

Lines changed: 152 additions & 363 deletions

File tree

SU2_CFD/include/solvers/CAdjEulerSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CAdjEulerSolver : public CSolver {
117117
* \param[in] geometry - Geometrical definition of the problem.
118118
* \param[in] config - Definition of the particular problem.
119119
*/
120-
void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) final;
120+
void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config);
121121

122122
/*!
123123
* \brief Parallelization of Undivided Laplacian.

SU2_CFD/include/solvers/CEulerSolver.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
273273
virtual unsigned long SetPrimitive_Variables(CSolver **solver_container,
274274
CConfig *config, bool Output);
275275

276+
/*!
277+
* \brief Set gradients of coefficients for fixed CL mode
278+
* \param[in] config - Definition of the particular problem.
279+
*/
280+
void SetCoefficient_Gradients(CConfig *config) const;
281+
276282
public:
277283
/*!
278284
* \brief Constructor of the class.
@@ -453,7 +459,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
453459
* \param[in] geometry - Geometrical definition of the problem.
454460
* \param[in] config - Definition of the particular problem.
455461
*/
456-
void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) final;
462+
void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config);
457463

458464
/*!
459465
* \author H. Kline
@@ -799,12 +805,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, COMPRESSIBLE> {
799805
*/
800806
inline su2double GetAoA_inc(void) const final { return AoA_inc; }
801807

802-
/*!
803-
* \brief Set gradients of coefficients for fixed CL mode
804-
* \param[in] config - Definition of the particular problem.
805-
*/
806-
void SetCoefficient_Gradients(CConfig *config) const;
807-
808808
/*!
809809
* \brief Update the solution using the explicit Euler scheme.
810810
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ class CFVMFlowSolverBase : public CSolver {
227227
void PushSolutionBackInTime(unsigned long TimeIter, bool restart, bool rans, CSolver*** solver_container,
228228
CGeometry** geometry, CConfig* config);
229229

230+
/*!
231+
* \brief Evaluate common part of objective function to all solvers.
232+
*/
233+
su2double EvaluateCommonObjFunc(const CConfig& config) const;
234+
230235
/*!
231236
* \brief Destructor.
232237
*/

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,3 +2441,110 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
24412441
SurfaceCoeff.CMz[iMarker_Monitoring] += SurfaceViscCoeff.CMz[iMarker_Monitoring];
24422442
}
24432443
}
2444+
2445+
template<class V, ENUM_REGIME R>
2446+
su2double CFVMFlowSolverBase<V,R>::EvaluateCommonObjFunc(const CConfig& config) const {
2447+
2448+
su2double objFun = 0.0;
2449+
2450+
/*--- Loop over all monitored markers, add to the 'combo' objective ---*/
2451+
2452+
for (auto iMarker = 0u; iMarker < config.GetnMarker_Monitoring(); iMarker++) {
2453+
2454+
const auto weight = config.GetWeight_ObjFunc(iMarker);
2455+
2456+
switch (config.GetKind_ObjFunc(iMarker)) {
2457+
case DRAG_COEFFICIENT:
2458+
objFun += weight * SurfaceCoeff.CD[iMarker];
2459+
break;
2460+
case LIFT_COEFFICIENT:
2461+
objFun += weight * SurfaceCoeff.CL[iMarker];
2462+
break;
2463+
case SIDEFORCE_COEFFICIENT:
2464+
objFun += weight * SurfaceCoeff.CSF[iMarker];
2465+
break;
2466+
case EFFICIENCY:
2467+
objFun += weight * SurfaceCoeff.CEff[iMarker];
2468+
break;
2469+
case MOMENT_X_COEFFICIENT:
2470+
objFun += weight * SurfaceCoeff.CMx[iMarker];
2471+
break;
2472+
case MOMENT_Y_COEFFICIENT:
2473+
objFun += weight * SurfaceCoeff.CMy[iMarker];
2474+
break;
2475+
case MOMENT_Z_COEFFICIENT:
2476+
objFun += weight * SurfaceCoeff.CMz[iMarker];
2477+
break;
2478+
case FORCE_X_COEFFICIENT:
2479+
objFun += weight * SurfaceCoeff.CFx[iMarker];
2480+
break;
2481+
case FORCE_Y_COEFFICIENT:
2482+
objFun += weight * SurfaceCoeff.CFy[iMarker];
2483+
break;
2484+
case FORCE_Z_COEFFICIENT:
2485+
objFun += weight * SurfaceCoeff.CFz[iMarker];
2486+
break;
2487+
case TOTAL_HEATFLUX:
2488+
objFun += weight * Surface_HF_Visc[iMarker];
2489+
break;
2490+
case MAXIMUM_HEATFLUX:
2491+
objFun += weight * Surface_MaxHF_Visc[iMarker];
2492+
break;
2493+
default:
2494+
break;
2495+
}
2496+
}
2497+
2498+
/*--- The following are not per-surface, and so to avoid that they are
2499+
double-counted when multiple surfaces are specified, they have been
2500+
placed outside of the loop above. In addition, multi-objective mode is
2501+
also disabled for these objective functions (error thrown at start). ---*/
2502+
2503+
const auto weight = config.GetWeight_ObjFunc(0);
2504+
2505+
switch (config.GetKind_ObjFunc(0)) {
2506+
case INVERSE_DESIGN_PRESSURE:
2507+
objFun += weight * Total_CpDiff;
2508+
break;
2509+
case INVERSE_DESIGN_HEATFLUX:
2510+
objFun += weight * Total_HeatFluxDiff;
2511+
break;
2512+
case THRUST_COEFFICIENT:
2513+
objFun += weight * TotalCoeff.CT;
2514+
break;
2515+
case TORQUE_COEFFICIENT:
2516+
objFun += weight * TotalCoeff.CQ;
2517+
break;
2518+
case FIGURE_OF_MERIT:
2519+
objFun += weight * TotalCoeff.CMerit;
2520+
break;
2521+
case SURFACE_TOTAL_PRESSURE:
2522+
objFun += weight * config.GetSurface_TotalPressure(0);
2523+
break;
2524+
case SURFACE_STATIC_PRESSURE:
2525+
objFun += weight * config.GetSurface_Pressure(0);
2526+
break;
2527+
case SURFACE_MASSFLOW:
2528+
objFun += weight * config.GetSurface_MassFlow(0);
2529+
break;
2530+
case SURFACE_UNIFORMITY:
2531+
objFun += weight * config.GetSurface_Uniformity(0);
2532+
break;
2533+
case SURFACE_SECONDARY:
2534+
objFun += weight * config.GetSurface_SecondaryStrength(0);
2535+
break;
2536+
case SURFACE_MOM_DISTORTION:
2537+
objFun += weight * config.GetSurface_MomentumDistortion(0);
2538+
break;
2539+
case SURFACE_SECOND_OVER_UNIFORM:
2540+
objFun += weight * config.GetSurface_SecondOverUniform(0);
2541+
break;
2542+
case CUSTOM_OBJFUNC:
2543+
objFun += weight * Total_Custom_ObjFunc;
2544+
break;
2545+
default:
2546+
break;
2547+
}
2548+
2549+
return objFun;
2550+
}

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, INCOMPRESSI
5656
* \overload
5757
* \param[in] geometry - Geometrical definition of the problem.
5858
* \param[in] config - Definition of the particular problem.
59+
* \param[in] iMesh - Grid level.
60+
* \param[in] navier_stokes - True when the constructor is called by the derived class CIncNSSolver.
5961
*/
60-
CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh);
62+
CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes = false);
6163

6264
/*!
6365
* \brief Destructor of the class.

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -838,13 +838,6 @@ class CSolver {
838838
unsigned short RunTime_EqSystem,
839839
bool Output) { }
840840

841-
/*!
842-
* \brief A virtual member.
843-
* \param[in] geometry - Geometrical definition of the problem.
844-
* \param[in] config - Definition of the particular problem.
845-
*/
846-
inline virtual void Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { }
847-
848841
/*!
849842
* \brief A virtual member.
850843
* \param[in] geometry - Geometrical definition of the problem.

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5573,7 +5573,7 @@ void CEulerSolver::Evaluate_ObjFunc(CConfig *config) {
55735573
unsigned short iMarker_Monitoring, Kind_ObjFunc;
55745574
su2double Weight_ObjFunc;
55755575

5576-
Total_ComboObj = 0.0;
5576+
Total_ComboObj = EvaluateCommonObjFunc(*config);
55775577

55785578
/*--- Loop over all monitored markers, add to the 'combo' objective ---*/
55795579

@@ -5584,46 +5584,18 @@ void CEulerSolver::Evaluate_ObjFunc(CConfig *config) {
55845584

55855585
switch(Kind_ObjFunc) {
55865586
case DRAG_COEFFICIENT:
5587-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CD[iMarker_Monitoring]);
55885587
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]);
55895588
if (config->GetFixed_CM_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCMy()*(SurfaceCoeff.CMy[iMarker_Monitoring]);
55905589
break;
5591-
case LIFT_COEFFICIENT:
5592-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CL[iMarker_Monitoring]);
5593-
break;
5594-
case SIDEFORCE_COEFFICIENT:
5595-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CSF[iMarker_Monitoring]);
5596-
break;
5597-
case EFFICIENCY:
5598-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CEff[iMarker_Monitoring]);
5599-
break;
56005590
case MOMENT_X_COEFFICIENT:
5601-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMx[iMarker_Monitoring]);
56025591
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMx_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]);
56035592
break;
56045593
case MOMENT_Y_COEFFICIENT:
5605-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMy[iMarker_Monitoring]);
56065594
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMy_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]);
56075595
break;
56085596
case MOMENT_Z_COEFFICIENT:
5609-
Total_ComboObj+=Weight_ObjFunc*(SurfaceCoeff.CMz[iMarker_Monitoring]);
56105597
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMz_dCL()*(SurfaceCoeff.CL[iMarker_Monitoring]);
56115598
break;
5612-
case FORCE_X_COEFFICIENT:
5613-
Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFx[iMarker_Monitoring];
5614-
break;
5615-
case FORCE_Y_COEFFICIENT:
5616-
Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFy[iMarker_Monitoring];
5617-
break;
5618-
case FORCE_Z_COEFFICIENT:
5619-
Total_ComboObj+=Weight_ObjFunc*SurfaceCoeff.CFz[iMarker_Monitoring];
5620-
break;
5621-
case TOTAL_HEATFLUX:
5622-
Total_ComboObj+=Weight_ObjFunc*Surface_HF_Visc[iMarker_Monitoring];
5623-
break;
5624-
case MAXIMUM_HEATFLUX:
5625-
Total_ComboObj+=Weight_ObjFunc*Surface_MaxHF_Visc[iMarker_Monitoring];
5626-
break;
56275599
default:
56285600
break;
56295601
}
@@ -5644,55 +5616,15 @@ void CEulerSolver::Evaluate_ObjFunc(CConfig *config) {
56445616
case NEARFIELD_PRESSURE:
56455617
Total_ComboObj+=Weight_ObjFunc*Total_CNearFieldOF;
56465618
break;
5647-
case INVERSE_DESIGN_PRESSURE:
5648-
Total_ComboObj+=Weight_ObjFunc*Total_CpDiff;
5649-
break;
5650-
case INVERSE_DESIGN_HEATFLUX:
5651-
Total_ComboObj+=Weight_ObjFunc*Total_HeatFluxDiff;
5652-
break;
5653-
case THRUST_COEFFICIENT:
5654-
Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CT;
5655-
break;
5656-
case TORQUE_COEFFICIENT:
5657-
Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CQ;
5658-
break;
5659-
case FIGURE_OF_MERIT:
5660-
Total_ComboObj+=Weight_ObjFunc*TotalCoeff.CMerit;
5661-
break;
5662-
case SURFACE_TOTAL_PRESSURE:
5663-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_TotalPressure(0);
5664-
break;
5665-
case SURFACE_STATIC_PRESSURE:
5666-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Pressure(0);
5667-
break;
5668-
case SURFACE_MASSFLOW:
5669-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_MassFlow(0);
5670-
break;
56715619
case SURFACE_MACH:
56725620
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Mach(0);
56735621
break;
5674-
case SURFACE_UNIFORMITY:
5675-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Uniformity(0);
5676-
break;
5677-
case SURFACE_SECONDARY:
5678-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_SecondaryStrength(0);
5679-
break;
5680-
case SURFACE_MOM_DISTORTION:
5681-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_MomentumDistortion(0);
5682-
break;
5683-
case SURFACE_SECOND_OVER_UNIFORM:
5684-
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_SecondOverUniform(0);
5685-
break;
56865622
case TOTAL_AVG_TEMPERATURE:
56875623
Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Temperature(0);
56885624
break;
5689-
case CUSTOM_OBJFUNC:
5690-
Total_ComboObj+=Weight_ObjFunc*Total_Custom_ObjFunc;
5691-
break;
56925625
default:
56935626
break;
56945627
}
5695-
56965628
}
56975629

56985630
void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,

0 commit comments

Comments
 (0)