@@ -40,13 +40,17 @@ def writeToVTR(fileName: str, data, coords, varNames):
4040 vtr = vtk .vtkRectilinearGrid ()
4141 vtr .SetDimensions (nX , nY , nZ )
4242
43- vect = lambda x : numpy_support .numpy_to_vtk (num_array = x , deep = True , array_type = vtk .VTK_FLOAT )
43+ def vect (x ):
44+ return numpy_support .numpy_to_vtk (num_array = x , deep = True , array_type = vtk .VTK_FLOAT )
45+
4446 x , y , z = coords
4547 vtr .SetXCoordinates (vect (x ))
4648 vtr .SetYCoordinates (vect (y ))
4749 vtr .SetZCoordinates (vect (z ))
4850
49- field = lambda u : numpy_support .numpy_to_vtk (num_array = u .ravel (order = 'F' ), deep = True , array_type = vtk .VTK_FLOAT )
51+ def field (u ):
52+ return numpy_support .numpy_to_vtk (num_array = u .ravel (order = 'F' ), deep = True , array_type = vtk .VTK_FLOAT )
53+
5054 pointData = vtr .GetPointData ()
5155 for name , u in zip (varNames , data ):
5256 uVTK = field (u )
@@ -93,7 +97,9 @@ def readFromVTR(fileName: str):
9397 dims = vtr .GetDimensions ()
9498 assert len (dims ) == 3 , "can only read 3D data"
9599
96- vect = lambda x : numpy_support .vtk_to_numpy (x )
100+ def vect (x ):
101+ return numpy_support .vtk_to_numpy (x )
102+
97103 coords = [vect (vtr .GetXCoordinates ()), vect (vtr .GetYCoordinates ()), vect (vtr .GetZCoordinates ())]
98104 pointData = vtr .GetPointData ()
99105 varNames = [pointData .GetArrayName (i ) for i in range (pointData .GetNumberOfArrays ())]
0 commit comments