Skip to content

Commit 53b23d7

Browse files
committed
FIX: Hard error on invalid REF_AREA during aerodynamic normalization
1 parent f4f327c commit 53b23d7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,11 @@ void CFlowOutput::AddAerodynamicCoefficients(const CConfig* config) {
17921792
}
17931793

17941794
void CFlowOutput::SetAerodynamicCoefficients(const CConfig* config, const CSolver* flow_solver){
1795-
1795+
if (config->GetRefArea() <= 0.0) {
1796+
SU2_MPI::RunTimeWarning("REF_AREA is 0.0 or geometry projection failed. Aerodynamic output will be skipped.", CURRENT_FUNCTION);
1797+
return;
1798+
}
1799+
17961800
SetHistoryOutputValue("REFERENCE_FORCE", flow_solver->GetAeroCoeffsReferenceForce());
17971801
SetHistoryOutputValue("DRAG", flow_solver->GetTotal_CD());
17981802
SetHistoryOutputValue("LIFT", flow_solver->GetTotal_CL());

SU2_CFD/src/solvers/CAdjNSSolver.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short
262262
/*--- Objective scaling: a factor must be applied to certain objectives ---*/
263263
for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) {
264264
Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring);
265+
ObjFunc = config->GetKind_ObjFunc(iMarker_Monitoring);
266+
267+
if ((ObjFunc == DRAG_COEFFICIENT) || (ObjFunc == LIFT_COEFFICIENT) || (ObjFunc == SIDEFORCE_COEFFICIENT) ||
268+
(ObjFunc == MOMENT_X_COEFFICIENT) || (ObjFunc == MOMENT_Y_COEFFICIENT) || (ObjFunc == MOMENT_Z_COEFFICIENT)) {
269+
if (RefArea <= 0.0) {
270+
SU2_MPI::Error("The requested adjoint objective requires a valid REF_AREA, but it is currently 0.0.", CURRENT_FUNCTION);
271+
}
272+
}
265273

266274
factor = 1.0/(0.5*RefDensity*RefArea*RefVel2);
267275

@@ -643,6 +651,13 @@ void CAdjNSSolver::Viscous_Sensitivity(CGeometry *geometry, CSolver **solver_con
643651
factor = 1.0;
644652
/*-- For multi-objective problems these scaling factors are applied before solution ---*/
645653
if (config->GetnObj()==1) {
654+
if ((ObjFunc == DRAG_COEFFICIENT) || (ObjFunc == LIFT_COEFFICIENT) || (ObjFunc == SIDEFORCE_COEFFICIENT) ||
655+
(ObjFunc == MOMENT_X_COEFFICIENT) || (ObjFunc == MOMENT_Y_COEFFICIENT) || (ObjFunc == MOMENT_Z_COEFFICIENT)) {
656+
if (RefArea <= 0.0) {
657+
SU2_MPI::Error("REF_AREA is 0.0. Cannot compute viscous sensitivity for aerodynamic objective.", CURRENT_FUNCTION);
658+
}
659+
}
660+
646661
factor = 1.0/(0.5*RefDensity*RefArea*RefVel2);
647662

648663
if ((ObjFunc == INVERSE_DESIGN_HEATFLUX) ||

0 commit comments

Comments
 (0)