Skip to content

Add Python wrappers for some NekMesh classes

Dave Moxey requested to merge dmoxey/nektar:feature/python-nekmesh into master

This MR adds support for NekMesh Python bindings. Credit to @gfarkas for adding tests and fixing bugs, as well as to Noah Yewman for providing the StructuredGrid.py and LoadCAD.py examples.

This is a fairly minimal wrapping at present: included are wrappers to enable Module, Mesh, the Element base class and Node to be accessed from Python. However, functionality is supported to subclass InputModule, ProcessModule and OutputModule from Python in order to define modules natively in Python. All NekMesh elements and modules can also be created through wrappers of the factory pattern.

A number of other changes have been made in this branch to align with this goal, hence the large size of the diff:

  • To enable C++ modules to be used from Python, all NekMesh modules have been moved to NekMeshUtils, in the same manner as we presently enable for FieldUtils.
  • Unit tests have been added by @gfarkas to test functionality of the bindings from Python, and Noah's examples have been added as regular tests so that the module subclass functionality is tested.
  • Consequently the Utils in NekMeshUtils was deemed to be pretty redundant: given that the diff here was already large owing to the change above, we opted to change NekMeshUtils to NekMesh in this branch also.
  • Python demos have been reorganised slightly so that they reflect the library structure that they use.
  • Corrected a couple of missing demos from the test suite.
  • Quite a major change is the backporting of std::shared_ptr support from upstream. This is a bit hacky, as it involves redefining some classes within boost.python itself. However these headers are rarely changed and, as this seems to work on all boost versions since our minimum supported version of 1.56, seems to be the best approach to solving some issues we were having with the use of Python-defined classes in these bindings.
Edited by Dave Moxey

Merge request reports