Closed pycam70 closed 2 years ago
Your U
data exists as both point and cell data, which is the default using this reader. This seems like a subtle bug in the glyph filter when this occurs.
How are you using vtkOpenFOAMReader()? There is a method to disable duplicating the cell data to point data. https://vtk.org/doc/nightly/html/classvtkOpenFOAMReader.html#aa3f5e9ee9594cbd34d31e6d9690c40fb. If you turn this off, you should only have cell data and this won't happen.
Thanks a lot for your answer ! It works now :)
Actually, I am using vtkOpenFOAMReader like this (with the line reader.CreateCellToPointOff() added now) :
reader = vtk.vtkOpenFOAMReader() reader.SetFileName("case.foam") reader.UpdateInformation() time_array = reader.GetTimeValues() reader.SetTimeValue(time_array.GetRange()[1]) reader.CreateCellToPointOff() reader.Update() multi_block = pv.wrap(reader.GetOutput()) mesh = multi_block[0]
PS you can use the new Reader classes directly. See https://docs.pyvista.org/api/readers/_autosummary/pyvista.OpenFOAMReader.html#pyvista-openfoamreader
It currently doesn't expose this vtk method, but I plan on exposing additional useful methods like this one. Feel free to add any you find useful as well!
Hi !
I am a master student specialized in fluid mechanics and I would like some help for my team project which consists of creating a work-flow for CFD data-processing from Openfoam via pyvista.
Actually I am trying to plot velocity vectors from velocity data with glyphs to show the vector field but it doesn't work.
Here is the data file : https://github.com/fbob/OpenFOAM_Case_Example
I open it with vtkOpenFOAMReader()
Here is the code to plot velocity with glyphs :
glyphs = mesh.glyph(orient='U',scale='U') p4 = pv.Plotter() p4.add_mesh(glyphs) p4.view_xy() p4.add_axes() p4.show()
Pyvista shows me this error :
Both
scale
andorient
must use point data or cell data.I don't understand because my velocity data use cell data. Indeed, when I do : mesh.cell_data
It shows me :
pyvista DataSetAttributes Association : CELL Active Scalars : U Active Vectors : U Active Texture : None Active Normals : None Contains arrays : U float32 (12225, 3) VECTORS epsilon float32 (12225,) k float32 (12225,) nut float32 (12225,) p float32 (12225,)
Could someone help me ?