Fix reordering Prisms for ProcessPerAlign
Issue/feature addressed
When importing a mesh from third-party (StarCCM++, Gmsh) with multiple Prism layers, NekMesh failed to output because the IDs of the prisms are not correctly ordered. It might be because other software have different way of ordering prisms and their mesh cannot be read by nektar. This problem only happens when the thrid-party mesh has multiple prism layers. Note that it is fine if we generate only one prism layer and then use ProcessBL to split prism layers. Process PerAlign sometimes also failed because this orientation problem.
Proposed solution
The function ReorderPrisms() should re-orders the IDs of the vertices of a prism from small to large. In a prism element, when one triangle face is reordered and the other face is wait to be re-ordered, the old way of sorting vertices failed.
Implementation
1. For the function "ReorderPrism()" in "Module.cpp", use a lambda function to sort the IDs of the vertices.
2. As this problem does not happen very often, we do not need to check the orientation at all times. I added the option "orient" in output module, and we can call "outputfile.xml:xml:orient" if reordering is needed during the output.
Tests
Sometimes I got the following error where the orientation of triangles are not consistent during ProcessPerAlign. It worked after the fix.
Fatal : Level 0 assertion violation
Orientation of triangular face (id = 111689) is inconsistent with face 3 of prism element (id = 55279) since Dir2 is aligned with Dir1. Mesh setup needs investigation
libc++abi: terminating due to uncaught exception of type Nektar::ErrorUtil::NekError: Level 0 assertion violation
Orientation of triangular face (id = 111689) is inconsistent with face 3 of prism element (id = 55279) since Dir2 is aligned with Dir1. Mesh setup needs investigation
I got the same error when converting msh format to xml using the following command:
NekMesh in.msh out.xml
And it worked with:
NekMesh in.msh out.xml:xml:orient
Suggested reviewers
Please suggest any people who would be appropriate to review your code.
Notes
Please add any other information that could be useful for reviewers.
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).