Skip to content

Smooth airfoil surfaces - #1924

Merged
sbryngelson merged 4 commits into
MFlowCode:masterfrom
danieljvickers:smooth-airfoil-surfaces
Sep 29, 2026
Merged

sbryngelson merged 4 commits into
MFlowCode:masterfrom
danieljvickers:smooth-airfoil-surfaces

Conversation

@danieljvickers

Copy link
Copy Markdown
Member

Contribution Policy

Improvements made to the airfoil levelset calculation. We were getting errors getting smooth profiles because of the method we were using to estimate levelset values. In current master, we generate several points, compute distance to each point, and take the distance and vector that points to the closest point. This causes many problems when points are too close to the surface and when the correct intersection lies between points.

To improve this, I have refactored the the airfoil levelset code to treat airfoil surfaces as a 2D STL model, where we project onto lines that connect the surface points. We also more-densely sample points near the tips of the airfoil to better resolve the areas of higher curvature. This produces significantly improved convergence in surface pressure values.

The following shows comparison to a 2D airfoil case with 400 grid cells per chord length.
image

The case file to generate this has been added to the examples and is skipped to not add additional tests compared to the per-existing 2D airfoil case. Accordingly, the golden files for the 2D IBM airfoil test have been regenerated.

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: bdda83b

Files changed:

  • 9
  • examples/2D_ibm_airfoil_surface_pressure/case.py
  • examples/2D_ibm_airfoil_surface_pressure/convergence.png
  • examples/2D_ibm_airfoil_surface_pressure/readme.md
  • src/common/m_derived_types.fpp
  • src/common/m_model.fpp
  • src/common/m_patch_geometries.fpp
  • src/simulation/m_compute_levelset.fpp
  • src/simulation/m_ib_patches.fpp
  • toolchain/mfc/test/cases.py

Findings:

  • s_distance_normals_2D in src/common/m_model.fpp was changed from an (pid, boundary_edge_count, point, ...) signature that indexes the module-level gpu_boundary_v(..., pid) array directly, to an assumed-shape real(wp), dimension(:,:,:), intent(in) :: boundary_v dummy, while still carrying $:GPU_ROUTINE(parallelism='[seq]'). Callers now pass array sections/derived-type components into this device routine: gpu_boundary_v(:,:,:,patch_ib(patch_id)%model_id) in src/simulation/m_compute_levelset.fpp, and ib_airfoil_grids(airfoil_id)%upper/lower from the new s_airfoil_distance_normals. This breaks with the pattern used by the untouched sibling routines in the same file (s_distance_normals_3D, f_model_is_inside), which pass an integer pid/airfoil_id and index the device-resident global array directly rather than passing an assumed-shape section/component into a routine seq procedure. Assumed-shape array descriptors passed into GPU device routines are not uniformly supported across the CI-gated compilers (including AMD flang), so this is a portability risk relative to the codebase's existing GPU macro conventions.

@danieljvickers

Copy link
Copy Markdown
Member Author

@sbryngelson This is ready for review.

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_compute_levelset.fpp 452 -76
src/common/m_patch_geometries.fpp 70 -9
src/simulation/m_ib_patches.fpp 560 +1
Directory Lines Diff
common 10425 -9
simulation 27990 -75
total 46919 -84

@sbryngelson
sbryngelson marked this pull request as ready for review September 28, 2026 03:04
@sbryngelson
sbryngelson self-requested a review as a code owner September 28, 2026 03:04
Copilot AI balanced review requested due to automatic review settings September 28, 2026 03:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sbryngelson

Copy link
Copy Markdown
Member

these intrinsics

  gp%levelset_norm = matmul(rotation, normals)  ! convert the normal 

sometimes cause compiler slowdowns or issues (esp. amdflang). nothing to worry about now just keep in mind. i think we have helpers for small matmuls

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.50980% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.31%. Comparing base (1ececa3) to head (bdda83b).

Files with missing lines Patch % Lines
src/simulation/m_ib_patches.fpp 68.18% 5 Missing and 2 partials ⚠️
src/simulation/m_compute_levelset.fpp 58.33% 5 Missing ⚠️
src/common/m_patch_geometries.fpp 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1924      +/-   ##
==========================================
+ Coverage   61.07%   61.31%   +0.24%     
==========================================
  Files          86       86              
  Lines       22662    22612      -50     
  Branches     3342     3327      -15     
==========================================
+ Hits        13841    13865      +24     
+ Misses       6351     6281      -70     
+ Partials     2470     2466       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson
sbryngelson merged commit 0f7f62f into MFlowCode:master Sep 29, 2026
126 of 144 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants