Open vishwesh5 opened 6 years ago
Using the two functions will help resolve this problem.
Regards
def readMultiBlockGeometry(filename):
reader = vtk.vtkXMLMultiBlockDataReader()
reader.SetFileName(filename)
reader.Update()
mb = reader.GetOutput()
data_iterator = mb.NewIterator()
img_data = data_iterator.GetCurrentDataObject()
img_shape = img_data.GetExtent()
point_data = img_data.GetPointData()
array_data = point_data.GetArray(0)
np_array = vtk_to_numpy(array_data)
np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 1]
img_array = np_array.reshape(np_shape)
return img_array
def readMultiBlockVelocityAndPressure(filename):
reader = vtk.vtkXMLMultiBlockDataReader()
reader.SetFileName(filename)
reader.Update()
mb = reader.GetOutput()
data_iterator = mb.NewIterator()
img_data = data_iterator.GetCurrentDataObject()
img_shape = img_data.GetExtent()
img_shape = img_data.GetExtent()
velocity_np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 2]
pressure_np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 1]
point_data = img_data.GetPointData()
velocity_array_data = point_data.GetArray(0)
pressure_array_data = point_data.GetArray(1)
velocity_np_array = vtk_to_numpy(velocity_array_data)
pressure_np_array = vtk_to_numpy(pressure_array_data)
velocity_np_array = velocity_np_array.reshape(velocity_np_shape)
pressure_np_array = pressure_np_array.reshape(pressure_np_shape)
steady_flow_array = np.concatenate([velocity_np_array, pressure_np_array], axis=2)
return steady_flow_array
geometry_array = readMultiBlockGeometry(geometry_file)
if np.isnan(geometry_array).any():
continue
steady_flow_array = readMultiBlockVelocityAndPressure(steady_flow_file)
if np.isnan(steady_flow_array).any():
continue
使用这两个函数将有助于解决这个问题。
问候
def readMultiBlockGeometry(filename): reader = vtk.vtkXMLMultiBlockDataReader() reader.SetFileName(filename) reader.Update() mb = reader.GetOutput() data_iterator = mb.NewIterator() img_data = data_iterator.GetCurrentDataObject() img_shape = img_data.GetExtent() point_data = img_data.GetPointData() array_data = point_data.GetArray(0) np_array = vtk_to_numpy(array_data) np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 1] img_array = np_array.reshape(np_shape) return img_array def readMultiBlockVelocityAndPressure(filename): reader = vtk.vtkXMLMultiBlockDataReader() reader.SetFileName(filename) reader.Update() mb = reader.GetOutput() data_iterator = mb.NewIterator() img_data = data_iterator.GetCurrentDataObject() img_shape = img_data.GetExtent() img_shape = img_data.GetExtent() velocity_np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 2] pressure_np_shape = [img_shape[3] - img_shape[2] + 1, img_shape[1] - img_shape[0] + 1, 1] point_data = img_data.GetPointData() velocity_array_data = point_data.GetArray(0) pressure_array_data = point_data.GetArray(1) velocity_np_array = vtk_to_numpy(velocity_array_data) pressure_np_array = vtk_to_numpy(pressure_array_data) velocity_np_array = velocity_np_array.reshape(velocity_np_shape) pressure_np_array = pressure_np_array.reshape(pressure_np_shape) steady_flow_array = np.concatenate([velocity_np_array, pressure_np_array], axis=2) return steady_flow_array geometry_array = readMultiBlockGeometry(geometry_file) if np.isnan(geometry_array).any(): continue steady_flow_array = readMultiBlockVelocityAndPressure(steady_flow_file) if np.isnan(steady_flow_array).any(): continue
Hello, I want to train a network in predicting the steady state flow velocity vector field and pressure field ,so i run keras_steady_flow_predictor.py,in that I found that len(train_geometries) = 0, so there should be a problem with my data set path, and everything else succeeded. If you see it, please take a look at it. Thank you very much. I will put the error picture Link below,Thank you! https://stshoueducn-my.sharepoint.com/:f:/g/personal/m210911561_st_shou_edu_cn/EiB_9KBrt99Cjms93It_h7ABbd4ZxsubKE86TQSo0B4e3w?e=fhfGRH
你好
根据 VTK 6 的更新,
Update()
只能在派生自对象的对象上调用函数vtkAlgorithm
班级。 因此,img_data.Update()
在 train/vtm_data.py 中出现错误。 这可以解决吗?
Did you finally solve this problem? What should I do?
Hi
According to the update made in VTK 6, the
Update()
function can be called only on objects which have been derived from thevtkAlgorithm
class. Thus,img_data.Update()
in train/vtm_data.py is giving errors. Can this be fixed?