Skip to content

Conversation

@svengoldberg
Copy link
Contributor

@svengoldberg svengoldberg commented Dec 22, 2025

General

This PR introduces the possibility to create b-spline profiles by approximating the user-set CPACS point list.
This is implemented for fuselage profiles and wing airfoils currently. It is still possible to define an index list of points that should be interpolated.

Thanks to @sdeinert for coming up with the CPACS definition!!
We extended it by the option to pass the error computation method and the optional index list for points that should be interpolated.

@MarAlder what do you think about our suggestion to extend the CPACS schema?

Code Behaviour

The user can now define the wanted number of control points that is used to approximate the profile. When kinks or guide curves are defined, this number may still be larger than what is defined in CPACS, for mathematical reasons. Nevertheless, the user now has more flexibility to determine the geometric behaviour of each profile. As a natural result from this reduced number of control points, an approximation error is introduced. The user can currently select from the computation as the root mean square error or the maximum error within CPACS. The respective choice and value are printed within the TiGLCreator GUI for better feedback.
In CPACS we also defined the other way round: Meaning, that a maximum tolerance for the approximation error can be defined and TiGL defines the control point number on its own. But, this still needs to be implemented in another pull request.

Unittests are added for both a wing and fuselage profile.

Implementation Details and Code Refactorings

The present implementation comes with quite a few changes and refactorings of yet existing code.

  • In general: The change for realizing this approach for fuselage profiles is less complex than the change for airfoils. This is result of the more complex structure of the yet existing code.
  • The new CPACS node results in a new generated class and some additional minor changes.
  • The WireCache type defined in src/wing/CTiglWingProfilePointList.h is split up. Before, it contained both the opened and closed wire. The save computation time and output, the cache is split into two different ones. Only the needed one (closed or opened) is computed. For that, parts of the class had the be rewritten.
  • The currently unused class src/geometry/CTiglApproximateBsplineWire was refactored to account for the new CPACS nodes and for it to store the necessary variables.
  • The profile approximation is realized using the class src/geometry/CTiglBSplineApproxInterp and its already defined functions which is almost unused up to now. Here, the error computation is changed to be more accurate. This is also the explanation for the needed change of the unittest value. Now, the approximation error is computed based on the difference between the beforehand defined points in the point list and an (approximation) of their projection on the new b-spline curve. Also, the error actual computation (2 point vectors) is outsourced to functions in src/common/tiglcommonfunctions. The function is passed as a function pointer to the solve method for more flexibility as we allow different ways of computation.
  • Additionally, the approximation in src/geometry/CTiglApproximateBsplineWire is now also based on CTiglBSplineApproxInterp to make use of existing code and to be consistent with the fuselage implementation. Before, an OCCT-function was called here. However, we wanted to define the number of control points which was not really possible with the OCCT-function.
  • Finally, the computeParams functions from src/geometry/CTiglInterpolatePointsWithKinks has to move from an anonymous namespace into the tigl namespace since it is also needed outside from this class.

Fixes #1276.

Checklist:

Task Finished Reviewer Approved
At least one test for the new functionality was added.
  • yes
  • does not apply
  • OK
New classes have been added to the Python interface.
  • yes
  • does not apply
  • OK
The code is properly documented with doxygen docstrings
  • yes
  • does not apply
  • OK
Changes are documented at the top of ChangeLog.md
  • yes
  • does not apply
  • OK

Additionally added options: User can define the approximation error method, currently: root mean square error or maximum error. Furthermore, the user can pass an index list within the CPACS configuration to define which points should still be interpolated. The other points, however, are approximated. The unittests needed to be changed to test for this behaviour. Also, a mistake was fixed, since the was a confusion regarding 0-based and 1-based indexing within th logic of interpolation indices.
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 58.36576% with 107 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.19%. Comparing base (ea6c6ca) to head (1e3cd37).

Files with missing lines Patch % Lines
src/geometry/CTiglApproximateBsplineWire.cpp 49.29% 36 Missing ⚠️
src/fuselage/CCPACSFuselageProfile.cpp 17.94% 32 Missing ⚠️
src/wing/CTiglWingProfilePointList.cpp 71.59% 25 Missing ⚠️
src/geometry/CTiglInterpolateBsplineWire.cpp 0.00% 6 Missing ⚠️
src/geometry/CTiglInterpolateLinearWire.cpp 0.00% 6 Missing ⚠️
src/common/tiglcommonfunctions.cpp 87.50% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1277      +/-   ##
==========================================
- Coverage   72.46%   72.19%   -0.27%     
==========================================
  Files         313      314       +1     
  Lines       27395    27592     +197     
==========================================
+ Hits        19851    19920      +69     
- Misses       7544     7672     +128     
Flag Coverage Δ
unittests 72.19% <58.36%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/CCPACSStringVector.cpp 88.00% <100.00%> (+0.76%) ⬆️
src/common/tiglcommonfunctions.h 100.00% <ø> (ø)
src/geometry/CTiglBSplineApproxInterp.cpp 96.98% <100.00%> (+0.02%) ⬆️
src/geometry/CTiglBSplineApproxInterp.h 100.00% <ø> (ø)
src/geometry/CTiglInterpolateBsplineWire.h 0.00% <ø> (ø)
src/geometry/CTiglInterpolatePointsWithKinks.cpp 100.00% <100.00%> (ø)
src/geometry/ITiglWireAlgorithm.h 100.00% <ø> (ø)
src/common/tiglcommonfunctions.cpp 78.52% <87.50%> (+0.12%) ⬆️
src/geometry/CTiglInterpolateBsplineWire.cpp 44.00% <0.00%> (ø)
src/geometry/CTiglInterpolateLinearWire.cpp 0.00% <0.00%> (ø)
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add feature to create profiles/airfoils from point lists that are not interpolated, but approximated

2 participants