Closed zangthanh closed 2 years ago
There is a sample method, which may be what you want...under resampling.
try making some PolyData from the CSV file and then using the interpolate or sample filters as described in the example: https://docs.pyvista.org/examples/01-filter/interpolate.html#sphx-glr-examples-01-filter-interpolate-py or https://docs.pyvista.org/examples/01-filter/resample.html
to make the polydata, pass the XYZ arrays to the PolyData constructor and assign the data value much like you did gor grid
Dear @banesullivan , @RichardScottOZ
Thank you very much for your comments. I got your main idea to work with resample example. However, I could not open my vtk data file to check data structure since it is written in binary format and I just started learning pyvista and python code skill is still very weak.
Here I attached my vtk file and xyz coordinates data. I really appreciate your offering to help me on coding part.
Sorry, had not noticed, move this to discussions as mentioned in the list here.
pyvista.read(file.vtk) should work?
Dear supporters, I am using openfoam for CFD simulation. From simulation results, I converted data to vtk data. Now, I want to extract velocity magnitude (U) in from at a specific set of points points written in 3 columns (x,y,z) in a .csv file. The output csv file data should be x,y,z and U. Here is my starting code. Could you please help me to finished it. Thank you very much.
import pyvista import numpy as np import pandas as pd
access to vtk data
grid = pyvista.UnstructuredGrid('./VTK/file.vtk')
load cvs data
csvfile= pd.read_csv("coordiantes.csv"), header=None)
get velocity field in numpy array
U_cell = grid.cell_arrays['U']