diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index eab91fca43c..52585922023 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -4358,19 +4358,31 @@ void CPhysicalGeometry::SetPositive_ZArea(CConfig* config) { const bool D3 = (nDim == 3); if (config->GetRefArea() == 0.0) { - if (D3) - config->SetRefArea(TotalPositiveZArea); - else - config->SetRefArea(TotalPositiveYArea); + if (D3) { + // Check if the area is valid + if (TotalPositiveZArea <= 0.0) { + SU2_MPI::Error( + "ERROR: Total positive Z area is zero or negative! Please check the geometry and ensure the area is valid.", + "CPhysicalGeometry::SetPositive_ZArea"); + } - if (rank == MASTER_NODE) { - if (D3) + config->SetRefArea(TotalPositiveZArea); + if (rank == MASTER_NODE) { cout << "Reference area = " << TotalPositiveZArea << A << ".\n"; - else + } + } else { + // Check if the area is valid in 2D + if (TotalPositiveYArea <= 0.0) { + SU2_MPI::Error( + "ERROR: Total positive Y area is zero or negative! Please check the geometry and ensure the area is valid.", + "CPhysicalGeometry::SetPositive_ZArea"); + } + config->SetRefArea(TotalPositiveYArea); + if (rank == MASTER_NODE) { cout << "Reference length = " << TotalPositiveYArea << L << ".\n"; + } } } - /*--- Set a semi-span value if no value is provided ---*/ if (config->GetSemiSpan() == 0.0) {