@@ -166,12 +166,6 @@ def save_usd_vorticity(
166
166
usd_mesh .GetDisplayColorAttr ().Set (colors .numpy ().tolist (), time = timestep // post_process_interval )
167
167
UsdGeom .Primvar (usd_mesh .GetDisplayColorAttr ()).SetInterpolation ("vertex" )
168
168
169
- # usd_stage.SetStartTimeCode(0)
170
- # usd_stage.SetEndTimeCode(timestep)
171
- # usd_stage.SetTimeCodesPerSecond(24)
172
-
173
- # usd_stage.Save()
174
-
175
169
print (f"Vorticity visualization at timestep { timestep } :" )
176
170
print (f" Number of vertices: { len (vertices )} " )
177
171
print (f" Number of triangles: { tri_count } " )
@@ -252,9 +246,9 @@ def save_usd_q_criterion(timestep, bc_mask, f_current, grid_shape, usd_mesh, q_c
252
246
print (f" Vorticity range: [{ vorticity_min :.6f} , { vorticity_max :.6f} ]" )
253
247
254
248
255
- # -------------------------- Function to Save Drone Body and Blades to USD --------------------------
256
- def save_usd_drone_and_blades (
257
- timestep , post_process_interval , vertices_wp , num_body_vertices , body_faces_np , blades_faces_np , usd_drone_body , usd_drone_blades , usd_stage
249
+ # -------------------------- Function to Save UAV Body and Blades to USD --------------------------
250
+ def save_usd_uav_and_blades (
251
+ timestep , post_process_interval , vertices_wp , num_body_vertices , body_faces_np , blades_faces_np , usd_uav_body , usd_uav_blades , usd_stage
258
252
):
259
253
# Get vertices and adjust for boundary condition offset
260
254
body_vertices = vertices_wp .numpy ()[:num_body_vertices ]
@@ -265,20 +259,20 @@ def save_usd_drone_and_blades(
265
259
blades_vertices = blades_vertices - 20
266
260
267
261
# Process body mesh
268
- drone_body_tri_count = len (body_faces_np )
269
- usd_drone_body .GetPointsAttr ().Set (body_vertices .tolist (), time = timestep // post_process_interval )
270
- usd_drone_body .GetFaceVertexCountsAttr ().Set (Vt .IntArray ([3 ] * drone_body_tri_count ), time = timestep // post_process_interval )
271
- usd_drone_body .GetFaceVertexIndicesAttr ().Set (Vt .IntArray (body_faces_np .flatten ().tolist ()), time = timestep // post_process_interval )
262
+ uav_body_tri_count = len (body_faces_np )
263
+ usd_uav_body .GetPointsAttr ().Set (body_vertices .tolist (), time = timestep // post_process_interval )
264
+ usd_uav_body .GetFaceVertexCountsAttr ().Set (Vt .IntArray ([3 ] * uav_body_tri_count ), time = timestep // post_process_interval )
265
+ usd_uav_body .GetFaceVertexIndicesAttr ().Set (Vt .IntArray (body_faces_np .flatten ().tolist ()), time = timestep // post_process_interval )
272
266
273
267
# Process blades mesh
274
268
# Rebase blade face indices to the local blade vertex array
275
269
blades_faces_np_corrected = blades_faces_np - num_body_vertices
276
- drone_blades_tri_count = len (blades_faces_np_corrected )
277
- usd_drone_blades .GetPointsAttr ().Set (blades_vertices .tolist (), time = timestep // post_process_interval )
278
- usd_drone_blades .GetFaceVertexCountsAttr ().Set (Vt .IntArray ([3 ] * drone_blades_tri_count ), time = timestep // post_process_interval )
279
- usd_drone_blades .GetFaceVertexIndicesAttr ().Set (Vt .IntArray (blades_faces_np_corrected .flatten ().tolist ()), time = timestep // post_process_interval )
270
+ uav_blades_tri_count = len (blades_faces_np_corrected )
271
+ usd_uav_blades .GetPointsAttr ().Set (blades_vertices .tolist (), time = timestep // post_process_interval )
272
+ usd_uav_blades .GetFaceVertexCountsAttr ().Set (Vt .IntArray ([3 ] * uav_blades_tri_count ), time = timestep // post_process_interval )
273
+ usd_uav_blades .GetFaceVertexIndicesAttr ().Set (Vt .IntArray (blades_faces_np_corrected .flatten ().tolist ()), time = timestep // post_process_interval )
280
274
281
- print (f"Drone body and blades USD updated at timestep { timestep } " )
275
+ print (f"UAV body and blades USD updated at timestep { timestep } " )
282
276
283
277
284
278
# -------------------------- Mesh Loading and IBM Setup --------------------------
@@ -404,7 +398,6 @@ def setup_stepper(grid, boundary_conditions, lbm_omega):
404
398
)
405
399
406
400
407
- # -------------------------- Post-Processing (Extended with USD Output using Q Criterion) --------------------------
408
401
def post_process (
409
402
i ,
410
403
post_process_interval ,
@@ -480,7 +473,7 @@ def post_process(
480
473
481
474
482
475
# -------------------------- Simulation Parameters --------------------------
483
- grid_shape = (100 , 200 , 200 )
476
+ grid_shape = (512 , 512 , 512 )
484
477
u_max = 0.01
485
478
num_steps = 100000
486
479
post_process_interval = 100
@@ -523,8 +516,8 @@ def post_process(
523
516
usd_file = os .path .join (usd_output_directory , "output.usd" )
524
517
usd_stage = Usd .Stage .CreateNew (usd_file )
525
518
usd_mesh = UsdGeom .Mesh .Define (usd_stage , "/World/FluidField" )
526
- usd_drone_body = UsdGeom .Mesh .Define (usd_stage , "/World/DroneBody " )
527
- usd_drone_blades = UsdGeom .Mesh .Define (usd_stage , "/World/DroneBlades " )
519
+ usd_uav_body = UsdGeom .Mesh .Define (usd_stage , "/World/UAVBody " )
520
+ usd_uav_blades = UsdGeom .Mesh .Define (usd_stage , "/World/UAVBlades " )
528
521
529
522
mesh_data = load_and_prepare_meshes (grid_shape )
530
523
vertices_wp = mesh_data ["vertices_wp" ]
@@ -611,26 +604,27 @@ def rotate_blades(
611
604
612
605
613
606
start_time = time .time ()
614
- progress_bar = tqdm (range (num_steps ), desc = "Simulation Progress" , unit = "steps" )
615
607
616
- for i in progress_bar :
617
- f_0 , f_1 = stepper (
608
+ for i in range ( num_steps ) :
609
+ f_0 , f_1 , lag_forces = stepper (
618
610
f_0 ,
619
611
f_1 ,
620
612
vertices_wp ,
621
613
vertex_areas_wp ,
622
614
velocities_wp ,
623
- rotate_blades ,
624
615
bc_mask ,
625
616
missing_mask ,
626
617
omega ,
627
618
i ,
628
619
)
629
620
f_0 , f_1 = f_1 , f_0
630
621
631
- if (i + 1 ) % print_interval == 0 :
632
- elapsed_time = time .time () - start_time
633
- progress_bar .set_postfix ({"Time elapsed" : f"{ elapsed_time :.2f} s" })
622
+ # Update solid velocities and positions
623
+ wp .launch (
624
+ kernel = rotate_blades ,
625
+ dim = vertices_wp .shape [0 ],
626
+ inputs = [i , lag_forces , vertices_wp , velocities_wp ],
627
+ )
634
628
635
629
if i % post_process_interval == 0 or i == num_steps - 1 :
636
630
post_process (
@@ -649,15 +643,15 @@ def rotate_blades(
649
643
vorticity_operator ,
650
644
usd_stage ,
651
645
)
652
- save_usd_drone_and_blades (
646
+ save_usd_uav_and_blades (
653
647
i ,
654
648
post_process_interval ,
655
649
vertices_wp ,
656
650
num_body_vertices ,
657
651
body_faces_np ,
658
652
blades_faces_np ,
659
- usd_drone_body ,
660
- usd_drone_blades ,
653
+ usd_uav_body ,
654
+ usd_uav_blades ,
661
655
usd_stage ,
662
656
)
663
657
0 commit comments