Skip to content

Debug airfoil sign error#1443

Open
danieljvickers wants to merge 4 commits into
MFlowCode:masterfrom
danieljvickers:debug-airfoil-sign-error
Open

Debug airfoil sign error#1443
danieljvickers wants to merge 4 commits into
MFlowCode:masterfrom
danieljvickers:debug-airfoil-sign-error

Conversation

@danieljvickers
Copy link
Copy Markdown
Member

Description

The levelsets of airfoils have a sign error, causing them to point into the aifoil rather than away. This causes the airfoil IB to suck in fluid rather than repel it. This is very evident in low mach numbers and causes instabilities.

Type of change

  • Bug Fix

Checklist

  • I added or updated tests for new behavior
  • I updated documentation if user-facing behavior changed

See the developer guide for full coding standards.

GPU changes (expand if you modified src/simulation/)
  • GPU results match CPU results
  • Tested on NVIDIA GPU or AMD GPU

@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions
Copy link
Copy Markdown

Claude Code Review

Head SHA: 418efe8

Files changed:

  • 1
  • src/simulation/m_compute_levelset.fpp

Findings

1. s_airfoil_levelset (2D): upper and lower surfaces now use opposing normal conventions

The PR reverses dist_vec for the lower surface only, leaving the upper surface unchanged. After this diff:

  • Upper surface (unchanged): dist_vec = xy_local - airfoil_grid_u(global_id) — vector points from surface point toward ghost point (outward)
  • Lower surface (changed): dist_vec = airfoil_grid_l(global_id) - xy_local — vector points from ghost point toward surface (inward)

Both branches feed directly into:

gp%levelset_norm = matmul(rotation, dist_vec(:))/dist

For a 2D airfoil, levelset_norm now points outward for ghost points above the chord line and inward for ghost points below it. This inconsistent sign on the lower-surface normal will corrupt boundary condition enforcement at those ghost points.

2. s_3d_airfoil_levelset (3D): all surface normals now point inward

Both the upper and lower branches of the 3D subroutine are flipped. The resulting dist_vec in every branch now points from the ghost point toward the nearest surface point (inward), and is stored directly as:

gp%levelset_norm = matmul(rotation, dist_vec(:)/dist_surf)

Every other geometry in this module (s_circle_levelset, s_sphere_levelset, s_rectangle_levelset, s_cuboid_levelset) builds dist_vec as ghost_point_position − surface_point_position, yielding an outward-pointing normal. The post-PR 3D airfoil normals are systematically reversed relative to the module convention, producing wrong wall-normal directions for IB boundary conditions in 3D.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.31%. Comparing base (7081882) to head (418efe8).

Files with missing lines Patch % Lines
src/simulation/m_compute_levelset.fpp 0.00% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1443   +/-   ##
=======================================
  Coverage   61.31%   61.31%           
=======================================
  Files          72       72           
  Lines       19771    19771           
  Branches     2852     2852           
=======================================
  Hits        12123    12123           
  Misses       5699     5699           
  Partials     1949     1949           

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Copy Markdown
Member

@danieljvickers have a look at the claude comments for a double check

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.

2 participants