High-Order VTK Output Mode

Hi everyone,

With the recent merge of PR 195, PyFR is now capable of exporting solution and grid data in vtu format using high-order VTK cells, referred to as Lagrange cells in VTK [1]. This allows VTK (and therefore ParaView) to utilize the same interpolation polynomials than those found in PyFR to represent high order solution data without explicit element sub-division. The order of the solution data found in the post-processing vtu files may be controlled by the user as it will be explained further in this post. The advantages of the high-order VTK output method compared to the original subdivision method are

  • Reduction of the size of post-processing files.
  • Accurate computation of solution data gradients using the Gradient of Unstructured Dataset filter, without the need of directly storing the gradients in the output.
  • Enhancement of the visualization of solution data within the grid elements.
  • Improved visual representation of curved non-linear elements (see all attached images for some examples of these benefits).

To display the solution in grids with high-order cells, VTK will internally sub-divide non-linear cells and then interpolate the solution to the the sub-division nodes (which are not visible unless the Point representation option is activate within Paraview) using Lagrange polynomials correspondent to the order of the considered element. The level of internal subdivision of ParaView can be controlled using the Nonlinear Subdivision level parameter which can be found within the Display menu in Paraview as shown in the following image

image

See the Examples section for more information on how the influence of this option in the visualization of high-order data.

Moreover, ParaView will now directly read the physical time information of output vtu files containing instantaneous solution data. This allows to utilize the physical time to improve the generation of animations within ParaView and to better distinguish the information found in each solution snapshot. The user may discard the physical time information by selecting the Time Array option in the Properties widget.

These new additions are only compatible with ParaView >= 5.9.0 and VTK>=9.0. If you do not have access to such versioning of the aforementioned tools, the subdivision method, which is activated with the -d argument in the export command, must be used. Refer to the following section for more information.

Usage

An example of the export command which allows to obtain solution data with high-order cells in vtu format is

pyfr export --order 4 mesh.pyfrm solution.pyfrs solution.vtu

The previous command will output the solution data using fourth order non-linear cells. The --order argument may also be replaced with -k. The subdivision argument -d functionality remains unchanged although it is worth noting that it cannot be combined with the --order argument. The former argument must be used if the post-procesing is not performed with ParaView >= 5.9.0.
With this new implementation, some API changes have been introduced to the export command. For example, if no arguments are provided then the solution will be exported in vtu format using non-linear cells of order equal to the solution order. This might incur some regression issues as the export command defaulted to one explicit subdivision before the implementation of this new functionality. Further information of the new export command API will be available in the User Guide of the next release of PyFR.

Examples

  1. Visualization of the curved shape of non-linear cells of a grid made up of degree 2 hexahedron (hex27 elements) with different choices of Nonlinear Subdivision level.

nonLinear_div0
Nonlinear Subdivision level = 0

nonLinear_div3
Nonlinear Subdivision level = 3

  1. Visualization of the Density variable in the euler_vortex_2d test case with different choices of Nonlinear Subdivision level. The dots indicate the internal subdivision points that ParaView generates to improve the visualization of high-order data.

vortex_div0
Nonlinear Subdivision level = 0

vortex_div1
Nonlinear Subdivision level = 1

vortex_div2
Nonlinear Subdivision level = 2

Recommended practices in ParaView:

  • Utilize the Clean to Grid filter of ParaView before proceeding with any operation, unless point merging results in unwanted visualization artifacts due to solution discontinuities (which might be the case for very high-order and/or under-resolved simulations).
  • Do not increase the Nonlinear Subdivision Level in intermediate steps of your postprocessing pipeline to avoid increasing the memory footprint and computational cost of your post-processing procedures.
  • Always activate the Crinkle option in the Slice and Clip filters whenever possible to ensure that the resulting grid is made up high-order elements, otherwise ParaView will output a triangulated grid without high-order data.
  • Activate the Enable Auto-MPI option in Edit->Settings to speed-up the post-processing operations whenever possible.

Future work

  • Choose the order of the non-linear cells based on the modal expansion of the solution within each element. If the solution at a given element is close to constant, there is no need to utilize a very high-order non-linear VTK cell to represent the solution within the considered element.
  • Compatibility with pyramid elements. VTK currently only supports VTK_QUADRATIC_PYRAMID as high-order pyramid element. Therefore, we have decided to drop support for high-order pyramid cells and we always use explicit subdivision for pyramid elements.
  • Allow to use explicit sub-division in combination with high-order VTK elements.
  • Add point merging functionality to the export procedure in PyFR.
  • Monitor possible changes and improvements of the implementation of high-order cells in VTK.

Acknowledgments

@GonzaloS: Implementation, Validation and Testing
@fdw: Implementation, Refactoring, Review and Testing
@Giorgio_Giangaspero: Review, Testing
@WillT: Review and Testing

Feedback

Please let us know if you find any bugs and do not hesitate to provide us with feedback to improve this newly added functionality.

2 Likes

This post is very informative and covers a wide range of topics, which has been incredibly helpful to me. However, I have a few minor questions regarding my usage of pyFR 1.15.0:

  1. The ā€œ-dā€ parameter seems to be related to division and appears to be deprecated. Iā€™d like to understand it better because I want to know if there is a so-called division method available when higher-order VTU is not an option. I havenā€™t updated to the latest license of Tecplot 360 2023 R1, and in the 2022 R1 version, it seems that higher-order VTU is not available. Iā€™m wondering if the ā€œ-dā€ parameter could be effective and if itā€™s possible to perform post-processing in older versions of Tecplot with this parameter if higher-order VTU is not an option.

  2. In pyFR 1.15.0, when using the export command, the ā€œā€“order nā€ command is now applied by default, which is convenient. However, Iā€™m currently using Paraview version 5.5.2, which is older than 5.9.0. However, I was surprised to discover that even in the lower version of Paraview 5.5.2, the ā€œNonlinear Subdivision Levelā€ option exists, and it seems to function correctly. Could you clarify if there are any potential risks associated with using a lower version of Paraview? This will help me decide whether itā€™s necessary to upgrade to a higher version. Iā€™d prefer not to switch versions but also want to avoid potential issues.

  3. Itā€™s well-known that after completing a simulation, you can use the export command to output pyFR results as VTU or PVTU for post-processing. However, Iā€™m curious if itā€™s possible to export the results in formats other than those related to VTU. I havenā€™t found any references on this.

I appreciate the ongoing efforts of the developers!

Sincerely regards.

The subdvision support is still available in PyFR. It is sometimes useful when you want to work with filters in ParaView that do not make use of non-linear subdivision (and so give poor results with high-order VTU files).

It is my understanding that some of the node numbers were changed between versions of ParaView. As such, our files may not work on some older versions. I would strongly suggest upgrading to 5.11.

Only VTU files are supported. These are reasonably efficient and well supported.

Regards, Freddie.

Thank you for your response, itā€™s very inspiring.

However, I donā€™t understand the significance of ā€˜-d n,ā€™ and what benefits does it bring to my data processing when I split it? I seem to have not found any explanations about it anywhere. Could you please explain why this is done and how I should choose the value of ā€˜nā€™?

Iā€™d love to test it through examples, but unfortunately, after calculating the standard Couette flow case provided on the official website, I used the following command:

pyfr export -d 1 couette-flow.pyfrm couette-flow-001.pyfrs couette-flow.vtu

Then it reported the following error:

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

This is why I mistakenly thought it was deprecated. My pyFR version is 1.15.0, and my numpy version is 1.25.1. Have I done something wrong, or do I have to use an older numpy version, less than 1.20?

Best Regard.

Before Paraview supported high-order elements, we needed a way to view the high-resolution results of PyFR. Subdivision was a good option; this takes a single element and interpolates the solution polynomial to a uniform set of points. These points are then used to construct a new set of elements inside the original element. These new elements are then written to the vtu file. As an example, take the Euler vortex example and export the result with the -d flag, then in Paraview have a look at the result using ā€œsurface with edgesā€ and youā€™ll see the number of elements changes as you vary the subdivision.

This is also how we handle high-order elements in the ascent plugin.

The advantage of using high-order elements when exporting is that the resulting vtu can be ā€œexactā€, and they require significantly less memory for the same number of elements.

1 Like

Thank you for your prompt response. I now have a conceptual understanding of the ā€œ-d nā€ parameter command.

However, at least for the Couette-flow case provided on this website, I encountered an error when using the following command after the simulation was completed:

pyfr export -d 1 couette-flow.pyfrm couette-flow-001.pyfrs couette-flow.vtu

The detailed error message provided above is available for reference. Is my usage incorrect? I donā€™t believe thereā€™s an issue with my version as Iā€™m using pyFR version 1.15.0 and numpy version 1.25.1.

Regards.

Numpy updated the way they handle types a few minor versions ago and I think thatā€™s what the issue is. Could you try using the current develop branch from the PyFR github? If you still see the same error it could be that we missed one of the places where we needed to update the way types are passed to numpy

Hello,

as of recently paraview introduced high order pyramid elements, is this on the roadmap of supported features?

Best regards

Do you have a reference for this?

Regards, Freddie.

Hello,
I see that the version requirement regarding the vtk format is higher than 9.0, but the version in the vtu file I exported after calculating with PyFR ļ¼ˆversion 1.15 ļ¼‰ shows the following:

<?xml version="1.0" ?>
<VTKFile byte_order="LittleEndian" type="UnstructuredGrid" version="2.1">
<UnstructuredGrid>
<FieldData>
<DataArray Name="TimeValue" type="Float64" NumberOfComponents="1" NumberOfTuples="1" format="ascii">
2881.0
</DataArray>
</FieldData>
<Piece NumberOfPoints="143875" NumberOfCells="1151">
<Points>

the current vtk version for exporting vtu files seems to be 2.1, how should I upgrade my exported vtk version?
Regards.

There is no need to upgrade anything. The VTK version and VTU file format versions are completely independent. Version 2.1 is the newest version of the VTU file format and what PyFR uses for high-order export. No further action should be required other than ensuring that you read the file with a version of VTK that understands v2.1.

Regards, Freddie.