CGNS support - velocity as a vector

I have started generating CGNS files from my CFD code, which is 2D and has a structured mesh. I have found that Paraview does not automatically convert VelocityX and VelocityY into a native vector format that can be plotted with glyph arrows. To get this functionality, I have to use the calculator to form the vectors from the components. Or, I can use the cgns-to-vtk converter to create a vtk file that Paraview recognizes velocity as native vectors. Shouldn’t this functionality be built-in to the CGNS importer? Is there something specific I must write to the cgns file for this to work with paraview? Having to do the extra step of file conversion or calculator should not be necessary. Thanks!

If I’m not mistaken, the CGNS reader is assembling 3D vectors into a vector array. However, it appears not to be working for 2D. Do you have a small data set you can share that shows the problem?

Yes I can. I am not sure I constructed the CGNS files exactly right, but I did follow the examples from their GitHub. In addition, they both load just fine in Tecplot 360, and all components of velocity are recognized. I have generated a 2D and 3D version of the solution, where the 3D version is just the 2D data duplicated once in the Z direction to get one layer of 3D cells. It is steady state, with one zone and one base, and is vertex-centered. In Paraview, in either file, the vectors do not seem to be recognized as scalars or vectors. They do not show up as options in the calculator.

EDIT: Scratch that about Paraview not recognizing the velocity components. I didn’t have it checked under Point Arrays. The 3D version works as it should, recognizing velocity as a vector, after checking that box. The 2D version gives errors when I check the velocity box, saying incorrect number of components. They are selectable as scalars, but not vectors, natively.

FlowOverCylinder_Re=40_3D.cgns (788 KB)
FlowOverCylinder_Re=40_2D.cgns (320 KB)

Thanks for noticing this bug. In fact, when I test your 2D file, I get a WARNING message about Incorrect number of components and not an error. If I clear the output message widget, I can use Velocity with its two components. I don’t understand your point about selection as scalar and not vectors.
The issue is that the CGNS Reader load a 2D vector in a 3D space in ParaView thus when adding the attribute VECTOR to the Velocity is fails. Then when applying rotation, Velocity will not be rotated as it is not a 3D vector!

My point is that I cannot create a Glyph with the velocity as my orientation array, without creating a new vector with the calculator using the VelocityX scalar and the VelocityY scalar. In the 3D CGNS file, the velocity is already converted to a 3-component vector, that can be plotted with Glyph, without manually creating the vector first.

@cory.quammen @utkarsh.ayachit @Kenneth_Moreland I have also replicated the issue with the 2d dataset. As you know, I am also interested in polishing the CGNS reader.

The user has an X and Y component of a 2d vector, and no Z. I’ve replicated a warning about incorrect number of components. This is an error in the CGNS reader, correct? Should I write this up?

Next, the Glyph filter thinks there is no vector in this dataset, only scalars. Shouldn’t the Glyph filter be able to use 2d vectors? Should I write this up?

This is touching a bigger issue with VTK. VTK in general assumes that vectors are 3D in many many many many many places (well, pretty much everywhere). Of course, it also forces points to be 3D. 2D points pretty much don’t work anywhere, so a 2D data set will have to add a z coordinate (usually 0) for anything to work. In light of that, I would not expect the glyph filter to work with 2D vectors.

I don’t think just patching Glyph to recognize 2D vectors is a great idea. If you really want to support that, it should be a sweeping change in VTK. (And I personally don’t feel there is enough motivation for that.)