warp-lang 1.3.3__py3-none-macosx_10_13_universal2.whl → 1.4.0__py3-none-macosx_10_13_universal2.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 (107) hide show
  1. warp/__init__.py +6 -0
  2. warp/autograd.py +59 -6
  3. warp/bin/libwarp-clang.dylib +0 -0
  4. warp/bin/libwarp.dylib +0 -0
  5. warp/build_dll.py +8 -10
  6. warp/builtins.py +126 -4
  7. warp/codegen.py +435 -53
  8. warp/config.py +1 -1
  9. warp/context.py +678 -403
  10. warp/dlpack.py +2 -0
  11. warp/examples/benchmarks/benchmark_cloth.py +10 -0
  12. warp/examples/core/example_render_opengl.py +12 -10
  13. warp/examples/fem/example_adaptive_grid.py +251 -0
  14. warp/examples/fem/example_apic_fluid.py +1 -1
  15. warp/examples/fem/example_diffusion_3d.py +2 -2
  16. warp/examples/fem/example_magnetostatics.py +1 -1
  17. warp/examples/fem/example_streamlines.py +1 -0
  18. warp/examples/fem/utils.py +23 -4
  19. warp/examples/sim/example_cloth.py +50 -6
  20. warp/fem/__init__.py +2 -0
  21. warp/fem/adaptivity.py +493 -0
  22. warp/fem/field/field.py +2 -1
  23. warp/fem/field/nodal_field.py +18 -26
  24. warp/fem/field/test.py +4 -4
  25. warp/fem/field/trial.py +4 -4
  26. warp/fem/geometry/__init__.py +1 -0
  27. warp/fem/geometry/adaptive_nanogrid.py +843 -0
  28. warp/fem/geometry/nanogrid.py +55 -28
  29. warp/fem/space/__init__.py +1 -1
  30. warp/fem/space/nanogrid_function_space.py +69 -35
  31. warp/fem/utils.py +113 -107
  32. warp/jax_experimental.py +28 -15
  33. warp/native/array.h +0 -1
  34. warp/native/builtin.h +103 -6
  35. warp/native/bvh.cu +2 -0
  36. warp/native/cuda_util.cpp +14 -0
  37. warp/native/cuda_util.h +2 -0
  38. warp/native/error.cpp +4 -2
  39. warp/native/exports.h +99 -17
  40. warp/native/mat.h +97 -0
  41. warp/native/mesh.cpp +36 -0
  42. warp/native/mesh.cu +51 -0
  43. warp/native/mesh.h +1 -0
  44. warp/native/quat.h +43 -0
  45. warp/native/spatial.h +6 -0
  46. warp/native/vec.h +74 -0
  47. warp/native/warp.cpp +2 -1
  48. warp/native/warp.cu +10 -3
  49. warp/native/warp.h +8 -1
  50. warp/paddle.py +382 -0
  51. warp/sim/__init__.py +1 -0
  52. warp/sim/collide.py +519 -0
  53. warp/sim/integrator_euler.py +18 -5
  54. warp/sim/integrator_featherstone.py +5 -5
  55. warp/sim/integrator_vbd.py +1026 -0
  56. warp/sim/model.py +49 -23
  57. warp/stubs.py +459 -0
  58. warp/tape.py +2 -0
  59. warp/tests/aux_test_dependent.py +1 -0
  60. warp/tests/aux_test_name_clash1.py +32 -0
  61. warp/tests/aux_test_name_clash2.py +32 -0
  62. warp/tests/aux_test_square.py +1 -0
  63. warp/tests/test_array.py +188 -0
  64. warp/tests/test_async.py +3 -3
  65. warp/tests/test_atomic.py +6 -0
  66. warp/tests/test_closest_point_edge_edge.py +93 -1
  67. warp/tests/test_codegen.py +62 -15
  68. warp/tests/test_codegen_instancing.py +1457 -0
  69. warp/tests/test_collision.py +486 -0
  70. warp/tests/test_compile_consts.py +3 -28
  71. warp/tests/test_dlpack.py +170 -0
  72. warp/tests/test_examples.py +22 -8
  73. warp/tests/test_fast_math.py +10 -4
  74. warp/tests/test_fem.py +64 -0
  75. warp/tests/test_func.py +46 -0
  76. warp/tests/test_implicit_init.py +49 -0
  77. warp/tests/test_jax.py +58 -0
  78. warp/tests/test_mat.py +84 -0
  79. warp/tests/test_mesh_query_point.py +188 -0
  80. warp/tests/test_module_hashing.py +40 -0
  81. warp/tests/test_multigpu.py +3 -3
  82. warp/tests/test_overwrite.py +8 -0
  83. warp/tests/test_paddle.py +852 -0
  84. warp/tests/test_print.py +89 -0
  85. warp/tests/test_quat.py +111 -0
  86. warp/tests/test_reload.py +31 -1
  87. warp/tests/test_scalar_ops.py +2 -0
  88. warp/tests/test_static.py +412 -0
  89. warp/tests/test_streams.py +64 -3
  90. warp/tests/test_struct.py +4 -4
  91. warp/tests/test_torch.py +24 -0
  92. warp/tests/test_triangle_closest_point.py +137 -0
  93. warp/tests/test_types.py +1 -1
  94. warp/tests/test_vbd.py +386 -0
  95. warp/tests/test_vec.py +143 -0
  96. warp/tests/test_vec_scalar_ops.py +139 -0
  97. warp/tests/unittest_suites.py +12 -0
  98. warp/tests/unittest_utils.py +9 -5
  99. warp/thirdparty/dlpack.py +3 -1
  100. warp/types.py +150 -28
  101. warp/utils.py +37 -14
  102. {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/METADATA +10 -8
  103. {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/RECORD +106 -94
  104. warp/tests/test_point_triangle_closest_point.py +0 -143
  105. {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/LICENSE.md +0 -0
  106. {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/WHEEL +0 -0
  107. {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/top_level.txt +0 -0
warp/sim/model.py CHANGED
@@ -527,8 +527,9 @@ class Model:
527
527
  tri_poses (array): Triangle element rest pose, shape [tri_count, 2, 2], float
528
528
  tri_activations (array): Triangle element activations, shape [tri_count], float
529
529
  tri_materials (array): Triangle element materials, shape [tri_count, 5], float
530
+ tri_areas (array): Triangle element rest areas, shape [tri_count], float
530
531
 
531
- edge_indices (array): Bending edge indices, shape [edge_count*4], int
532
+ edge_indices (array): Bending edge indices, shape [edge_count*4], int, each row is [o0, o1, v1, v2], where v1, v2 are on the edge
532
533
  edge_rest_angle (array): Bending edge rest angle, shape [edge_count], float
533
534
  edge_bending_properties (array): Bending edge stiffness and damping parameters, shape [edge_count, 2], float
534
535
 
@@ -558,6 +559,7 @@ class Model:
558
559
  joint_type (array): Joint type, shape [joint_count], int
559
560
  joint_parent (array): Joint parent body indices, shape [joint_count], int
560
561
  joint_child (array): Joint child body indices, shape [joint_count], int
562
+ joint_ancestor (array): Maps from joint index to the index of the joint that has the current joint parent body as child (-1 if no such joint ancestor exists), shape [joint_count], int
561
563
  joint_X_p (array): Joint transform in parent frame, shape [joint_count, 7], float
562
564
  joint_X_c (array): Joint mass frame in child frame, shape [joint_count, 7], float
563
565
  joint_axis (array): Joint axis in child frame, shape [joint_axis_count, 3], float
@@ -639,6 +641,8 @@ class Model:
639
641
  joint_dof_count (int): Total number of velocity degrees of freedom of all joints in the system
640
642
  joint_coord_count (int): Total number of position degrees of freedom of all joints in the system
641
643
 
644
+ particle_coloring (list of array): The coloring of all the particles, used for VBD's Gauss-Seidel interation.
645
+
642
646
  device (wp.Device): Device on which the Model was allocated
643
647
 
644
648
  Note:
@@ -695,6 +699,7 @@ class Model:
695
699
  self.tri_poses = None
696
700
  self.tri_activations = None
697
701
  self.tri_materials = None
702
+ self.tri_areas = None
698
703
 
699
704
  self.edge_indices = None
700
705
  self.edge_rest_angle = None
@@ -727,6 +732,7 @@ class Model:
727
732
  self.joint_type = None
728
733
  self.joint_parent = None
729
734
  self.joint_child = None
735
+ self.joint_ancestor = None
730
736
  self.joint_X_p = None
731
737
  self.joint_X_c = None
732
738
  self.joint_axis = None
@@ -806,6 +812,8 @@ class Model:
806
812
  self.joint_dof_count = 0
807
813
  self.joint_coord_count = 0
808
814
 
815
+ self.particle_coloring = []
816
+
809
817
  self.device = wp.get_device(device)
810
818
 
811
819
  def state(self, requires_grad=None) -> State:
@@ -1174,6 +1182,7 @@ class ModelBuilder:
1174
1182
  self.tri_poses = []
1175
1183
  self.tri_activations = []
1176
1184
  self.tri_materials = []
1185
+ self.tri_areas = []
1177
1186
 
1178
1187
  # edges (bending)
1179
1188
  self.edge_indices = []
@@ -1493,6 +1502,7 @@ class ModelBuilder:
1493
1502
  "tri_poses",
1494
1503
  "tri_activations",
1495
1504
  "tri_materials",
1505
+ "tri_areas",
1496
1506
  "tet_poses",
1497
1507
  "tet_activations",
1498
1508
  "tet_materials",
@@ -3529,6 +3539,7 @@ class ModelBuilder:
3529
3539
  self.tri_poses.append(inv_D.tolist())
3530
3540
  self.tri_activations.append(0.0)
3531
3541
  self.tri_materials.append((tri_ke, tri_ka, tri_kd, tri_drag, tri_lift))
3542
+ self.tri_areas.append(area)
3532
3543
  return area
3533
3544
 
3534
3545
  def add_triangles(
@@ -3617,7 +3628,9 @@ class ModelBuilder:
3617
3628
  np.array(tri_lift)[valid_inds],
3618
3629
  )
3619
3630
  )
3620
- return areas.tolist()
3631
+ areas = areas.tolist()
3632
+ self.tri_areas.extend(areas)
3633
+ return areas
3621
3634
 
3622
3635
  def add_tetrahedron(
3623
3636
  self, i: int, j: int, k: int, l: int, k_mu: float = 1.0e3, k_lambda: float = 1.0e3, k_damp: float = 0.0
@@ -3685,10 +3698,10 @@ class ModelBuilder:
3685
3698
  by the `model.tri_kb` parameter.
3686
3699
 
3687
3700
  Args:
3688
- i: The index of the first particle
3689
- j: The index of the second particle
3690
- k: The index of the third particle
3691
- l: The index of the fourth particle
3701
+ i: The index of the first particle, i.e., opposite vertex 0
3702
+ j: The index of the second particle, i.e., opposite vertex 1
3703
+ k: The index of the third particle, i.e., vertex 0
3704
+ l: The index of the fourth particle, i.e., vertex 1
3692
3705
  rest: The rest angle across the edge in radians, if not specified it will be computed
3693
3706
 
3694
3707
  Note:
@@ -3736,10 +3749,10 @@ class ModelBuilder:
3736
3749
  by the `model.tri_kb` parameter.
3737
3750
 
3738
3751
  Args:
3739
- i: The indices of the first particle
3740
- j: The indices of the second particle
3741
- k: The indices of the third particle
3742
- l: The indices of the fourth particle
3752
+ i: The index of the first particle, i.e., opposite vertex 0
3753
+ j: The index of the second particle, i.e., opposite vertex 1
3754
+ k: The index of the third particle, i.e., vertex 0
3755
+ l: The index of the fourth particle, i.e., vertex 1
3743
3756
  rest: The rest angles across the edges in radians, if not specified they will be computed
3744
3757
 
3745
3758
  Note:
@@ -3849,16 +3862,22 @@ class ModelBuilder:
3849
3862
  p = wp.quat_rotate(rot, g) + pos
3850
3863
  m = mass
3851
3864
 
3865
+ particle_flag = PARTICLE_FLAG_ACTIVE
3866
+
3852
3867
  if x == 0 and fix_left:
3853
3868
  m = 0.0
3869
+ particle_flag = wp.uint32(int(particle_flag) & ~int(PARTICLE_FLAG_ACTIVE))
3854
3870
  elif x == dim_x and fix_right:
3855
3871
  m = 0.0
3872
+ particle_flag = wp.uint32(int(particle_flag) & ~int(PARTICLE_FLAG_ACTIVE))
3856
3873
  elif y == 0 and fix_bottom:
3857
3874
  m = 0.0
3875
+ particle_flag = wp.uint32(int(particle_flag) & ~int(PARTICLE_FLAG_ACTIVE))
3858
3876
  elif y == dim_y and fix_top:
3859
3877
  m = 0.0
3878
+ particle_flag = wp.uint32(int(particle_flag) & ~int(PARTICLE_FLAG_ACTIVE))
3860
3879
 
3861
- self.add_particle(p, vel, m)
3880
+ self.add_particle(p, vel, m, flags=particle_flag)
3862
3881
 
3863
3882
  if x > 0 and y > 0:
3864
3883
  if reverse_winding:
@@ -3902,22 +3921,20 @@ class ModelBuilder:
3902
3921
  spring_indices = set()
3903
3922
 
3904
3923
  for _k, e in adj.edges.items():
3905
- # skip open edges
3906
- if e.f0 == -1 or e.f1 == -1:
3907
- continue
3908
-
3909
3924
  self.add_edge(
3910
3925
  e.o0, e.o1, e.v0, e.v1, edge_ke=edge_ke, edge_kd=edge_kd
3911
3926
  ) # opposite 0, opposite 1, vertex 0, vertex 1
3912
3927
 
3913
- spring_indices.add((min(e.o0, e.o1), max(e.o0, e.o1)))
3914
- spring_indices.add((min(e.o0, e.v0), max(e.o0, e.v0)))
3915
- spring_indices.add((min(e.o0, e.v1), max(e.o0, e.v1)))
3928
+ # skip constraints open edges
3929
+ if e.f0 != -1 and e.f1 != -1:
3930
+ spring_indices.add((min(e.o0, e.o1), max(e.o0, e.o1)))
3931
+ spring_indices.add((min(e.o0, e.v0), max(e.o0, e.v0)))
3932
+ spring_indices.add((min(e.o0, e.v1), max(e.o0, e.v1)))
3916
3933
 
3917
- spring_indices.add((min(e.o1, e.v0), max(e.o1, e.v0)))
3918
- spring_indices.add((min(e.o1, e.v1), max(e.o1, e.v1)))
3934
+ spring_indices.add((min(e.o1, e.v0), max(e.o1, e.v0)))
3935
+ spring_indices.add((min(e.o1, e.v1), max(e.o1, e.v1)))
3919
3936
 
3920
- spring_indices.add((min(e.v0, e.v1), max(e.v0, e.v1)))
3937
+ spring_indices.add((min(e.v0, e.v1), max(e.v0, e.v1)))
3921
3938
 
3922
3939
  if add_springs:
3923
3940
  for i, j in spring_indices:
@@ -4001,14 +4018,14 @@ class ModelBuilder:
4001
4018
  adj = wp.utils.MeshAdjacency(self.tri_indices[start_tri:end_tri], end_tri - start_tri)
4002
4019
 
4003
4020
  edgeinds = np.fromiter(
4004
- (x for e in adj.edges.values() if e.f0 != -1 and e.f1 != -1 for x in (e.o0, e.o1, e.v0, e.v1)),
4021
+ (x for e in adj.edges.values() for x in (e.o0, e.o1, e.v0, e.v1)),
4005
4022
  int,
4006
4023
  ).reshape(-1, 4)
4007
4024
  self.add_edges(
4008
4025
  edgeinds[:, 0],
4009
4026
  edgeinds[:, 1],
4010
4027
  edgeinds[:, 2],
4011
- edgeinds[:, 0],
4028
+ edgeinds[:, 3],
4012
4029
  edge_ke=[edge_ke] * len(edgeinds),
4013
4030
  edge_kd=[edge_kd] * len(edgeinds),
4014
4031
  )
@@ -4459,6 +4476,7 @@ class ModelBuilder:
4459
4476
  m.tri_poses = wp.array(self.tri_poses, dtype=wp.mat22, requires_grad=requires_grad)
4460
4477
  m.tri_activations = wp.array(self.tri_activations, dtype=wp.float32, requires_grad=requires_grad)
4461
4478
  m.tri_materials = wp.array(self.tri_materials, dtype=wp.float32, requires_grad=requires_grad)
4479
+ m.tri_areas = wp.array(self.tri_areas, dtype=wp.float32, requires_grad=requires_grad)
4462
4480
 
4463
4481
  # ---------------------
4464
4482
  # edges
@@ -4514,6 +4532,14 @@ class ModelBuilder:
4514
4532
  m.joint_q = wp.array(self.joint_q, dtype=wp.float32, requires_grad=requires_grad)
4515
4533
  m.joint_qd = wp.array(self.joint_qd, dtype=wp.float32, requires_grad=requires_grad)
4516
4534
  m.joint_name = self.joint_name
4535
+ # compute joint ancestors
4536
+ child_to_joint = {}
4537
+ for i, child in enumerate(self.joint_child):
4538
+ child_to_joint[child] = i
4539
+ parent_joint = []
4540
+ for parent in self.joint_parent:
4541
+ parent_joint.append(child_to_joint.get(parent, -1))
4542
+ m.joint_ancestor = wp.array(parent_joint, dtype=wp.int32)
4517
4543
 
4518
4544
  # dynamics properties
4519
4545
  m.joint_armature = wp.array(self.joint_armature, dtype=wp.float32, requires_grad=requires_grad)