Skip to content

Updated mesh reading for Gmsh version 4 - #77

Merged
brendanjmeade merged 5 commits into
mainfrom
fix_mesh_display
Feb 23, 2026
Merged

brendanjmeade merged 5 commits into
mainfrom
fix_mesh_display

Conversation

@jploveless

Copy link
Copy Markdown
Collaborator

celeri_ui was written for Gmsh version 2 files. We're no longer using these, and the modern version 4 files are formatted really differently. I hacked together some changes that might not be perfect, but meshes are now displaying, at least when loaded one-by-one.

The previous version of Gmsh files made things easier, specifying the dimension of mesh elements as the first number of each line within the $Elements block. The new version is meant for more of a line-by-line parsing, with some lines specifying the dimensions and then the number of elements n of that physical section, with the next n lines just containing the vertex indices.

To accommodate this knowing no TypeScript, I find the $Elements section, then find the index where the 2-D elements (triangles) start, then filter out any lines that start with a 2, which indicate subsequent blocks of 2-D elements (but not their actual vertices). This seems reasonable, because Gmsh always (?) defines 0-D and 1-D elements in a .msh file, and so no triangle will have the index of 2, and therefore we won't be missing it when parsing the element indices.

This is not a great way to read a mesh, but really all we need to do is display it, so I think it's fine. I also had to include a wrap-to-360 statement when reading node longitudes.

@jploveless

Copy link
Copy Markdown
Collaborator Author

Oh, this definitely breaks support for old versions of Gmsh, and so the GitHub action tests are failing.

@jploveless

Copy link
Copy Markdown
Collaborator Author

Edited the toy coordinates and nodes in mocha/tests/FileOpenerTests.spec.ts and now tests are passing.

@brendanjmeade
brendanjmeade merged commit 2ea77a3 into main Feb 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants