Merge branch 'fix-IPF-vtk-2' into 'development'

infere data type automatically

See merge request damask/DAMASK!138
This commit is contained in:
Francisco Jose Gallardo Basile 2020-02-28 10:00:26 +01:00
commit 13c3ce0019
1 changed files with 39 additions and 44 deletions

View File

@ -1096,8 +1096,7 @@ class DADF5():
continue continue
array = self.read_dataset(x,0) array = self.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape), vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True))
deep=True,array_type= vtk.VTK_DOUBLE))
vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) #ToDo: hard coded 1! vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) #ToDo: hard coded 1!
vtk_geom.GetCellData().AddArray(vtk_data[-1]) vtk_geom.GetCellData().AddArray(vtk_data[-1])
@ -1107,8 +1106,7 @@ class DADF5():
continue continue
array = self.read_dataset(x,0) array = self.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape), vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True))
deep=True,array_type= vtk.VTK_DOUBLE))
ph_name = re.compile(r'(?<=(constituent\/))(.*?)(?=(generic))') # identify phase name ph_name = re.compile(r'(?<=(constituent\/))(.*?)(?=(generic))') # identify phase name
dset_name = '1_' + re.sub(ph_name,r'',x[0].split('/',1)[1]) # removing phase name dset_name = '1_' + re.sub(ph_name,r'',x[0].split('/',1)[1]) # removing phase name
vtk_data[-1].SetName(dset_name) vtk_data[-1].SetName(dset_name)
@ -1127,8 +1125,7 @@ class DADF5():
continue continue
array = self.read_dataset(x,0) array = self.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape), vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True))
deep=True,array_type= vtk.VTK_DOUBLE))
vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) #ToDo: why 1_? vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) #ToDo: why 1_?
vtk_geom.GetCellData().AddArray(vtk_data[-1]) vtk_geom.GetCellData().AddArray(vtk_data[-1])
else: else:
@ -1137,8 +1134,7 @@ class DADF5():
continue continue
array = self.read_dataset(x,0) array = self.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape), vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True))
deep=True,array_type= vtk.VTK_DOUBLE))
vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) vtk_data[-1].SetName('1_'+x[0].split('/',1)[1])
vtk_geom.GetCellData().AddArray(vtk_data[-1]) vtk_geom.GetCellData().AddArray(vtk_data[-1])
self.set_visible('constituents',constituents_backup) self.set_visible('constituents',constituents_backup)
@ -1147,8 +1143,7 @@ class DADF5():
writer = vtk.vtkXMLRectilinearGridWriter() if self.structured else \ writer = vtk.vtkXMLRectilinearGridWriter() if self.structured else \
vtk.vtkXMLUnstructuredGridWriter() vtk.vtkXMLUnstructuredGridWriter()
x = self.get_dataset_location('u_n') x = self.get_dataset_location('u_n')
vtk_data.append(numpy_support.numpy_to_vtk(num_array=self.read_dataset(x,0), vtk_data.append(numpy_support.numpy_to_vtk(num_array=self.read_dataset(x,0),deep=True))
deep=True,array_type=vtk.VTK_DOUBLE))
vtk_data[-1].SetName('u') vtk_data[-1].SetName('u')
vtk_geom.GetPointData().AddArray(vtk_data[-1]) vtk_geom.GetPointData().AddArray(vtk_data[-1])
elif mode.lower()=='point': elif mode.lower()=='point':