Skip to content

Python wrapper and associated changes

Boman Romain requested to merge python_wrapper into master

Created by: msanchezmartinez

This pull request includes several large changes to the code. Most of them deal with the Python wrapping. Some have to do with memory management, especially on the C part of the code. README file updated as well.

CMake

Many things have been changed on the CMake part of the code so that it could be used with Python.

  • VLMMacros now includes different tests for wrapper and non-wrapper versions
  • FindNUMPY from CUPyDO
  • CMakeLists checks for Python 2.7 if required
  • Flat plate test added

Matlab code

Used for post-processing.

  • Removed outfile.m
  • Modified drawwing.m for some lacking surfaces

Swig

This is the code that creates the Python wrapper.

  • Included numpy.i
  • Created VLM_ADS.i

Python code

  • Created module pythonVLM
  • VLM_inputs: handles the input files to be created, both for properties and for geometry (including already exiting arp files)
  • VLM_utilities: creating the workspace and adding folders to the python path
  • VLM_driver: provides the driver of the simulation, as well as numerous functions, getters and setters for use with CUPyDO
  • VLM_testing: simple tests for the VLM code
  • run.py: is able to run the different tests

C code

Most changes appear in order to ease the python wrapping. Some reduce the memory footprint and remove memory leaks.

  • Setup and iteration routines extracted from the main function (to vGeometrySetup, vSetup, vIteration)
  • Created VLMData struct to hold all VLM data
  • Deallocated many allocated variables here and there, to avoid memory leaks
  • Removed unused variables
  • Adapted routines to use VLMData instead of many different arguments
  • Adapted vHTail, vVTail, vWing to work when no control surfaces are present

Testing

Both Python wrapper based tests and non-Python wrapper based tests are present. All in the second group have a Python equivalent. Testing using python enables the comparison to "standard" values, while the older version just checked that it did not crash.

All tests give the same results on my machine (OS X, clang), gaston (Debian, gcc), my laptop (Windows 10, MSVC) and an Ubuntu 18.04 LTS VM (gcc). They are quite fast, taking in total under a minute. Some geometry files have been moved to a models subfolder, similar to CUPyDO.

Merge request reports

Loading