Skip to content

Extend NekPy to support nonconformal meshes and allow mesh movement data to be written to file

Issue/feature addressed

I wanted to be able to generate nonconformal meshes using NekPy. This required some additional NekPy bindings and making it possible to write movement data to Nektar++ XML files.

Proposed solution

  • A Nektar::SpatialDomains::Movement::WriteMovement method was added, so movement data could be saved in an XML file
  • Nektar::SpatialDomains::Movement::AddZone and Nektar::SpatialDomains::Movement::AddInterface methods were written, to support creation of movement data programmatically (and not just by parsing XML)
  • NekPy bindings were written for Movement, Zone, and Interface classes
  • Bindings for various other methods were written, where they were found to be useful. This included the MeshGraph::WriteGeometry method.

Implementation

To make it possible to write movement data to an XML file, some more information about the composites and domains which interfaces and zones correspond to was needed. This required a few additional member variables and accessors for those classes, with corresponding modifications to the constructors. a WriteMovement method was added which could write the MOVEMENT section of Nektar XML.

In order to be able to build non-conformal meshes from scratch with NekPy, methods were written which could add zones and interfaces to the Movement class on-the-fly. This means it is now possible to build up a Movement object without having to read all of it in from an existing XML file.

A few argument and return-types had to be made const in order to work with Python bindings. As these appeared to be situations that were well-suited to constness, this was done rather than introducing a wrapper for the Python binding.

In addition to NekPy bindings for Movement, Zone, and Interface classes (and subclasses), bindings were added for the following methods of classes already available in NekPy:

  • Geometry2D::GetCurve
  • PointGeom::GetCoordinates
  • Geometry::SetGlobalID
  • MeshGraph::Write
  • MeshGraph::GetDomain
  • MeshGraph::GetMovement

New bindings were also written for the following classes:

  • FieldMetaDataMap
  • GeometryList
  • Composite
  • CompositeMap
  • MeshGraphXml
  • MeshGraphXmlCompressed

These changes were needed to make it possible to create meshes from scratch using the Python bindings.

Tests

Unit tests were written for the new Movement-related methods.

  • TestAddGetZones creates two dummy Zone objects, adds them to a Movement object, and then checks to see whether they are returned by the Movement::GetZones method.
  • TestAddGetInterfaces creates three dummy Interface objects, uses them to create 3 interface pairs on a Movement object, and then checks they are returned by the Movement::GetInterfaces method.
  • TestWriteMovement assembles a simple Movement object then calls Movement::WriteMovement. The resulting XML tree is then queried to make sure that all the Zones and Interfaces expected are contained within it.

Suggested reviewers

@dmoxey

Notes

This has been written for work on ExCALIBUR-NEPTUNE. It is being used for mesh generation in the NESO-fame project.

Checklist

  • Functions and classes, or changes to them, are documented.
  • User guide/documentation is updated.
  • Changelog is updated.
  • Suitable tests added for new functionality.
  • Contributed code is correctly formatted. (See the contributing guidelines).
  • License added to any new files.
  • No extraneous files have been added (e.g. compiler output or test data files).
Edited by Chris MacMackin

Merge request reports