warp-lang 1.4.1__py3-none-win_amd64.whl → 1.5.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of warp-lang might be problematic. Click here for more details.

Files changed (164) hide show
  1. warp/__init__.py +4 -0
  2. warp/autograd.py +43 -8
  3. warp/bin/warp-clang.dll +0 -0
  4. warp/bin/warp.dll +0 -0
  5. warp/build.py +21 -2
  6. warp/build_dll.py +23 -6
  7. warp/builtins.py +1920 -111
  8. warp/codegen.py +186 -62
  9. warp/config.py +2 -2
  10. warp/context.py +322 -73
  11. warp/examples/assets/pixel.jpg +0 -0
  12. warp/examples/benchmarks/benchmark_cloth_paddle.py +86 -0
  13. warp/examples/benchmarks/benchmark_gemm.py +121 -0
  14. warp/examples/benchmarks/benchmark_interop_paddle.py +158 -0
  15. warp/examples/benchmarks/benchmark_tile.py +179 -0
  16. warp/examples/core/example_dem.py +2 -1
  17. warp/examples/core/example_mesh_intersect.py +3 -3
  18. warp/examples/fem/example_adaptive_grid.py +37 -10
  19. warp/examples/fem/example_apic_fluid.py +3 -2
  20. warp/examples/fem/example_convection_diffusion_dg.py +4 -5
  21. warp/examples/fem/example_deformed_geometry.py +1 -1
  22. warp/examples/fem/example_diffusion_3d.py +47 -4
  23. warp/examples/fem/example_distortion_energy.py +220 -0
  24. warp/examples/fem/example_magnetostatics.py +127 -85
  25. warp/examples/fem/example_nonconforming_contact.py +5 -5
  26. warp/examples/fem/example_stokes.py +3 -1
  27. warp/examples/fem/example_streamlines.py +12 -19
  28. warp/examples/fem/utils.py +38 -15
  29. warp/examples/optim/example_walker.py +2 -2
  30. warp/examples/sim/example_cloth.py +2 -25
  31. warp/examples/sim/example_jacobian_ik.py +6 -2
  32. warp/examples/sim/example_quadruped.py +2 -1
  33. warp/examples/tile/example_tile_convolution.py +58 -0
  34. warp/examples/tile/example_tile_fft.py +47 -0
  35. warp/examples/tile/example_tile_filtering.py +105 -0
  36. warp/examples/tile/example_tile_matmul.py +79 -0
  37. warp/examples/tile/example_tile_mlp.py +375 -0
  38. warp/fem/__init__.py +8 -0
  39. warp/fem/cache.py +16 -12
  40. warp/fem/dirichlet.py +1 -1
  41. warp/fem/domain.py +44 -1
  42. warp/fem/field/__init__.py +1 -2
  43. warp/fem/field/field.py +31 -19
  44. warp/fem/field/nodal_field.py +101 -49
  45. warp/fem/field/virtual.py +794 -0
  46. warp/fem/geometry/__init__.py +2 -2
  47. warp/fem/geometry/deformed_geometry.py +3 -105
  48. warp/fem/geometry/element.py +13 -0
  49. warp/fem/geometry/geometry.py +165 -5
  50. warp/fem/geometry/grid_2d.py +3 -6
  51. warp/fem/geometry/grid_3d.py +31 -28
  52. warp/fem/geometry/hexmesh.py +3 -46
  53. warp/fem/geometry/nanogrid.py +3 -2
  54. warp/fem/geometry/{quadmesh_2d.py → quadmesh.py} +280 -159
  55. warp/fem/geometry/tetmesh.py +2 -43
  56. warp/fem/geometry/{trimesh_2d.py → trimesh.py} +354 -186
  57. warp/fem/integrate.py +683 -261
  58. warp/fem/linalg.py +404 -0
  59. warp/fem/operator.py +101 -18
  60. warp/fem/polynomial.py +5 -5
  61. warp/fem/quadrature/quadrature.py +45 -21
  62. warp/fem/space/__init__.py +45 -11
  63. warp/fem/space/basis_function_space.py +451 -0
  64. warp/fem/space/basis_space.py +58 -11
  65. warp/fem/space/function_space.py +146 -5
  66. warp/fem/space/grid_2d_function_space.py +80 -66
  67. warp/fem/space/grid_3d_function_space.py +113 -68
  68. warp/fem/space/hexmesh_function_space.py +96 -108
  69. warp/fem/space/nanogrid_function_space.py +62 -110
  70. warp/fem/space/quadmesh_function_space.py +208 -0
  71. warp/fem/space/shape/__init__.py +45 -7
  72. warp/fem/space/shape/cube_shape_function.py +328 -54
  73. warp/fem/space/shape/shape_function.py +10 -1
  74. warp/fem/space/shape/square_shape_function.py +328 -60
  75. warp/fem/space/shape/tet_shape_function.py +269 -19
  76. warp/fem/space/shape/triangle_shape_function.py +238 -19
  77. warp/fem/space/tetmesh_function_space.py +69 -37
  78. warp/fem/space/topology.py +38 -0
  79. warp/fem/space/trimesh_function_space.py +179 -0
  80. warp/fem/utils.py +6 -331
  81. warp/jax_experimental.py +3 -1
  82. warp/native/array.h +55 -40
  83. warp/native/builtin.h +124 -43
  84. warp/native/bvh.h +4 -0
  85. warp/native/coloring.cpp +600 -0
  86. warp/native/cuda_util.cpp +14 -0
  87. warp/native/cuda_util.h +2 -1
  88. warp/native/fabric.h +8 -0
  89. warp/native/hashgrid.h +4 -0
  90. warp/native/marching.cu +8 -0
  91. warp/native/mat.h +14 -3
  92. warp/native/mathdx.cpp +59 -0
  93. warp/native/mesh.h +4 -0
  94. warp/native/range.h +13 -1
  95. warp/native/reduce.cpp +9 -1
  96. warp/native/reduce.cu +7 -0
  97. warp/native/runlength_encode.cpp +9 -1
  98. warp/native/runlength_encode.cu +7 -1
  99. warp/native/scan.cpp +8 -0
  100. warp/native/scan.cu +8 -0
  101. warp/native/scan.h +8 -1
  102. warp/native/sparse.cpp +8 -0
  103. warp/native/sparse.cu +8 -0
  104. warp/native/temp_buffer.h +7 -0
  105. warp/native/tile.h +1857 -0
  106. warp/native/tile_gemm.h +341 -0
  107. warp/native/tile_reduce.h +210 -0
  108. warp/native/volume_builder.cu +8 -0
  109. warp/native/volume_builder.h +8 -0
  110. warp/native/warp.cpp +10 -2
  111. warp/native/warp.cu +369 -15
  112. warp/native/warp.h +12 -2
  113. warp/optim/adam.py +39 -4
  114. warp/paddle.py +29 -12
  115. warp/render/render_opengl.py +137 -65
  116. warp/sim/graph_coloring.py +292 -0
  117. warp/sim/integrator_euler.py +4 -2
  118. warp/sim/integrator_featherstone.py +115 -44
  119. warp/sim/integrator_vbd.py +6 -0
  120. warp/sim/model.py +90 -17
  121. warp/stubs.py +651 -85
  122. warp/tape.py +12 -7
  123. warp/tests/assets/pixel.npy +0 -0
  124. warp/tests/aux_test_instancing_gc.py +18 -0
  125. warp/tests/test_array.py +207 -48
  126. warp/tests/test_closest_point_edge_edge.py +8 -8
  127. warp/tests/test_codegen.py +120 -1
  128. warp/tests/test_codegen_instancing.py +30 -0
  129. warp/tests/test_collision.py +110 -0
  130. warp/tests/test_coloring.py +241 -0
  131. warp/tests/test_context.py +34 -0
  132. warp/tests/test_examples.py +18 -4
  133. warp/tests/test_fabricarray.py +33 -0
  134. warp/tests/test_fem.py +453 -113
  135. warp/tests/test_func.py +48 -1
  136. warp/tests/test_generics.py +52 -0
  137. warp/tests/test_iter.py +68 -0
  138. warp/tests/test_mat_scalar_ops.py +1 -1
  139. warp/tests/test_mesh_query_point.py +5 -4
  140. warp/tests/test_module_hashing.py +23 -0
  141. warp/tests/test_paddle.py +27 -87
  142. warp/tests/test_print.py +191 -1
  143. warp/tests/test_spatial.py +1 -1
  144. warp/tests/test_tile.py +700 -0
  145. warp/tests/test_tile_mathdx.py +144 -0
  146. warp/tests/test_tile_mlp.py +383 -0
  147. warp/tests/test_tile_reduce.py +374 -0
  148. warp/tests/test_tile_shared_memory.py +190 -0
  149. warp/tests/test_vbd.py +12 -20
  150. warp/tests/test_volume.py +43 -0
  151. warp/tests/unittest_suites.py +23 -2
  152. warp/tests/unittest_utils.py +4 -0
  153. warp/types.py +339 -73
  154. warp/utils.py +22 -1
  155. {warp_lang-1.4.1.dist-info → warp_lang-1.5.0.dist-info}/METADATA +33 -7
  156. {warp_lang-1.4.1.dist-info → warp_lang-1.5.0.dist-info}/RECORD +159 -132
  157. {warp_lang-1.4.1.dist-info → warp_lang-1.5.0.dist-info}/WHEEL +1 -1
  158. warp/fem/field/test.py +0 -180
  159. warp/fem/field/trial.py +0 -183
  160. warp/fem/space/collocated_function_space.py +0 -102
  161. warp/fem/space/quadmesh_2d_function_space.py +0 -261
  162. warp/fem/space/trimesh_2d_function_space.py +0 -153
  163. {warp_lang-1.4.1.dist-info → warp_lang-1.5.0.dist-info}/LICENSE.md +0 -0
  164. {warp_lang-1.4.1.dist-info → warp_lang-1.5.0.dist-info}/top_level.txt +0 -0
@@ -7,8 +7,11 @@
7
7
 
8
8
  import unittest
9
9
 
10
+ import warp as wp
10
11
  import warp.examples
12
+ import warp.sim
11
13
  from warp.sim.collide import *
14
+ from warp.sim.integrator_euler import eval_triangles_contact
12
15
  from warp.tests.unittest_utils import *
13
16
 
14
17
 
@@ -474,12 +477,119 @@ def test_edge_edge_collision(test, device):
474
477
  devices = get_test_devices()
475
478
 
476
479
 
480
+ def test_particle_collision(test, device):
481
+ with wp.ScopedDevice(device):
482
+ contact_radius = 1.23
483
+ builder1 = wp.sim.ModelBuilder()
484
+ builder1.add_cloth_grid(
485
+ pos=wp.vec3(0.0, 0.0, 0.0),
486
+ rot=wp.quat_identity(),
487
+ vel=wp.vec3(0.0, 0.0, 0.0),
488
+ dim_x=100,
489
+ dim_y=100,
490
+ cell_x=0.1,
491
+ cell_y=0.1,
492
+ mass=0.1,
493
+ particle_radius=contact_radius,
494
+ )
495
+
496
+ cloth_grid = builder1.finalize()
497
+ cloth_grid_particle_radius = cloth_grid.particle_radius.numpy()
498
+ assert_np_equal(cloth_grid_particle_radius, np.full(cloth_grid_particle_radius.shape, contact_radius), tol=1e-5)
499
+
500
+ vertices = [
501
+ [2.0, 0.0, 0.0],
502
+ [2.0, 2.0, 0.0],
503
+ [0.0, 0.0, 0.0],
504
+ [1.0, 0.0, 1.0],
505
+ [1.0, 1.0, 1.0],
506
+ [0.0, 0.0, 1.0],
507
+ ]
508
+ vertices = [wp.vec3(v) for v in vertices]
509
+ faces = [0, 1, 2, 3, 4, 5]
510
+
511
+ builder2 = wp.sim.ModelBuilder()
512
+ builder2.add_cloth_mesh(
513
+ pos=wp.vec3(0.0, 0.0, 0.0),
514
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
515
+ scale=1.0,
516
+ vertices=vertices,
517
+ indices=faces,
518
+ tri_ke=1e4,
519
+ tri_ka=1e4,
520
+ tri_kd=1e-5,
521
+ edge_ke=10,
522
+ edge_kd=0.0,
523
+ vel=wp.vec3(0.0, 0.0, 0.0),
524
+ density=0.1,
525
+ particle_radius=contact_radius,
526
+ )
527
+ cloth_mesh = builder2.finalize()
528
+ cloth_mesh_particle_radius = cloth_mesh.particle_radius.numpy()
529
+ assert_np_equal(cloth_mesh_particle_radius, np.full(cloth_mesh_particle_radius.shape, contact_radius), tol=1e-5)
530
+
531
+ state = cloth_mesh.state()
532
+ particle_f = wp.zeros_like(state.particle_q)
533
+ wp.launch(
534
+ kernel=eval_triangles_contact,
535
+ dim=cloth_mesh.tri_count * cloth_mesh.particle_count,
536
+ inputs=[
537
+ cloth_mesh.particle_count,
538
+ state.particle_q,
539
+ state.particle_qd,
540
+ cloth_mesh.tri_indices,
541
+ cloth_mesh.tri_materials,
542
+ cloth_mesh.particle_radius,
543
+ ],
544
+ outputs=[particle_f],
545
+ )
546
+ test.assertTrue((np.linalg.norm(particle_f.numpy(), axis=1) != 0).all())
547
+
548
+ builder3 = wp.sim.ModelBuilder()
549
+ builder3.add_cloth_mesh(
550
+ pos=wp.vec3(0.0, 0.0, 0.0),
551
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
552
+ scale=1.0,
553
+ vertices=vertices,
554
+ indices=faces,
555
+ tri_ke=1e4,
556
+ tri_ka=1e4,
557
+ tri_kd=1e-5,
558
+ edge_ke=10,
559
+ edge_kd=0.0,
560
+ vel=wp.vec3(0.0, 0.0, 0.0),
561
+ density=0.1,
562
+ particle_radius=0.5,
563
+ )
564
+ cloth_mesh_2 = builder3.finalize()
565
+ cloth_mesh_2_particle_radius = cloth_mesh_2.particle_radius.numpy()
566
+ assert_np_equal(cloth_mesh_2_particle_radius, np.full(cloth_mesh_2_particle_radius.shape, 0.5), tol=1e-5)
567
+
568
+ state_2 = cloth_mesh_2.state()
569
+ particle_f_2 = wp.zeros_like(cloth_mesh_2.particle_q)
570
+ wp.launch(
571
+ kernel=eval_triangles_contact,
572
+ dim=cloth_mesh_2.tri_count * cloth_mesh_2.particle_count,
573
+ inputs=[
574
+ cloth_mesh_2.particle_count,
575
+ state_2.particle_q,
576
+ state_2.particle_qd,
577
+ cloth_mesh_2.tri_indices,
578
+ cloth_mesh_2.tri_materials,
579
+ cloth_mesh_2.particle_radius,
580
+ ],
581
+ outputs=[particle_f_2],
582
+ )
583
+ test.assertTrue((np.linalg.norm(particle_f_2.numpy(), axis=1) == 0).all())
584
+
585
+
477
586
  class TestCollision(unittest.TestCase):
478
587
  pass
479
588
 
480
589
 
481
590
  add_function_test(TestCollision, "test_vertex_triangle_collision", test_vertex_triangle_collision, devices=devices)
482
591
  add_function_test(TestCollision, "test_edge_edge_collision", test_vertex_triangle_collision, devices=devices)
592
+ add_function_test(TestCollision, "test_particle_collision", test_particle_collision, devices=devices)
483
593
 
484
594
  if __name__ == "__main__":
485
595
  wp.clear_kernel_cache()
@@ -0,0 +1,241 @@
1
+ # Copyright (c) 2024 NVIDIA CORPORATION. All rights reserved.
2
+ # NVIDIA CORPORATION and its licensors retain all intellectual property
3
+ # and proprietary rights in and to this software, related documentation
4
+ # and any modifications thereto. Any use, reproduction, disclosure or
5
+ # distribution of this software and related documentation without an express
6
+ # license agreement from NVIDIA CORPORATION is strictly prohibited.
7
+
8
+
9
+ import numpy as np
10
+
11
+ import warp as wp
12
+ import warp.examples
13
+ import warp.sim
14
+ from warp.sim.graph_coloring import ColoringAlgorithm, construct_trimesh_graph_edges, validate_graph_coloring
15
+ from warp.tests.unittest_utils import *
16
+
17
+
18
+ def color_lattice_grid(num_x, num_y):
19
+ colors = []
20
+ for _ in range(4):
21
+ colors.append([])
22
+
23
+ for xi in range(num_x + 1):
24
+ for yi in range(num_y + 1):
25
+ node_dx = yi * (num_x + 1) + xi
26
+
27
+ a = 1 if xi % 2 else 0
28
+ b = 1 if yi % 2 else 0
29
+
30
+ c = b * 2 + a
31
+
32
+ colors[c].append(node_dx)
33
+
34
+ color_groups = [np.array(group) for group in colors]
35
+
36
+ return color_groups
37
+
38
+
39
+ @unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
40
+ def test_coloring_trimesh(test, device):
41
+ from pxr import Usd, UsdGeom
42
+
43
+ with wp.ScopedDevice(device):
44
+ usd_stage = Usd.Stage.Open(os.path.join(wp.examples.get_asset_directory(), "bunny.usd"))
45
+ usd_geom = UsdGeom.Mesh(usd_stage.GetPrimAtPath("/root/bunny"))
46
+
47
+ vertices = np.array(usd_geom.GetPointsAttr().Get())
48
+ faces = np.array(usd_geom.GetFaceVertexIndicesAttr().Get())
49
+
50
+ builder = wp.sim.ModelBuilder()
51
+
52
+ builder.add_cloth_mesh(
53
+ pos=wp.vec3(0.0, 0.0, 0.0),
54
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
55
+ scale=1.0,
56
+ vertices=[wp.vec3(p) for p in vertices],
57
+ indices=faces.flatten(),
58
+ vel=wp.vec3(0.0, 0.0, 0.0),
59
+ density=0.02,
60
+ )
61
+
62
+ model = builder.finalize()
63
+
64
+ particle_colors = wp.empty(shape=(model.particle_count), dtype=int, device="cpu")
65
+
66
+ edge_indices_cpu = wp.array(model.edge_indices.numpy()[:, 2:], dtype=int, device="cpu")
67
+
68
+ # coloring without bending
69
+ num_colors_greedy = wp.context.runtime.core.graph_coloring(
70
+ model.particle_count,
71
+ edge_indices_cpu.__ctype__(),
72
+ ColoringAlgorithm.GREEDY.value,
73
+ particle_colors.__ctype__(),
74
+ )
75
+ wp.launch(
76
+ kernel=validate_graph_coloring,
77
+ inputs=[edge_indices_cpu, particle_colors],
78
+ dim=edge_indices_cpu.shape[0],
79
+ device="cpu",
80
+ )
81
+
82
+ num_colors_mcs = wp.context.runtime.core.graph_coloring(
83
+ model.particle_count,
84
+ edge_indices_cpu.__ctype__(),
85
+ ColoringAlgorithm.MCS.value,
86
+ particle_colors.__ctype__(),
87
+ )
88
+ wp.launch(
89
+ kernel=validate_graph_coloring,
90
+ inputs=[edge_indices_cpu, particle_colors],
91
+ dim=edge_indices_cpu.shape[0],
92
+ device="cpu",
93
+ )
94
+
95
+ # coloring with bending
96
+ edge_indices_cpu_with_bending = construct_trimesh_graph_edges(model.edge_indices, True)
97
+ num_colors_greedy = wp.context.runtime.core.graph_coloring(
98
+ model.particle_count,
99
+ edge_indices_cpu_with_bending.__ctype__(),
100
+ ColoringAlgorithm.GREEDY.value,
101
+ particle_colors.__ctype__(),
102
+ )
103
+ wp.context.runtime.core.balance_coloring(
104
+ model.particle_count,
105
+ edge_indices_cpu_with_bending.__ctype__(),
106
+ num_colors_greedy,
107
+ 1.1,
108
+ particle_colors.__ctype__(),
109
+ )
110
+ wp.launch(
111
+ kernel=validate_graph_coloring,
112
+ inputs=[edge_indices_cpu_with_bending, particle_colors],
113
+ dim=edge_indices_cpu_with_bending.shape[0],
114
+ device="cpu",
115
+ )
116
+
117
+ num_colors_mcs = wp.context.runtime.core.graph_coloring(
118
+ model.particle_count,
119
+ edge_indices_cpu_with_bending.__ctype__(),
120
+ ColoringAlgorithm.MCS.value,
121
+ particle_colors.__ctype__(),
122
+ )
123
+ wp.context.runtime.core.balance_coloring(
124
+ model.particle_count,
125
+ edge_indices_cpu_with_bending.__ctype__(),
126
+ num_colors_mcs,
127
+ 1.1,
128
+ particle_colors.__ctype__(),
129
+ )
130
+ wp.launch(
131
+ kernel=validate_graph_coloring,
132
+ inputs=[edge_indices_cpu_with_bending, particle_colors],
133
+ dim=edge_indices_cpu_with_bending.shape[0],
134
+ device="cpu",
135
+ )
136
+
137
+
138
+ @unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
139
+ def test_combine_coloring(test, device):
140
+ from pxr import Usd, UsdGeom
141
+
142
+ with wp.ScopedDevice(device):
143
+ builder1 = wp.sim.ModelBuilder()
144
+ usd_stage = Usd.Stage.Open(os.path.join(wp.examples.get_asset_directory(), "bunny.usd"))
145
+ usd_geom = UsdGeom.Mesh(usd_stage.GetPrimAtPath("/root/bunny"))
146
+
147
+ vertices = np.array(usd_geom.GetPointsAttr().Get())
148
+ faces = np.array(usd_geom.GetFaceVertexIndicesAttr().Get())
149
+
150
+ builder1.add_cloth_mesh(
151
+ pos=wp.vec3(0.0, 0.0, 0.0),
152
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
153
+ scale=1.0,
154
+ vertices=[wp.vec3(p) for p in vertices],
155
+ indices=faces.flatten(),
156
+ vel=wp.vec3(0.0, 0.0, 0.0),
157
+ density=0.02,
158
+ )
159
+
160
+ builder1.add_cloth_grid(
161
+ pos=wp.vec3(0.0, 4.0, 0.0),
162
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
163
+ vel=wp.vec3(0.0, 0.0, 0.0),
164
+ dim_x=50,
165
+ dim_y=100,
166
+ cell_x=0.1,
167
+ cell_y=0.1,
168
+ mass=0.1,
169
+ fix_left=True,
170
+ )
171
+ builder1.color()
172
+
173
+ builder2 = wp.sim.ModelBuilder()
174
+ builder2.add_cloth_grid(
175
+ pos=wp.vec3(0.0, 4.0, 0.0),
176
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
177
+ vel=wp.vec3(0.0, 0.0, 0.0),
178
+ dim_x=50,
179
+ dim_y=100,
180
+ cell_x=0.1,
181
+ cell_y=0.1,
182
+ mass=0.1,
183
+ # to include bending in coloring
184
+ edge_ke=100000,
185
+ fix_left=True,
186
+ )
187
+ builder2.color()
188
+
189
+ builder3 = wp.sim.ModelBuilder()
190
+ builder3.add_cloth_grid(
191
+ pos=wp.vec3(0.0, 4.0, 0.0),
192
+ rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
193
+ vel=wp.vec3(0.0, 0.0, 0.0),
194
+ dim_x=50,
195
+ dim_y=100,
196
+ cell_x=0.1,
197
+ cell_y=0.1,
198
+ mass=0.1,
199
+ fix_left=True,
200
+ )
201
+
202
+ builder3.set_coloring(
203
+ color_lattice_grid(50, 100),
204
+ )
205
+
206
+ builder1.add_builder(builder2)
207
+ builder1.add_builder(builder3)
208
+
209
+ model = builder2.finalize()
210
+
211
+ particle_number_colored = np.full((model.particle_count), -1, dtype=int)
212
+ particle_colors = np.full((model.particle_count), -1, dtype=int)
213
+ for color, color_group in enumerate(model.particle_coloring):
214
+ particle_number_colored[color_group.numpy()] += 1
215
+ particle_colors[color_group.numpy()] = color
216
+
217
+ # all particles has been colored exactly once
218
+ assert_np_equal(particle_number_colored, 0)
219
+
220
+ edge_indices_cpu = wp.array(model.edge_indices.numpy()[:, 2:], dtype=int, device="cpu")
221
+ wp.launch(
222
+ kernel=validate_graph_coloring,
223
+ inputs=[edge_indices_cpu, wp.array(particle_colors, dtype=int, device="cpu")],
224
+ dim=edge_indices_cpu.shape[0],
225
+ device="cpu",
226
+ )
227
+
228
+
229
+ devices = get_test_devices()
230
+
231
+
232
+ class TestColoring(unittest.TestCase):
233
+ pass
234
+
235
+
236
+ add_function_test(TestColoring, "test_coloring_trimesh", test_coloring_trimesh, devices=devices)
237
+ add_function_test(TestColoring, "test_combine_coloring", test_combine_coloring, devices=devices)
238
+
239
+ if __name__ == "__main__":
240
+ wp.clear_kernel_cache()
241
+ unittest.main(verbosity=2)
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2024 NVIDIA CORPORATION. All rights reserved.
2
+ # NVIDIA CORPORATION and its licensors retain all intellectual property
3
+ # and proprietary rights in and to this software, related documentation
4
+ # and any modifications thereto. Any use, reproduction, disclosure or
5
+ # distribution of this software and related documentation without an express
6
+ # license agreement from NVIDIA CORPORATION is strictly prohibited.
7
+
8
+ import unittest
9
+ from typing import List, Tuple
10
+
11
+ import warp as wp
12
+ from warp.tests.unittest_utils import *
13
+
14
+
15
+ def test_context_type_str(test, device):
16
+ assert wp.context.type_str(List[int]) == "List[int]"
17
+ assert wp.context.type_str(List[float]) == "List[float]"
18
+
19
+ assert wp.context.type_str(Tuple[int]) == "Tuple[int]"
20
+ assert wp.context.type_str(Tuple[float]) == "Tuple[float]"
21
+ assert wp.context.type_str(Tuple[int, float]) == "Tuple[int, float]"
22
+ assert wp.context.type_str(Tuple[int, ...]) == "Tuple[int, ...]"
23
+
24
+
25
+ class TestContext(unittest.TestCase):
26
+ pass
27
+
28
+
29
+ add_function_test(TestContext, "test_context_type_str", test_context_type_str)
30
+
31
+
32
+ if __name__ == "__main__":
33
+ wp.clear_kernel_cache()
34
+ unittest.main(verbosity=2)
@@ -316,7 +316,7 @@ add_example_test(
316
316
  name="sim.example_cloth",
317
317
  devices=test_devices,
318
318
  test_options={"usd_required": True},
319
- test_options_cpu={"num_frames": 10},
319
+ test_options_cpu={"num_frames": 10, "test_timeout": 600},
320
320
  )
321
321
  add_example_test(
322
322
  TestSimExamples, name="sim.example_granular", devices=test_devices, test_options_cpu={"num_frames": 10}
@@ -365,9 +365,15 @@ if check_p2p():
365
365
  add_example_test(
366
366
  TestFemExamples,
367
367
  name="fem.example_apic_fluid",
368
- devices=get_selected_cuda_test_devices(),
368
+ devices=get_selected_cuda_test_devices(mode="basic"),
369
369
  test_options={"num_frames": 5, "voxel_size": 2.0},
370
370
  )
371
+ add_example_test(
372
+ TestFemExamples,
373
+ name="fem.example_adaptive_grid",
374
+ devices=get_selected_cuda_test_devices(mode="basic"),
375
+ test_options={"headless": True, "div_conforming": True},
376
+ )
371
377
 
372
378
  # The following examples do not need CUDA
373
379
  add_example_test(
@@ -390,18 +396,20 @@ add_example_test(
390
396
  name="fem.example_convection_diffusion",
391
397
  devices=test_devices,
392
398
  test_options={"resolution": 20, "headless": True},
399
+ test_options_cpu={"test_timeout": 600},
393
400
  )
394
401
  add_example_test(
395
402
  TestFemExamples,
396
403
  name="fem.example_burgers",
397
404
  devices=test_devices,
398
405
  test_options={"resolution": 20, "num_frames": 25, "degree": 1, "headless": True},
406
+ test_options_cpu={"test_timeout": 600},
399
407
  )
400
408
  add_example_test(
401
409
  TestFemExamples,
402
410
  name="fem.example_convection_diffusion_dg",
403
411
  devices=test_devices,
404
- test_options={"resolution": 20, "num_frames": 25, "mesh": "quad", "headless": True},
412
+ test_options={"resolution": 20, "num_frames": 25, "headless": True},
405
413
  test_options_cpu={"test_timeout": 600},
406
414
  )
407
415
  add_example_test(
@@ -429,9 +437,15 @@ add_example_test(
429
437
  add_example_test(
430
438
  TestFemExamples,
431
439
  name="fem.example_streamlines",
432
- devices=test_devices,
440
+ devices=get_selected_cuda_test_devices(),
433
441
  test_options={"headless": True},
434
442
  )
443
+ add_example_test(
444
+ TestFemExamples,
445
+ name="fem.example_distortion_energy",
446
+ devices=get_selected_cuda_test_devices(),
447
+ test_options={"headless": True, "resolution": 16},
448
+ )
435
449
  add_example_test(
436
450
  TestFemExamples,
437
451
  name="fem.example_magnetostatics",
@@ -821,6 +821,38 @@ def test_fabricarray_fill_matrix(test, device):
821
821
  assert_np_equal(ifb.numpy(), np.zeros((*ifb.shape, *mat_shape), dtype=nptype))
822
822
 
823
823
 
824
+ @wp.kernel
825
+ def fa_kernel_indexing_types(
826
+ a: wp.fabricarray(dtype=wp.int32),
827
+ ):
828
+ x = a[wp.uint8(0)]
829
+ y = a[wp.int16(1)]
830
+ z = a[wp.uint32(2)]
831
+ w = a[wp.int64(3)]
832
+
833
+ a[wp.uint8(0)] = 123
834
+ a[wp.int16(1)] = 123
835
+ a[wp.uint32(2)] = 123
836
+ a[wp.int64(3)] = 123
837
+
838
+ wp.atomic_add(a, wp.uint8(0), 123)
839
+ wp.atomic_sub(a, wp.int16(1), 123)
840
+ # wp.atomic_min(a, wp.uint32(2), 123)
841
+ # wp.atomic_max(a, wp.int64(3), 123)
842
+
843
+
844
+ def test_fabricarray_indexing_types(test, device):
845
+ data = wp.zeros(shape=(4,), dtype=wp.int32, device=device)
846
+ iface = _create_fabric_array_interface(data, "foo", copy=True)
847
+ fa = wp.fabricarray(data=iface, attrib="foo")
848
+ wp.launch(
849
+ kernel=fa_kernel_indexing_types,
850
+ dim=1,
851
+ inputs=(fa,),
852
+ device=device,
853
+ )
854
+
855
+
824
856
  @wp.kernel
825
857
  def fa_generic_sums_kernel(a: wp.fabricarrayarray(dtype=Any), sums: wp.array(dtype=Any)):
826
858
  i = wp.tid()
@@ -945,6 +977,7 @@ add_function_test(TestFabricArray, "test_fabricarray_generic_array", test_fabric
945
977
  add_function_test(TestFabricArray, "test_fabricarray_fill_scalar", test_fabricarray_fill_scalar, devices=devices)
946
978
  add_function_test(TestFabricArray, "test_fabricarray_fill_vector", test_fabricarray_fill_vector, devices=devices)
947
979
  add_function_test(TestFabricArray, "test_fabricarray_fill_matrix", test_fabricarray_fill_matrix, devices=devices)
980
+ add_function_test(TestFabricArray, "test_fabricarray_indexing_types", test_fabricarray_indexing_types, devices=devices)
948
981
 
949
982
  # fabric arrays of arrays
950
983
  add_function_test(TestFabricArray, "test_fabricarrayarray", test_fabricarrayarray, devices=devices)