|
[Sponsors] |
May 4, 2018, 06:48 |
python VTK help
|
#1 |
New Member
Gino Parisella
Join Date: Mar 2017
Location: Perth, Western Australia
Posts: 22
Rep Power: 9 |
I would like to use foamToVTK generated files for simulation post-process in python.
At the moment, I have difficulties in getting cell centers. I read the vtk file, and get the data arrays for each cell. BUT how do I get the cell centers/points list? I am a bit lost getting cell IDs, points, connectivities really... So I do: Code:
reader = vtk.vtkUnstructuredGridReader() reader.SetFileName(filepath) reader.ReadAllFieldsOn() reader.ReadAllVectorsOn() reader.ReadAllScalarsOn() reader.Update() vtkdata = reader.GetOutput() celldata = vtkdata.GetCellData() Then I tried Code:
cells = vtkdata.GetCells() From the VTK user manual, it's not completely clear to me (haven't gone through the whole thing though...). I hope someone can give me some light on this. Cheers, Gino |
|
May 4, 2018, 22:31 |
|
#2 |
New Member
Gino Parisella
Join Date: Mar 2017
Location: Perth, Western Australia
Posts: 22
Rep Power: 9 |
Found a solution thanks to this post
The code extension should look like: Code:
cells = vtkdata.GetCells() cellpoints = vtk_to_numpy(cells.GetData()) i=0 cell_point_id = list() while i < cells.GetSize(): pts = cellpoints[i] cell_point_id.append(cellpoints[i+1:i+pts+1]) i += pts + 1 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Generating isosurface from vtk file with python script | Leios | ParaView | 1 | March 26, 2018 12:33 |
[General] Paraview.simple python module and loading legacy vtk file timeseries | awa5114 | ParaView | 2 | July 17, 2017 08:40 |
[General] How can I use python script to generate animation from 2000 frames of vtk datasets | LieyuShi | ParaView | 3 | March 10, 2016 13:37 |
get Bounds of VTK in python | Eloise | OpenFOAM Post-Processing | 1 | June 26, 2014 09:42 |
[General] VTK API: Working with values inside the python shell | Thoma | ParaView | 4 | January 10, 2013 14:35 |