JuliaVTK / WriteVTK.jl

Julia package for writing VTK XML files
Other
151 stars 32 forks source link

Support direction dependent degrees for `VTK_LAGRANGE_QUADRILATERAL` cells #110

Closed lcw closed 2 years ago

lcw commented 2 years ago

To support direction dependent degrees for VTK_LAGRANGE_QUADRILATERAL cells I need to add an attribute to the CellData tag, i.e., <CellData HigherOrderDegrees="HigherOrderDegrees">, along with the cell data. For reference see https://gitlab.kitware.com/paraview/paraview/-/issues/21550.

Adding the cell data is straight forward using the supplied interface but I don't know the best way to add the attribute. My first shot was

xroot = WriteVTK.LightXML.root(pvtk.vtk.xdoc)
xgrid = WriteVTK.LightXML.find_element(xroot, pvtk.vtk.grid_type)
xpiece = WriteVTK.LightXML.find_element(xgrid, "Piece")
xcelldata = WriteVTK.LightXML.find_element(xpiece, "CellData")
WriteVTK.LightXML.set_attribute(xcelldata, "HigherOrderDegrees", "HigherOrderDegrees")

which works except that the attribute doesn't propagate to the PCellData tag in the pvtu file.

Is there an interface for this already? If not what do you think about the following?

vtk[VTKCellData()] = Dict("HigherOrderDegrees"=>"HigherOrderDegrees")

This would loop through the key value pairs and add them as attributes to the CellData tag. Then _update_pvtk!(pvtk::PVTKFile) would copy all CellData attributes to PCellData.

lcw commented 2 years ago

I took a first cut at this here https://github.com/jipolanco/WriteVTK.jl/pull/111.

lcw commented 2 years ago

Fixed by #111.