# Libraries to deal with unstructured grids

I am dealing with a *.cgns file. This mesh format, when saved as an unstructured grid, holds nodes coordinates, nodes connectivity per element and boundary conditions. It is a neat mesh format with good documentation. However, I am still responsible for building the rest of the data structures for the calculations. For example, the face table for cell-centered FV schemes. This is a very delicate work which has to be done for every solver somehow (for cell-vertex solvers it would be the points neighboring I think).

So, since many folks out there had to develop this type of routines, I think it is reasonable to think someone smarter than me wrote a library which organize these data structures.

I was reading PETSc documentation for DMPlex but I am still trying to figure out how to give a *.cgns file to it. From what I saw, even compiling with cgns support, the file I/O for this format is not well established for this library. I am not criticizing anyone, PETSc is an awesome library.

My question is if there is any library out there which manages the creation of this type of data structures, not just for FV methods, but also for any type of scheme/solver? A quick bonus question... Is there anyone researching algorithms to create data structures for PDE solvers efficiently?

Most finite element libraries have the ability to read a good number of mesh formats. The library I work on, deal.II (see http://www.dealii.org) happens to have quite a number of mesh readers for VTK, UCD, GMSH, ... formats, see here: https://dealii.org/developer/doxygen/deal.II/classGridIn.html and its implementation here https://github.com/dealii/dealii/blob/master/source/grid/grid_in.cc . These readers are generally not terribly complicated (with the exception of the UNV format, which for historical reasons is really just a memory dump of one particular program) and relatively easy to extend to a new format such as the one you're interested in.

Once you have that out of the way, the whole rest then happens automatically: building meshes, building connections between cells, querying cells for their neighbors, bounding edges or vertices, or building numerical methods on them. In other words, the problem is nicely separated: All you would have to do is to write a reader for a particular mesh format, and every functionality of these libraries then becomes available to you immediately.

• Isn't dealii restricted to quads/hexes? – rchilton1980 Nov 12 at 18:30
• Correct. If you need something else, take a look at libmesh. That also has triangles and tetrahedra. – Wolfgang Bangerth Nov 13 at 3:52

Disclaimer: The post is about a library I am currently writing.

Hi. So, I do not have a library that has the algorithm to generate the exact neighbor information that you want. But I have a C++17 library which I'm working on a library called xmsh which can reproducibly store such information (and any information as such) once generated. The library/file format is still nascent and under development and only supports single file ASCII for now. However, it already has all the functionality needed if not yet the performance. It is also extendable to multiple file binary formats. In both cases, the data (as read from the file) would itself be stored on a single processor. Your mesh can then be reliably created out of the file data without having to regenerate all the quantities again.

Caveats:

1. library is C++17 library
2. It has been tested only on llvm-6.0, llvm-7.0 and gcc-8

If you however do find bugs and report them, I'll be more than happy to fix them.