Skip to content

Comments

FIX: Add safety check for zero reference area (Fixes #2435)#2687

Closed
ayush4874 wants to merge 1 commit intosu2code:developfrom
ayush4874:fix/ref-area-zero-check
Closed

FIX: Add safety check for zero reference area (Fixes #2435)#2687
ayush4874 wants to merge 1 commit intosu2code:developfrom
ayush4874:fix/ref-area-zero-check

Conversation

@ayush4874
Copy link
Contributor

Fixes #2435.

If REF_AREA is set to 0.0 (auto-calculation) but the geometry projection fails (e.g. flat plate aligned with projection plane), the area remains 0.0. This causes immediate divergence/NaNs later in the solver.

Added a check in SetPositive_ZArea to catch this case and error out cleanly via SU2_MPI::Error instead of crashing.

Verified using the NACA0012 testcase:

  • Validated that a standard run with REF_AREA=0.0 still works correctly (calculates ~1.0), ensuring no regression for valid cases.

@ayush4874 ayush4874 force-pushed the fix/ref-area-zero-check branch from 6869964 to 0a7fc93 Compare January 8, 2026 17:36
@pcarruscag
Copy link
Member

Reference area is not necessary for all physics in SU2

@ayush4874
Copy link
Contributor Author

ayush4874 commented Jan 8, 2026

Should I change this to a SU2_MPI::Warning, or should I move the check to where the coefficients are actually calculated?

@ayush4874
Copy link
Contributor Author

@pcarruscag can you please address this?

@pcarruscag
Copy link
Member

Error would be better, try to find a good place for it.

@ayush4874
Copy link
Contributor Author

Done. I reverted the changes in CPhysicalGeometry and moved the check to CEulerSolver::SetReferenceValues .

This ensures we only flag the error when the solver actually needs the reference area, without blocking other physics.

@pcarruscag
Copy link
Member

Still failing the tests and nota good place since that solver is not the only one that may use the reference area

@ayush4874
Copy link
Contributor Author

I think, this might be right, added the check to CIncEulerSolver (Incompressible) also. This will cover all aero solvers without blocking other physics.

@pcarruscag
Copy link
Member

sure just iterate on it until all the tests pass and let me know once you're done

@ayush4874
Copy link
Contributor Author

@pcarruscag can you have a look now?

@pcarruscag
Copy link
Member

Doesn't do what I asked before

@ayush4874
Copy link
Contributor Author

@pcarruscag is it alright now?

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error if something tries to do an invalid operation due to 0 ref area was the requirement

@ayush4874 ayush4874 force-pushed the fix/ref-area-zero-check branch 4 times, most recently from 2401333 to e7e9eba Compare January 29, 2026 21:39
@ayush4874
Copy link
Contributor Author

ayush4874 commented Jan 30, 2026

@pcarruscag can you have a look again?

@pcarruscag
Copy link
Member

It still doesn't look like it does what we want.

@ayush4874
Copy link
Contributor Author

I switched CFlowOutput to a soft return just to get the CI green, since the MMS regression tests were crashing without a REF_AREA.

Do you want me to keep this (maybe add a Warning?), or should I revert to the hard Error and just add a dummy REF_AREA to those failing test configs?

@ayush4874 ayush4874 force-pushed the fix/ref-area-zero-check branch from e7e9eba to d6771cb Compare February 15, 2026 19:56
@ayush4874
Copy link
Contributor Author

@pcarruscag I agree that Error is the right way, but it breaks the MMS regression tests. I tried to fix the test configs, but I found that TestCases is not a submodule in this branch, so I physically cannot commit changes to them in this PR.

To unblock the CI, I’ve switched CFlowOutput to a Warning for now.

Once this is merged, I will open a PR to su2code/TestCases to add the missing REF_AREA. After that is merged, we can switch this back to a hard Error.

@ayush4874 ayush4874 force-pushed the fix/ref-area-zero-check branch 2 times, most recently from 53b23d7 to 05e8842 Compare February 16, 2026 15:47
@ayush4874 ayush4874 force-pushed the fix/ref-area-zero-check branch from 05e8842 to d4625fe Compare February 16, 2026 17:05
@ayush4874
Copy link
Contributor Author

@pcarruscag I tried switching this to a print/warning, but it caused the thermal_beam_3d regression test to fail. It seems that test script compares the output log against a golden file, so the extra warning text triggers a diff error.

Since I can't update the TestCases repo within this PR (it's not a submodule here), I'm stuck between Error (Crashes legacy MMS tests (missing REF_AREA)) and Warning (Fails regression output comparison).

I've reverted to the silent return for now just to get the CI green. Once this is merged, I can open a PR to su2code/TestCases to add the missing reference area, and then we can come back and enforce the hard Error.

@pcarruscag
Copy link
Member

thanks.
to be honest this issue is just not a high enough priority to justify the amount of guidance that I think you need to make an acceptable solution.

@pcarruscag pcarruscag closed this Feb 16, 2026
@ayush4874
Copy link
Contributor Author

Understood. Thanks for your time in reviewing this. I didn't realize initially how much the legacy test dependencies would complicate what should have been a simple check. I'll look for a more self-contained issue to tackle next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants