solvcon / modmesh

Toolkit for solving partial differential equations
BSD 3-Clause "New" or "Revised" License
31 stars 38 forks source link

Use Bezier curve to fit NACA 4-digit airfoil #320

Open yungyuc opened 4 months ago

yungyuc commented 4 months ago

In the current prototype of the naca app, the airfoil is described using sampled edges. I'd like to try to describe the airfoil using Bezier curves, so that generating meshes for the airfoil shapes ca use arbitrarily high resolution.

Progress

Open for discussions

Add GUI control for changing the airfoil drawing and fitting parameters.

yungyuc commented 1 month ago

PR #384 adds a prototype that samples the 4th-order polynomial profile of the airfoil using both cubic bezier curves: https://github.com/solvcon/modmesh/blob/6e634cdb499d4e14a2e0b9dc81c67ed862d4319c/modmesh/gui/naca.py#L113-L127

And straight lines: https://github.com/solvcon/modmesh/blob/6e634cdb499d4e14a2e0b9dc81c67ed862d4319c/modmesh/gui/naca.py#L106-L110

But fitting is not done yet.

yungyuc commented 1 month ago

@YenPeiChen07 Could you please help completing all tasks for fitting the airfoil? I may add more as we go. But if the work lasts too long I may create a new issue to track.

If you are not familiar with an optimization algorithm like linear least square, perhaps discussing with @Gene0315 can help.

yungyuc commented 1 month ago

PR #406 refactors the code added in PR #384 and moved the calculating and drawing code from modmesh/gui/naca.py to modmesh/pilot/airfoil/__init__.py. modmesh/gui/naca.py is left for adding interactive GUI code in the future.

A reference to the wikipedia page https://en.wikipedia.org/wiki/NACA_airfoil is added in the code comment: https://github.com/solvcon/modmesh/blob/d9214b6d9534ef2b90ba1fd536aa2448f7f963be/modmesh/pilot/airfoil/__init__.py#L49

The related equations are listed in the wikipedia page. I also copied them in the code comments. The symmetric profile: https://github.com/solvcon/modmesh/blob/d9214b6d9534ef2b90ba1fd536aa2448f7f963be/modmesh/pilot/airfoil/__init__.py#L90-L100

The asymmetric profile (camber): https://github.com/solvcon/modmesh/blob/d9214b6d9534ef2b90ba1fd536aa2448f7f963be/modmesh/pilot/airfoil/__init__.py#L127-L148

yungyuc commented 1 month ago

Also in the future, we may consider to move other GUI code from modmesh/view.py to be under the package modmesh/pilot/. A package named as pilot may better suggest the geometry creation and mesh generation we are planning to add in modmesh. The old name view does not have the meaning.