Closed lijas closed 4 years ago
Hi, it would be great to add support for Bézier cells, but I'm not sure about how this should be done.
From looking at the link, it's not entirely clear for me how they work in VTK. From what I understand, one has to specify weights and the degree of the polynomials. For instance, in TestBezier.cxx:
ugrid->GetPointData()->SetRationalWeights(rationalWeights);
ugrid->GetCellData()->SetHigherOrderDegrees(degrees);
I don't know how this translates into the generated XML files. But in principle yes, I think some more code is required.
I don't really know how VTK works at all. Are all the other standard cells (like quads, trias) exported in a certain xml format? I guess one have to read the documentation on how the xml for at bezier cell should be structured.
It looks like bezier cells are released in vtk 9.0, but it is unclear when.
Roughly speaking, the VTK libraries and the VTK file formats are two separate things. The libraries can of course read and write VTK files, and they are used by applications such as ParaView to do so. The (modern) VTK file formats are based on XML.
The purpose of this package is to write VTK XML files using a lightweight, pure Julia implementation, thus avoiding the VTK C++ libraries. The idea is that the produced files are compatible with (can be read by) the VTK libraries.
So, to support Bézier cells, the first step is to understand what they look like when the VTK libraries output an XML file containing Bézier data. This may be done either by looking at the VTK C++ source code, or at a file generated by VTK 9.0.
Ok thank you for the information. From what I know from bezier curves, they are defined by "control points", which acts similar to nodes used by regular element. So I guess the output should be pretty similiar to standard cells. There also seem to be possible to specify weights to each control point/basis function: https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Rational_B%C3%A9zier_curves
Do you know if we also have to wait for paraview to update their VTK version to 9.0, or is it possible to like specify which version to use? I dont know, but it might be a long process for paraview to update their vtk version...
Apparently ParaView 5.8 will be released soon, and there's a release candidate available. From looking at the ParaView repo, it seems like the VTK version included in the release candidate already has support for Bézier elements. So at least we would be able to test the WriteVTK implementation, once we have one.
Hello again. I was looking a bit more into how the general xml/vtu format worked, and it seems to be pretty straight forward.
Like you said, when outputing a beizer element, there should be some way to specify the order of the element in each direction, and the weights for each point. the question is, what are the names of the xml-tags...
I tried asking the vtk forum, but they have not responded yet. I tried to export a file using the python api, but it was not updated since 2016, so there was to bezier support. I do not know how to use c++ so I cant export an example xml file using c++.
Are you able to produce an example xml file in some way?
The obvious way to produce a VTK file with Bézier cells would be to run one of the test files that come with the VTK source code, like the TestBezier.cxx file that I mentioned above. For this, one first needs to compile the whole C++ library.
I've compiled the vtk library and run the Bézier test. Have a look at the .vtu files. I did not manage to view them on paraview. So if someone finds a solution for this please tell me how it's done.
Great, now we have something to work with :)
I was able to open them in Paraview 5.8 by removing the top line <?xml version="1.0"?>
in the files.
Looks the relevant xml-tags are: <PointData RationalWeights="RationalWeights">
It also looks like they use this tag: <InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
, but I dont know if it is needed.
Sorry for the misrepresented problem. For sure I can open the files in paraview even with the top line <?xml version="1.0"?>
. But they are not rendered as shown in the vtk blog or the report. I can only see the control nodes or the weights of the Bézier cells, but that's not helpful at all.
My paraview and vtk version is
Version: 5.8.0-640-gb32910c740
VTK Version: 9.0.0.rc2-776-g687d6a5f7c
Can someone get the interpolated representation of the Bézier cells as shown in the examples on the vtk homepage?
I get the same rendering as you. I think there should be some subdivision level for how smooth stuff should be rendered.
Okay. So can you tell me if you find a solution for that? My sphere looks like the image you have uploaded.
I get the same rendering as you. I think there should be some subdivision level for how smooth stuff should be rendered.
Thanks for the files!
Okay. So can you tell me if you find a solution for that? My sphere looks like the image you have uploaded.
It seems like you need to apply the Tesselate filter. Rendering smooth shapes is not the default because it's expensive. This is mentioned at the end of this blog post by Kitware.
By the way, it would be a good idea to also implement support for Lagrange elements, since these were introduced a few years ago, and Bézier elements seem to be based on Lagrange ones.
@jipolanco thank you very much! Finally I get the expected results.
In VTKCellTypes.jl
, it seems like the higher order Lagrange cells are already implemented?
How should the interface/api for the bezier cells looks like. Should the user add RationalWeights and HigherOrderDegrees through vtk_point_data(grid, "RationalWeights", rw)
and vtk_cell_data(grid, "HigherOrderDegress", orders)
themself? Becuase then I dont think there is that much code to write other than adding the celltypes to VTKCellTypes.jl
Or should we some helper functions, like add_rational_weights(..)
?
I just added the Bézier cell types in VTKCellTypes.jl
to the bezier
branch, see #64.
From looking at the generated files, maybe you're right and the existent vtk_point_data
and vtk_cell_data
are enough.
It seems to work!
I just generated one of the VTK examples in test/bezier.jl
.
Let me know if it works for you (it's in the bezier
branch) and I'll merge the PR.
Nice!. I will try exporting bezier cells from my fe code later.
Just for your information. There is another possibility to get a better resolution of the paraview rendering.
In the properties (ensure advanced options are enabled pressing the gear icon on the top right side of the property tab) there is a field Miscellaneous
Play with the field nonlinear subdivisions which yields a better resolution
I tried exprting 2d bezier quads, and it worked. I have not tried HigherOrderDegrees or RationalWeigts though...
Hi Recently VTK added support for bezier element: https://gitlab.kitware.com/vtk/vtk/merge_requests/6055
VTK_BEZIER_CURVE VTK_BEZIER_TRIANGLE VTK_BEZIER_QUADRILATERAL VTK_BEZIER_TETRAHEDRON VTK_BEZIER_HEXAHEDRON VTK_BEZIER_WEDGE VTK_BEZIER_PYRAMID
Is it possible to just add these to the cell-types file for them do be used, or is more code required to add these element types?