Closed michalhabera closed 6 years ago
meshio is really just a translator. If the input mesh has a z-component that's 0 everywhere, then the output mesh will have, too. It'd be weird to mess with that. I suppose this could be fixed either in gmsh itself -- or dolfin.
Well, I'm afraid that you're already messing with that a bit when reading xdmf3 mesh, see https://github.com/nschloe/meshio/blob/ecd790a2fbd3d8bb5c7048b5920dc1caf929be00/meshio/xdmf_io.py#L353-L354
But this is good. Each mesh that is potentially saved as planar can be read again by meshio. I've created the pull request #298 with a small fix adding the option save_as_planar
to meshio.xdmf_io.XdmfWriter
.
Alright now. I've looked at this issue again and found that meshio didn't properly handle 2D meshes at all. @mrehor gave a good example. The original reason for this was that some mesh formats (like VTK) don't support 2D meshes at all.
Now, I/O is handled properly (https://github.com/nschloe/meshio/pull/301) for those formats that support it (like XDMF). There also is a command-line option for meshio-convert
that allows pruning the z-components if it's all 0. This should hopefully satisfy your use case.
Thanks for fixing this @nschloe, works as expected.
See https://github.com/FEniCS/dolfinx/issues/159.
An option to force convert 3D mesh to 2D mesh (by stripping last component away) would be very useful. Some users are preparing planar (2D) meshes in
gmsh
, which embeds into 3D. Reading 3D mesh into finite element library results in larger system matrices and suboptimal computations for tensors ofrank >= 1
.