elrnv / vtkio

Visualization ToolKit (VTK) file parser and writer
Apache License 2.0
55 stars 12 forks source link

Do not skip serializing number of cells for VTU output? #31

Open Andlon opened 1 year ago

Andlon commented 1 year ago

ParaView and meshio complain when NumberOfCells="0" is missing in the output XML. I'm not sure what the reason is for skipping it, but apparently not skipping the serialization is sufficient to fix ParaView. meshio seems to have other troubles. I glanced at the code of meshio and it might just be that their logic is broken for empty meshes. I'm not entirely sure as I'm not so fluent in the style of Python they use.

I wanted to add a test but I couldn't quite figure out the structure of tests, i.e. where to put it, and how best to create a test like this. With some hints I might be able to do that.

elrnv commented 1 year ago

Hi @Andlon! thanks the PR! Could you include a new test in the tests subdirectory called "paraview.rs" and add your test there? You can think of each test file being there to address a certain class of features (legacy vs. xml vtk files) or compatibility (pygmesh/meshio). Please indicate the version of ParaView in the comments of the test. Could you also add a subdir in the assets folder called "paraview" and place your test file there so it's easy to find when working with paraview compatibility issues.

Let me know if you have ideas of how to organize the tests. There didn't seem to be a need for this before since there are not a lot of tests.

elrnv commented 1 year ago

I think the reason why number of cells is not serialized is to omit it from polygon meshes, which are not supposed to have cells. This is why the test is failing. Perhaps we should decide what to serialize based on the type of mesh.