1212BGEO_PATH = DIR .joinpath ("ParticleData_Fluid_50.bgeo" )
1313VTK_PATH = DIR .joinpath ("ParticleData_Fluid_5.vtk" )
1414
15+ def now_s ():
16+ time .time_ns () / (10 ** 9 )
1517
1618def test_bgeo ():
1719 particles = np .array (meshio .read (BGEO_PATH ).points , dtype = np .float32 )
@@ -63,15 +65,15 @@ def test_memory_access():
6365 iso_surface_threshold = 0.6 , aabb_min = np .array ([0.0 , 0.0 , 0.0 ]), aabb_max = np .array ([2.0 , 2.0 , 2.0 ]))
6466 mesh = reconstruction .mesh
6567
66- start = time . time ()
68+ start = now_s ()
6769 triangles_copy = mesh .triangles
6870 vertices_copy = mesh .vertices
69- copy_time = time . time () - start
71+ copy_time = now_s () - start
7072 print ("Copy time:" , copy_time )
7173
72- start = time . time ()
74+ start = now_s ()
7375 vertices , triangles = mesh .take_vertices_and_triangles ()
74- take_time = time . time () - start
76+ take_time = now_s () - start
7577 print ("Take time:" , take_time )
7678
7779 print ("Copy time / Take time (Speedup):" , copy_time / take_time )
@@ -115,15 +117,15 @@ def reconstruction_pipeline(input_file, output_file, *, attributes_to_interpolat
115117
116118
117119def test_no_post_processing ():
118- start = time . time ()
120+ start = now_s ()
119121 subprocess .run ([BINARY_PATH ] + f"reconstruct { VTK_PATH } -o { DIR .joinpath ("test_bin.vtk" )} -r=0.025 -l=2.0 -c=0.5 -t=0.6 -d=on --subdomain-grid=on --mesh-cleanup=off --mesh-smoothing-weights=off --mesh-smoothing-iters=0 --normals=off --normals-smoothing-iters=0" .split (), check = True )
120- print ("Binary done in" , time . time () - start )
122+ print ("Binary done in" , now_s () - start )
121123
122- start = time . time ()
124+ start = now_s ()
123125 reconstruction_pipeline (VTK_PATH , DIR .joinpath ("test.vtk" ), particle_radius = np .float64 (0.025 ), smoothing_length = np .float64 (2.0 ),
124126 cube_size = np .float64 (0.5 ), iso_surface_threshold = np .float64 (0.6 ), mesh_smoothing_weights = False ,
125127 mesh_smoothing_iters = 0 , normals_smoothing_iters = 0 , mesh_cleanup = False , compute_normals = False , subdomain_grid = True )
126- print ("Python done in" , time . time () - start )
128+ print ("Python done in" , now_s () - start )
127129
128130 binary_mesh = meshio .read (DIR .joinpath ("test_bin.vtk" ))
129131 python_mesh = meshio .read (DIR .joinpath ("test.vtk" ))
@@ -142,17 +144,17 @@ def test_no_post_processing():
142144 assert (np .allclose (binary_verts , python_verts ))
143145
144146def test_with_post_processing ():
145- start = time . time ()
147+ start = now_s ()
146148 subprocess .run ([BINARY_PATH ] + f"reconstruct { VTK_PATH } -o { DIR .joinpath ("test_bin.vtk" )} -r=0.025 -l=2.0 -c=0.5 -t=0.6 -d=on --subdomain-grid=on --interpolate_attribute velocity --decimate-barnacles=on --mesh-cleanup=on --mesh-smoothing-weights=on --mesh-smoothing-iters=25 --normals=on --normals-smoothing-iters=10 --output-smoothing-weights=on --generate-quads=off" .split (), check = True )
147- print ("Binary done in" , time . time () - start )
149+ print ("Binary done in" , now_s () - start )
148150
149- start = time . time ()
151+ start = now_s ()
150152 reconstruction_pipeline (VTK_PATH , DIR .joinpath ("test.vtk" ), attributes_to_interpolate = ["velocity" ], particle_radius = np .float64 (0.025 ), smoothing_length = np .float64 (2.0 ),
151153 cube_size = np .float64 (0.5 ), iso_surface_threshold = np .float64 (0.6 ), mesh_smoothing_weights = True ,
152154 mesh_smoothing_weights_normalization = np .float64 (13.0 ), mesh_smoothing_iters = 25 , normals_smoothing_iters = 10 ,
153155 generate_quads = False , mesh_cleanup = True , compute_normals = True , subdomain_grid = True , decimate_barnacles = True ,
154156 output_mesh_smoothing_weights = True , output_raw_normals = True )
155- print ("Python done in" , time . time () - start )
157+ print ("Python done in" , now_s () - start )
156158
157159 binary_mesh = meshio .read (DIR .joinpath ("test_bin.vtk" ))
158160 python_mesh = meshio .read (DIR .joinpath ("test.vtk" ))
@@ -176,6 +178,7 @@ def test_with_post_processing():
176178 assert (np .allclose (binary_vels , python_vels ))
177179
178180 # Trimesh similarity test
181+ # TODO: Replace load_mesh call: the function tries to create temporary files which may fail on some CI runners
179182 binary_mesh = trimesh .load_mesh (DIR .joinpath ("test_bin.vtk" ), "vtk" )
180183 python_mesh = trimesh .load_mesh (DIR .joinpath ("test.vtk" ), "vtk" )
181184
0 commit comments