-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make geometry spline interpolation mesh independent #435
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long standing bug fixed. Changes are minimal for the Geometry group but the tests still need to be updated as mentioned.
This is great. I remember facing this bug a while ago and ended up using a custom geometry component for my project (bad practice, sorry!). Yes please update the test reference values. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #435 +/- ##
==========================================
+ Coverage 93.92% 93.94% +0.02%
==========================================
Files 104 105 +1
Lines 6472 6478 +6
==========================================
+ Hits 6079 6086 +7
+ Misses 393 392 -1 ☔ View full report in Codecov by Sentry. |
Done, I realised there were some other places using B-spline components with the same issue so fixed those too |
@sabakhshi probably better if you review this, not sure @lamkina is a particularly prolific OAS user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the my previous comments. I approve.
I removed myself as a reviewer, but my overall comment is the B-Spline corrections make sense so as long as the tests are passing this should be all set. |
I'll leave it up to @kanekosh to merge as he is the senior maintainer here. |
@sabakhshi or @kanekosh can one of you merge this? |
Purpose
Problem
OpenAeroStruct uses b-splines to interpolate geometric design variable values onto the mesh (either at mesh nodes or panel mid-points), these b-splines are defined over a coordinate range of 0 to 1, so it is necessary to map the spanwise coordinates of the mesh to the same range. In other words, we need to define where on the spline each mesh point interpolates it's design variable value from.
Currently, for all DVs that use this interpolation, we simply linearly space these interpolation points from 0 to 1. This works fine if your mesh has constant spanwise spacing but otherwise produces unintuitive results, it also means that for the same design variable values, changing the spanwise mesh distribution significantly changes the wing geometry.
Additionally, this approach means that for the t_over_c variable, the b-spline used for interpolation technically spans not from the root to the tip but from the centre of the first panel to the centre of the last panel. This means that, even if you keep a constant spanwise mesh spacing, the interpolation of t_over_c values will change depending on how many panels you use along the span.
Fix
This PR fixes the above issue by computing the points on the b-spline to interpolate from based on the actual mesh coordinates. This means that the wing geometry no longer depends on the spanwise mesh distribution, and the t_over_c interpolation no longer depends on the number of spanwise mesh points.
Example
In the case below I use the standard rectangular wing mesh and control x-shear and chord with 2 control points, one at the tip and one at the root. This should result in the chord length and x-shear being linearly interpolated on the wing, but with the current implementation this is not the case if you use cosine spanwise spacing (shown in blue). The Orange mesh is the geometry produced with the changes in this PR and is as you'd expect.
Expected time until merged
Type of change
Testing
A few of the tests currently fail because this PR slightly alters how t_over_c is interpolated which slightly changes the optimized reference values we test against, if you're happy with these changes I will update the reference values.
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable