warp-lang 1.9.1__py3-none-manylinux_2_34_aarch64.whl → 1.10.0__py3-none-manylinux_2_34_aarch64.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.
- warp/__init__.py +301 -287
- warp/__init__.pyi +882 -305
- warp/_src/__init__.py +14 -0
- warp/_src/autograd.py +1077 -0
- warp/_src/build.py +620 -0
- warp/_src/build_dll.py +642 -0
- warp/{builtins.py → _src/builtins.py} +1435 -379
- warp/_src/codegen.py +4361 -0
- warp/{config.py → _src/config.py} +178 -169
- warp/_src/constants.py +59 -0
- warp/_src/context.py +8352 -0
- warp/_src/dlpack.py +464 -0
- warp/_src/fabric.py +362 -0
- warp/_src/fem/__init__.py +14 -0
- warp/_src/fem/adaptivity.py +510 -0
- warp/_src/fem/cache.py +689 -0
- warp/_src/fem/dirichlet.py +190 -0
- warp/{fem → _src/fem}/domain.py +42 -30
- warp/_src/fem/field/__init__.py +131 -0
- warp/_src/fem/field/field.py +703 -0
- warp/{fem → _src/fem}/field/nodal_field.py +32 -15
- warp/{fem → _src/fem}/field/restriction.py +3 -1
- warp/{fem → _src/fem}/field/virtual.py +55 -27
- warp/_src/fem/geometry/__init__.py +32 -0
- warp/{fem → _src/fem}/geometry/adaptive_nanogrid.py +79 -163
- warp/_src/fem/geometry/closest_point.py +99 -0
- warp/{fem → _src/fem}/geometry/deformed_geometry.py +16 -22
- warp/{fem → _src/fem}/geometry/element.py +34 -10
- warp/{fem → _src/fem}/geometry/geometry.py +50 -20
- warp/{fem → _src/fem}/geometry/grid_2d.py +14 -23
- warp/{fem → _src/fem}/geometry/grid_3d.py +14 -23
- warp/{fem → _src/fem}/geometry/hexmesh.py +42 -63
- warp/{fem → _src/fem}/geometry/nanogrid.py +256 -247
- warp/{fem → _src/fem}/geometry/partition.py +123 -63
- warp/{fem → _src/fem}/geometry/quadmesh.py +28 -45
- warp/{fem → _src/fem}/geometry/tetmesh.py +42 -63
- warp/{fem → _src/fem}/geometry/trimesh.py +28 -45
- warp/{fem → _src/fem}/integrate.py +166 -158
- warp/_src/fem/linalg.py +385 -0
- warp/_src/fem/operator.py +398 -0
- warp/_src/fem/polynomial.py +231 -0
- warp/{fem → _src/fem}/quadrature/pic_quadrature.py +17 -20
- warp/{fem → _src/fem}/quadrature/quadrature.py +97 -47
- warp/_src/fem/space/__init__.py +248 -0
- warp/{fem → _src/fem}/space/basis_function_space.py +22 -11
- warp/_src/fem/space/basis_space.py +681 -0
- warp/{fem → _src/fem}/space/dof_mapper.py +5 -3
- warp/{fem → _src/fem}/space/function_space.py +16 -13
- warp/{fem → _src/fem}/space/grid_2d_function_space.py +6 -7
- warp/{fem → _src/fem}/space/grid_3d_function_space.py +6 -4
- warp/{fem → _src/fem}/space/hexmesh_function_space.py +6 -10
- warp/{fem → _src/fem}/space/nanogrid_function_space.py +5 -9
- warp/{fem → _src/fem}/space/partition.py +119 -60
- warp/{fem → _src/fem}/space/quadmesh_function_space.py +6 -10
- warp/{fem → _src/fem}/space/restriction.py +68 -33
- warp/_src/fem/space/shape/__init__.py +152 -0
- warp/{fem → _src/fem}/space/shape/cube_shape_function.py +11 -9
- warp/{fem → _src/fem}/space/shape/shape_function.py +10 -9
- warp/{fem → _src/fem}/space/shape/square_shape_function.py +8 -6
- warp/{fem → _src/fem}/space/shape/tet_shape_function.py +5 -3
- warp/{fem → _src/fem}/space/shape/triangle_shape_function.py +5 -3
- warp/{fem → _src/fem}/space/tetmesh_function_space.py +5 -9
- warp/_src/fem/space/topology.py +461 -0
- warp/{fem → _src/fem}/space/trimesh_function_space.py +5 -9
- warp/_src/fem/types.py +114 -0
- warp/_src/fem/utils.py +488 -0
- warp/_src/jax.py +188 -0
- warp/_src/jax_experimental/__init__.py +14 -0
- warp/_src/jax_experimental/custom_call.py +389 -0
- warp/_src/jax_experimental/ffi.py +1286 -0
- warp/_src/jax_experimental/xla_ffi.py +658 -0
- warp/_src/marching_cubes.py +710 -0
- warp/_src/math.py +416 -0
- warp/_src/optim/__init__.py +14 -0
- warp/_src/optim/adam.py +165 -0
- warp/_src/optim/linear.py +1608 -0
- warp/_src/optim/sgd.py +114 -0
- warp/_src/paddle.py +408 -0
- warp/_src/render/__init__.py +14 -0
- warp/_src/render/imgui_manager.py +291 -0
- warp/_src/render/render_opengl.py +3638 -0
- warp/_src/render/render_usd.py +939 -0
- warp/_src/render/utils.py +162 -0
- warp/_src/sparse.py +2718 -0
- warp/_src/tape.py +1208 -0
- warp/{thirdparty → _src/thirdparty}/unittest_parallel.py +9 -2
- warp/_src/torch.py +393 -0
- warp/_src/types.py +5888 -0
- warp/_src/utils.py +1695 -0
- warp/autograd.py +12 -1054
- warp/bin/warp-clang.so +0 -0
- warp/bin/warp.so +0 -0
- warp/build.py +8 -588
- warp/build_dll.py +6 -721
- warp/codegen.py +6 -4251
- warp/constants.py +6 -39
- warp/context.py +12 -8062
- warp/dlpack.py +6 -444
- warp/examples/distributed/example_jacobi_mpi.py +4 -5
- warp/examples/fem/example_adaptive_grid.py +1 -1
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_burgers.py +8 -8
- warp/examples/fem/example_diffusion.py +1 -1
- warp/examples/fem/example_distortion_energy.py +1 -1
- warp/examples/fem/example_mixed_elasticity.py +2 -2
- warp/examples/fem/example_navier_stokes.py +1 -1
- warp/examples/fem/example_nonconforming_contact.py +7 -7
- warp/examples/fem/example_stokes.py +1 -1
- warp/examples/fem/example_stokes_transfer.py +1 -1
- warp/examples/fem/utils.py +2 -2
- warp/examples/interop/example_jax_callable.py +1 -1
- warp/examples/interop/example_jax_ffi_callback.py +1 -1
- warp/examples/interop/example_jax_kernel.py +1 -1
- warp/examples/tile/example_tile_mcgp.py +191 -0
- warp/fabric.py +6 -337
- warp/fem/__init__.py +159 -97
- warp/fem/adaptivity.py +7 -489
- warp/fem/cache.py +9 -648
- warp/fem/dirichlet.py +6 -184
- warp/fem/field/__init__.py +8 -109
- warp/fem/field/field.py +7 -652
- warp/fem/geometry/__init__.py +7 -18
- warp/fem/geometry/closest_point.py +11 -77
- warp/fem/linalg.py +18 -366
- warp/fem/operator.py +11 -369
- warp/fem/polynomial.py +9 -209
- warp/fem/space/__init__.py +5 -211
- warp/fem/space/basis_space.py +6 -662
- warp/fem/space/shape/__init__.py +41 -118
- warp/fem/space/topology.py +6 -437
- warp/fem/types.py +6 -81
- warp/fem/utils.py +11 -444
- warp/jax.py +8 -165
- warp/jax_experimental/__init__.py +14 -1
- warp/jax_experimental/custom_call.py +8 -365
- warp/jax_experimental/ffi.py +17 -873
- warp/jax_experimental/xla_ffi.py +5 -605
- warp/marching_cubes.py +5 -689
- warp/math.py +16 -393
- warp/native/array.h +385 -37
- warp/native/builtin.h +314 -37
- warp/native/bvh.cpp +43 -9
- warp/native/bvh.cu +62 -27
- warp/native/bvh.h +310 -309
- warp/native/clang/clang.cpp +102 -97
- warp/native/coloring.cpp +0 -1
- warp/native/crt.h +208 -0
- warp/native/exports.h +156 -0
- warp/native/hashgrid.cu +2 -0
- warp/native/intersect.h +24 -1
- warp/native/intersect_tri.h +44 -35
- warp/native/mat.h +1456 -276
- warp/native/mesh.cpp +4 -4
- warp/native/mesh.cu +4 -2
- warp/native/mesh.h +176 -61
- warp/native/quat.h +0 -52
- warp/native/scan.cu +2 -0
- warp/native/sparse.cu +7 -3
- warp/native/spatial.h +12 -0
- warp/native/tile.h +681 -89
- warp/native/tile_radix_sort.h +3 -3
- warp/native/tile_reduce.h +394 -46
- warp/native/tile_scan.h +4 -4
- warp/native/vec.h +469 -0
- warp/native/version.h +23 -0
- warp/native/volume.cpp +1 -1
- warp/native/volume.cu +1 -0
- warp/native/volume.h +1 -1
- warp/native/volume_builder.cu +2 -0
- warp/native/warp.cpp +57 -29
- warp/native/warp.cu +521 -250
- warp/native/warp.h +11 -8
- warp/optim/__init__.py +6 -3
- warp/optim/adam.py +6 -145
- warp/optim/linear.py +14 -1585
- warp/optim/sgd.py +6 -94
- warp/paddle.py +6 -388
- warp/render/__init__.py +8 -4
- warp/render/imgui_manager.py +7 -267
- warp/render/render_opengl.py +6 -3618
- warp/render/render_usd.py +6 -919
- warp/render/utils.py +6 -142
- warp/sparse.py +37 -2563
- warp/tape.py +6 -1188
- warp/tests/__main__.py +1 -1
- warp/tests/cuda/test_async.py +4 -4
- warp/tests/cuda/test_conditional_captures.py +1 -1
- warp/tests/cuda/test_multigpu.py +1 -1
- warp/tests/cuda/test_streams.py +58 -1
- warp/tests/geometry/test_bvh.py +157 -22
- warp/tests/geometry/test_marching_cubes.py +0 -1
- warp/tests/geometry/test_mesh.py +5 -3
- warp/tests/geometry/test_mesh_query_aabb.py +5 -12
- warp/tests/geometry/test_mesh_query_point.py +5 -2
- warp/tests/geometry/test_mesh_query_ray.py +15 -3
- warp/tests/geometry/test_volume_write.py +5 -5
- warp/tests/interop/test_dlpack.py +18 -17
- warp/tests/interop/test_jax.py +772 -49
- warp/tests/interop/test_paddle.py +1 -1
- warp/tests/test_adam.py +0 -1
- warp/tests/test_arithmetic.py +9 -9
- warp/tests/test_array.py +578 -100
- warp/tests/test_array_reduce.py +3 -3
- warp/tests/test_atomic.py +12 -8
- warp/tests/test_atomic_bitwise.py +209 -0
- warp/tests/test_atomic_cas.py +4 -4
- warp/tests/test_bool.py +2 -2
- warp/tests/test_builtins_resolution.py +5 -571
- warp/tests/test_codegen.py +33 -14
- warp/tests/test_conditional.py +1 -1
- warp/tests/test_context.py +6 -6
- warp/tests/test_copy.py +242 -161
- warp/tests/test_ctypes.py +3 -3
- warp/tests/test_devices.py +24 -2
- warp/tests/test_examples.py +16 -84
- warp/tests/test_fabricarray.py +35 -35
- warp/tests/test_fast_math.py +0 -2
- warp/tests/test_fem.py +56 -10
- warp/tests/test_fixedarray.py +3 -3
- warp/tests/test_func.py +8 -5
- warp/tests/test_generics.py +1 -1
- warp/tests/test_indexedarray.py +24 -24
- warp/tests/test_intersect.py +39 -9
- warp/tests/test_large.py +1 -1
- warp/tests/test_lerp.py +3 -1
- warp/tests/test_linear_solvers.py +1 -1
- warp/tests/test_map.py +35 -4
- warp/tests/test_mat.py +52 -62
- warp/tests/test_mat_constructors.py +4 -5
- warp/tests/test_mat_lite.py +1 -1
- warp/tests/test_mat_scalar_ops.py +121 -121
- warp/tests/test_math.py +34 -0
- warp/tests/test_module_aot.py +4 -4
- warp/tests/test_modules_lite.py +28 -2
- warp/tests/test_print.py +11 -11
- warp/tests/test_quat.py +93 -58
- warp/tests/test_runlength_encode.py +1 -1
- warp/tests/test_scalar_ops.py +38 -10
- warp/tests/test_smoothstep.py +1 -1
- warp/tests/test_sparse.py +126 -15
- warp/tests/test_spatial.py +105 -87
- warp/tests/test_special_values.py +6 -6
- warp/tests/test_static.py +7 -7
- warp/tests/test_struct.py +13 -2
- warp/tests/test_triangle_closest_point.py +48 -1
- warp/tests/test_types.py +27 -15
- warp/tests/test_utils.py +52 -52
- warp/tests/test_vec.py +29 -29
- warp/tests/test_vec_constructors.py +5 -5
- warp/tests/test_vec_scalar_ops.py +97 -97
- warp/tests/test_version.py +75 -0
- warp/tests/tile/test_tile.py +178 -0
- warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
- warp/tests/tile/test_tile_cholesky.py +7 -4
- warp/tests/tile/test_tile_load.py +26 -2
- warp/tests/tile/test_tile_mathdx.py +3 -3
- warp/tests/tile/test_tile_matmul.py +1 -1
- warp/tests/tile/test_tile_mlp.py +2 -4
- warp/tests/tile/test_tile_reduce.py +214 -13
- warp/tests/unittest_suites.py +6 -14
- warp/tests/unittest_utils.py +10 -9
- warp/tests/walkthrough_debug.py +3 -1
- warp/torch.py +6 -373
- warp/types.py +29 -5764
- warp/utils.py +10 -1659
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0.dist-info}/METADATA +46 -99
- warp_lang-1.10.0.dist-info/RECORD +468 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
- warp/examples/assets/cartpole.urdf +0 -110
- warp/examples/assets/crazyflie.usd +0 -0
- warp/examples/assets/nv_ant.xml +0 -92
- warp/examples/assets/nv_humanoid.xml +0 -183
- warp/examples/assets/quadruped.urdf +0 -268
- warp/examples/optim/example_bounce.py +0 -266
- warp/examples/optim/example_cloth_throw.py +0 -228
- warp/examples/optim/example_drone.py +0 -870
- warp/examples/optim/example_inverse_kinematics.py +0 -182
- warp/examples/optim/example_inverse_kinematics_torch.py +0 -191
- warp/examples/optim/example_softbody_properties.py +0 -400
- warp/examples/optim/example_spring_cage.py +0 -245
- warp/examples/optim/example_trajectory.py +0 -227
- warp/examples/sim/example_cartpole.py +0 -143
- warp/examples/sim/example_cloth.py +0 -225
- warp/examples/sim/example_cloth_self_contact.py +0 -316
- warp/examples/sim/example_granular.py +0 -130
- warp/examples/sim/example_granular_collision_sdf.py +0 -202
- warp/examples/sim/example_jacobian_ik.py +0 -244
- warp/examples/sim/example_particle_chain.py +0 -124
- warp/examples/sim/example_quadruped.py +0 -203
- warp/examples/sim/example_rigid_chain.py +0 -203
- warp/examples/sim/example_rigid_contact.py +0 -195
- warp/examples/sim/example_rigid_force.py +0 -133
- warp/examples/sim/example_rigid_gyroscopic.py +0 -115
- warp/examples/sim/example_rigid_soft_contact.py +0 -140
- warp/examples/sim/example_soft_body.py +0 -196
- warp/examples/tile/example_tile_walker.py +0 -327
- warp/sim/__init__.py +0 -74
- warp/sim/articulation.py +0 -793
- warp/sim/collide.py +0 -2570
- warp/sim/graph_coloring.py +0 -307
- warp/sim/import_mjcf.py +0 -791
- warp/sim/import_snu.py +0 -227
- warp/sim/import_urdf.py +0 -579
- warp/sim/import_usd.py +0 -898
- warp/sim/inertia.py +0 -357
- warp/sim/integrator.py +0 -245
- warp/sim/integrator_euler.py +0 -2000
- warp/sim/integrator_featherstone.py +0 -2101
- warp/sim/integrator_vbd.py +0 -2487
- warp/sim/integrator_xpbd.py +0 -3295
- warp/sim/model.py +0 -4821
- warp/sim/particles.py +0 -121
- warp/sim/render.py +0 -431
- warp/sim/utils.py +0 -431
- warp/tests/sim/disabled_kinematics.py +0 -244
- warp/tests/sim/test_cloth.py +0 -863
- warp/tests/sim/test_collision.py +0 -743
- warp/tests/sim/test_coloring.py +0 -347
- warp/tests/sim/test_inertia.py +0 -161
- warp/tests/sim/test_model.py +0 -226
- warp/tests/sim/test_sim_grad.py +0 -287
- warp/tests/sim/test_sim_grad_bounce_linear.py +0 -212
- warp/tests/sim/test_sim_kinematics.py +0 -98
- warp/thirdparty/__init__.py +0 -0
- warp_lang-1.9.1.dist-info/RECORD +0 -456
- /warp/{fem → _src/fem}/quadrature/__init__.py +0 -0
- /warp/{tests/sim → _src/thirdparty}/__init__.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/appdirs.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/dlpack.py +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0.dist-info}/WHEEL +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0.dist-info}/top_level.txt +0 -0
|
@@ -15,22 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
from typing import Optional
|
|
17
17
|
|
|
18
|
-
import numpy as np
|
|
19
|
-
|
|
20
18
|
import warp as wp
|
|
21
|
-
from warp.fem import cache, utils
|
|
22
|
-
from warp.fem.types import OUTSIDE, Coords, ElementIndex, Sample, make_free_sample
|
|
23
|
-
|
|
24
|
-
from .
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Nanogrid,
|
|
28
|
-
_add_axis_flag,
|
|
29
|
-
_build_node_grid,
|
|
30
|
-
_extract_axis_flag,
|
|
31
|
-
_get_boundary_mask,
|
|
32
|
-
_make_face_flags,
|
|
33
|
-
)
|
|
19
|
+
from warp._src.fem import cache, utils
|
|
20
|
+
from warp._src.fem.types import OUTSIDE, Coords, ElementIndex, Sample, make_free_sample
|
|
21
|
+
|
|
22
|
+
from .nanogrid import NanogridBase
|
|
23
|
+
|
|
24
|
+
_wp_module_name_ = "warp.fem.geometry.adaptive_nanogrid"
|
|
34
25
|
|
|
35
26
|
_FACE_LEVEL_BIT = wp.constant(wp.uint8(4)) # follows nanogrid.FACE_OUTER_OFFSET_BIT
|
|
36
27
|
_GRID_LEVEL_BIT = wp.constant(wp.int32(19)) # follows nanogrid.GRID_AXIS_FLAG
|
|
@@ -57,7 +48,7 @@ class AdaptiveNanogridSideArg:
|
|
|
57
48
|
face_areas: wp.vec3
|
|
58
49
|
|
|
59
50
|
|
|
60
|
-
class AdaptiveNanogrid(
|
|
51
|
+
class AdaptiveNanogrid(NanogridBase):
|
|
61
52
|
"""Adaptive sparse grid"""
|
|
62
53
|
|
|
63
54
|
dimension = 3
|
|
@@ -86,61 +77,24 @@ class AdaptiveNanogrid(Geometry):
|
|
|
86
77
|
raise ValueError("Too many refinement levels, max 8 supported")
|
|
87
78
|
|
|
88
79
|
self.level_count = level_count
|
|
89
|
-
self._cell_grid = cell_grid
|
|
90
80
|
self._cell_level = cell_level
|
|
91
81
|
|
|
92
|
-
device =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
self._cell_grid_info = self._cell_grid.get_grid_info()
|
|
82
|
+
device = cell_grid.device
|
|
83
|
+
cell_ijk = wp.array(dtype=wp.vec3i, shape=(cell_grid.get_voxel_count(),), device=device)
|
|
84
|
+
cell_grid.get_voxels(out=cell_ijk)
|
|
96
85
|
|
|
97
|
-
|
|
98
|
-
node_count =
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
node_grid = _build_node_grid(cell_ijk, cell_level, cell_grid, temporary_store)
|
|
87
|
+
node_count = node_grid.get_voxel_count()
|
|
88
|
+
node_ijk = wp.array(shape=(node_count,), dtype=wp.vec3i, device=device)
|
|
89
|
+
node_grid.get_voxels(out=node_ijk)
|
|
101
90
|
|
|
102
|
-
|
|
103
|
-
self._face_ijk = None
|
|
91
|
+
super().__init__(cell_grid, cell_ijk, node_grid, node_ijk)
|
|
104
92
|
|
|
105
93
|
self._stacked_edge_grid = None
|
|
106
94
|
self._stacked_edge_count = 0
|
|
107
95
|
self._stacked_face_grid = None
|
|
108
96
|
self._stacked_face_count = 0
|
|
109
97
|
|
|
110
|
-
transform = self.transform
|
|
111
|
-
self._inverse_transform = wp.mat33f(np.linalg.inv(transform))
|
|
112
|
-
self._cell_volume = abs(np.linalg.det(transform))
|
|
113
|
-
self._face_areas = wp.vec3(
|
|
114
|
-
tuple(np.linalg.norm(np.cross(transform[:, k - 2], transform[:, k - 1])) for k in range(3))
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
@property
|
|
118
|
-
def cell_grid(self) -> wp.Volume:
|
|
119
|
-
return self._cell_grid
|
|
120
|
-
|
|
121
|
-
@property
|
|
122
|
-
def vertex_grid(self) -> wp.Volume:
|
|
123
|
-
return self._node_grid
|
|
124
|
-
|
|
125
|
-
@property
|
|
126
|
-
def face_grid(self) -> wp.Volume:
|
|
127
|
-
self._ensure_face_grid()
|
|
128
|
-
return self._face_grid
|
|
129
|
-
|
|
130
|
-
def cell_count(self):
|
|
131
|
-
return self._cell_ijk.shape[0]
|
|
132
|
-
|
|
133
|
-
def vertex_count(self):
|
|
134
|
-
return self._node_ijk.shape[0]
|
|
135
|
-
|
|
136
|
-
def side_count(self):
|
|
137
|
-
self._ensure_face_grid()
|
|
138
|
-
return self._face_ijk.shape[0]
|
|
139
|
-
|
|
140
|
-
def boundary_side_count(self):
|
|
141
|
-
self._ensure_face_grid()
|
|
142
|
-
return self._boundary_face_indices.shape[0]
|
|
143
|
-
|
|
144
98
|
@property
|
|
145
99
|
def stacked_face_grid(self) -> wp.Volume:
|
|
146
100
|
self._ensure_stacked_face_grid()
|
|
@@ -159,24 +113,8 @@ class AdaptiveNanogrid(Geometry):
|
|
|
159
113
|
self._ensure_stacked_edge_grid()
|
|
160
114
|
return self._stacked_edge_count
|
|
161
115
|
|
|
162
|
-
def reference_cell(self) -> Cube:
|
|
163
|
-
return Cube()
|
|
164
|
-
|
|
165
|
-
def reference_side(self) -> Square:
|
|
166
|
-
return Square()
|
|
167
|
-
|
|
168
|
-
@property
|
|
169
|
-
def transform(self):
|
|
170
|
-
return np.array(self._cell_grid_info.transform_matrix).reshape(3, 3)
|
|
171
|
-
|
|
172
116
|
CellArg = AdaptiveNanogridCellArg
|
|
173
117
|
|
|
174
|
-
@cache.cached_arg_value
|
|
175
|
-
def cell_arg_value(self, device) -> CellArg:
|
|
176
|
-
args = self.CellArg()
|
|
177
|
-
self.fill_cell_arg(args, device)
|
|
178
|
-
return args
|
|
179
|
-
|
|
180
118
|
def fill_cell_arg(self, arg: CellArg, device):
|
|
181
119
|
arg.cell_grid = self._cell_grid.id
|
|
182
120
|
arg.cell_ijk = self._cell_ijk
|
|
@@ -242,9 +180,6 @@ class AdaptiveNanogrid(Geometry):
|
|
|
242
180
|
dist, coords = AdaptiveNanogrid._cell_closest_point_local(args, cell_index, uvw)
|
|
243
181
|
return coords, dist
|
|
244
182
|
|
|
245
|
-
def make_filtered_cell_lookup(self, filter_func: wp.Function = None):
|
|
246
|
-
return Nanogrid._make_filtered_cell_lookup(self, filter_func)
|
|
247
|
-
|
|
248
183
|
@wp.func
|
|
249
184
|
def cell_measure(args: CellArg, s: Sample):
|
|
250
185
|
scale = AdaptiveNanogrid._cell_scale(args, s.element_index)
|
|
@@ -254,23 +189,12 @@ class AdaptiveNanogrid(Geometry):
|
|
|
254
189
|
def cell_normal(args: CellArg, s: Sample):
|
|
255
190
|
return wp.vec3(0.0)
|
|
256
191
|
|
|
257
|
-
SideIndexArg = Nanogrid.SideIndexArg
|
|
258
|
-
side_index_arg_value = Nanogrid.side_index_arg_value
|
|
259
|
-
fill_side_index_arg = Nanogrid.fill_side_index_arg
|
|
260
|
-
|
|
261
192
|
SideArg = AdaptiveNanogridSideArg
|
|
262
193
|
|
|
263
194
|
@wp.func
|
|
264
195
|
def side_to_cell_arg(side_arg: SideArg):
|
|
265
196
|
return side_arg.cell_arg
|
|
266
197
|
|
|
267
|
-
@cache.cached_arg_value
|
|
268
|
-
def side_arg_value(self, device) -> SideArg:
|
|
269
|
-
args = self.SideArg()
|
|
270
|
-
self.fill_side_arg(args, device)
|
|
271
|
-
|
|
272
|
-
return args
|
|
273
|
-
|
|
274
198
|
def fill_side_arg(self, arg: SideArg, device):
|
|
275
199
|
self._ensure_face_grid()
|
|
276
200
|
|
|
@@ -280,10 +204,6 @@ class AdaptiveNanogrid(Geometry):
|
|
|
280
204
|
arg.face_cell_indices = self._face_cell_indices.to(device)
|
|
281
205
|
arg.face_areas = self._face_areas
|
|
282
206
|
|
|
283
|
-
@wp.func
|
|
284
|
-
def boundary_side_index(args: SideIndexArg, boundary_side_index: int):
|
|
285
|
-
return args.boundary_face_indices[boundary_side_index]
|
|
286
|
-
|
|
287
207
|
@wp.func
|
|
288
208
|
def _get_face_level(flags: wp.uint8):
|
|
289
209
|
return wp.int32(flags >> _FACE_LEVEL_BIT)
|
|
@@ -296,11 +216,11 @@ class AdaptiveNanogrid(Geometry):
|
|
|
296
216
|
def side_position(args: SideArg, s: Sample):
|
|
297
217
|
ijk = args.face_ijk[s.element_index]
|
|
298
218
|
flags = args.face_flags[s.element_index]
|
|
299
|
-
axis =
|
|
300
|
-
flip =
|
|
219
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
220
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
301
221
|
scale = AdaptiveNanogrid._get_face_scale(flags)
|
|
302
222
|
|
|
303
|
-
uvw = wp.vec3(ijk) + scale *
|
|
223
|
+
uvw = wp.vec3(ijk) + scale * NanogridBase._side_to_cell_coords(axis, flip, 0.0, s.element_coords)
|
|
304
224
|
|
|
305
225
|
cell_grid = args.cell_arg.cell_grid
|
|
306
226
|
return wp.volume_index_to_world(cell_grid, uvw - wp.vec3(0.5))
|
|
@@ -308,10 +228,10 @@ class AdaptiveNanogrid(Geometry):
|
|
|
308
228
|
@wp.func
|
|
309
229
|
def side_deformation_gradient(args: SideArg, s: Sample):
|
|
310
230
|
flags = args.face_flags[s.element_index]
|
|
311
|
-
axis =
|
|
312
|
-
flip =
|
|
231
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
232
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
313
233
|
scale = AdaptiveNanogrid._get_face_scale(flags)
|
|
314
|
-
v1, v2 =
|
|
234
|
+
v1, v2 = NanogridBase._face_tangent_vecs(args.cell_arg.cell_grid, axis, flip)
|
|
315
235
|
return wp.matrix_from_cols(v1, v2) * scale
|
|
316
236
|
|
|
317
237
|
@wp.func
|
|
@@ -327,24 +247,24 @@ class AdaptiveNanogrid(Geometry):
|
|
|
327
247
|
@wp.func
|
|
328
248
|
def side_measure(args: SideArg, s: Sample):
|
|
329
249
|
flags = args.face_flags[s.element_index]
|
|
330
|
-
axis =
|
|
250
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
331
251
|
scale = AdaptiveNanogrid._get_face_scale(flags)
|
|
332
252
|
return args.face_areas[axis] * scale * scale
|
|
333
253
|
|
|
334
254
|
@wp.func
|
|
335
255
|
def side_measure_ratio(args: SideArg, s: Sample):
|
|
336
256
|
flags = args.face_flags[s.element_index]
|
|
337
|
-
axis =
|
|
257
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
338
258
|
scale = AdaptiveNanogrid._get_face_scale(flags)
|
|
339
259
|
return args.face_areas[axis] / (args.cell_arg.cell_volume * scale)
|
|
340
260
|
|
|
341
261
|
@wp.func
|
|
342
262
|
def side_normal(args: SideArg, s: Sample):
|
|
343
263
|
flags = args.face_flags[s.element_index]
|
|
344
|
-
axis =
|
|
345
|
-
flip =
|
|
264
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
265
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
346
266
|
|
|
347
|
-
v1, v2 =
|
|
267
|
+
v1, v2 = NanogridBase._face_tangent_vecs(args.cell_arg.cell_grid, axis, flip)
|
|
348
268
|
return wp.cross(v1, v2) / args.face_areas[axis]
|
|
349
269
|
|
|
350
270
|
@wp.func
|
|
@@ -368,11 +288,11 @@ class AdaptiveNanogrid(Geometry):
|
|
|
368
288
|
@wp.func
|
|
369
289
|
def side_inner_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
370
290
|
flags = args.face_flags[side_index]
|
|
371
|
-
axis =
|
|
372
|
-
flip =
|
|
373
|
-
offset =
|
|
291
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
292
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
293
|
+
offset = NanogridBase._get_face_inner_offset(flags)
|
|
374
294
|
|
|
375
|
-
same_level_cell_coords =
|
|
295
|
+
same_level_cell_coords = NanogridBase._side_to_cell_coords(axis, flip, 1.0 - float(offset), side_coords)
|
|
376
296
|
same_level_cell_ijk = args.face_ijk[side_index]
|
|
377
297
|
side_level = AdaptiveNanogrid._get_face_level(flags)
|
|
378
298
|
same_level_cell_ijk[axis] += (offset - 1) << side_level
|
|
@@ -388,11 +308,11 @@ class AdaptiveNanogrid(Geometry):
|
|
|
388
308
|
@wp.func
|
|
389
309
|
def side_outer_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
390
310
|
flags = args.face_flags[side_index]
|
|
391
|
-
axis =
|
|
392
|
-
flip =
|
|
393
|
-
offset =
|
|
311
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
312
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
313
|
+
offset = NanogridBase._get_face_outer_offset(flags)
|
|
394
314
|
|
|
395
|
-
same_level_cell_coords =
|
|
315
|
+
same_level_cell_coords = NanogridBase._side_to_cell_coords(axis, flip, float(offset), side_coords)
|
|
396
316
|
same_level_cell_ijk = args.face_ijk[side_index]
|
|
397
317
|
side_level = AdaptiveNanogrid._get_face_level(flags)
|
|
398
318
|
same_level_cell_ijk[axis] -= offset << side_level
|
|
@@ -413,8 +333,8 @@ class AdaptiveNanogrid(Geometry):
|
|
|
413
333
|
element_coords: Coords,
|
|
414
334
|
):
|
|
415
335
|
flags = args.face_flags[side_index]
|
|
416
|
-
axis =
|
|
417
|
-
flip =
|
|
336
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
337
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
418
338
|
side_level = AdaptiveNanogrid._get_face_level(flags)
|
|
419
339
|
cell_level = int(args.cell_arg.cell_level[element_index])
|
|
420
340
|
|
|
@@ -431,7 +351,7 @@ class AdaptiveNanogrid(Geometry):
|
|
|
431
351
|
and wp.max(same_level_cell_coords) <= 1.0
|
|
432
352
|
)
|
|
433
353
|
|
|
434
|
-
return wp.where(on_side,
|
|
354
|
+
return wp.where(on_side, NanogridBase._cell_to_side_coords(axis, flip, same_level_cell_coords), Coords(OUTSIDE))
|
|
435
355
|
|
|
436
356
|
@wp.func
|
|
437
357
|
def side_coordinates(args: SideArg, side_index: int, pos: wp.vec3):
|
|
@@ -442,10 +362,10 @@ class AdaptiveNanogrid(Geometry):
|
|
|
442
362
|
|
|
443
363
|
flags = args.face_flags[side_index]
|
|
444
364
|
side_level = AdaptiveNanogrid._get_face_level(flags)
|
|
445
|
-
axis =
|
|
446
|
-
flip =
|
|
365
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
366
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
447
367
|
|
|
448
|
-
return
|
|
368
|
+
return NanogridBase._cell_to_side_coords(axis, flip, fine_cell_coords / float(1 << side_level))
|
|
449
369
|
|
|
450
370
|
@wp.func
|
|
451
371
|
def side_closest_point(args: SideArg, side_index: int, pos: wp.vec3):
|
|
@@ -454,10 +374,12 @@ class AdaptiveNanogrid(Geometry):
|
|
|
454
374
|
proj_coords = Coords(wp.clamp(coords[0], 0.0, 1.0), wp.clamp(coords[1], 0.0, 1.0), 0.0)
|
|
455
375
|
|
|
456
376
|
flags = args.face_flags[side_index]
|
|
457
|
-
axis =
|
|
458
|
-
flip =
|
|
377
|
+
axis = NanogridBase._get_face_axis(flags)
|
|
378
|
+
flip = NanogridBase._get_face_inner_offset(flags)
|
|
459
379
|
side_level = AdaptiveNanogrid._get_face_level(flags)
|
|
460
|
-
cell_coord_offset =
|
|
380
|
+
cell_coord_offset = NanogridBase._side_to_cell_coords(axis, flip, 0, coords - proj_coords) * float(
|
|
381
|
+
1 << side_level
|
|
382
|
+
)
|
|
461
383
|
|
|
462
384
|
return proj_coords, wp.length_sq(wp.volume_index_to_world_dir(args.cell_grid, cell_coord_offset))
|
|
463
385
|
|
|
@@ -492,16 +414,12 @@ class AdaptiveNanogrid(Geometry):
|
|
|
492
414
|
self._face_ijk,
|
|
493
415
|
self._face_cell_indices,
|
|
494
416
|
self._face_flags,
|
|
495
|
-
boundary_face_mask
|
|
417
|
+
boundary_face_mask,
|
|
496
418
|
],
|
|
497
419
|
)
|
|
498
|
-
boundary_face_indices, _ = utils.masked_indices(boundary_face_mask
|
|
420
|
+
boundary_face_indices, _ = utils.masked_indices(boundary_face_mask)
|
|
499
421
|
self._boundary_face_indices = boundary_face_indices.detach()
|
|
500
422
|
|
|
501
|
-
def _ensure_face_grid(self):
|
|
502
|
-
if self._face_ijk is None:
|
|
503
|
-
self._build_face_grid()
|
|
504
|
-
|
|
505
423
|
def _ensure_stacked_edge_grid(self):
|
|
506
424
|
if self._stacked_edge_grid is None:
|
|
507
425
|
self._stacked_edge_grid = _build_stacked_edge_grid(
|
|
@@ -537,7 +455,7 @@ class AdaptiveNanogrid(Geometry):
|
|
|
537
455
|
level_flag = ((level >> ax) & 1) << _GRID_LEVEL_BIT
|
|
538
456
|
ijk[ax] = wp.where(coord < 0, coord & ~level_flag, coord | level_flag)
|
|
539
457
|
|
|
540
|
-
return _add_axis_flag(ijk, axis)
|
|
458
|
+
return NanogridBase._add_axis_flag(ijk, axis)
|
|
541
459
|
|
|
542
460
|
@wp.func
|
|
543
461
|
def find_cell(
|
|
@@ -576,15 +494,15 @@ def _cell_face_indices(
|
|
|
576
494
|
):
|
|
577
495
|
cell = wp.tid()
|
|
578
496
|
ijk = cell_ijk[cell]
|
|
579
|
-
node_ijk[cell, 0] = _add_axis_flag(ijk, 0)
|
|
580
|
-
node_ijk[cell, 1] = _add_axis_flag(ijk, 1)
|
|
581
|
-
node_ijk[cell, 2] = _add_axis_flag(ijk, 2)
|
|
497
|
+
node_ijk[cell, 0] = NanogridBase._add_axis_flag(ijk, 0)
|
|
498
|
+
node_ijk[cell, 1] = NanogridBase._add_axis_flag(ijk, 1)
|
|
499
|
+
node_ijk[cell, 2] = NanogridBase._add_axis_flag(ijk, 2)
|
|
582
500
|
|
|
583
501
|
offset = 1 << int(cell_level[cell])
|
|
584
502
|
|
|
585
|
-
node_ijk[cell, 3] = _add_axis_flag(ijk + wp.vec3i(offset, 0, 0), 0)
|
|
586
|
-
node_ijk[cell, 4] = _add_axis_flag(ijk + wp.vec3i(0, offset, 0), 1)
|
|
587
|
-
node_ijk[cell, 5] = _add_axis_flag(ijk + wp.vec3i(0, 0, offset), 2)
|
|
503
|
+
node_ijk[cell, 3] = NanogridBase._add_axis_flag(ijk + wp.vec3i(offset, 0, 0), 0)
|
|
504
|
+
node_ijk[cell, 4] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, offset, 0), 1)
|
|
505
|
+
node_ijk[cell, 5] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 0, offset), 2)
|
|
588
506
|
|
|
589
507
|
|
|
590
508
|
@wp.kernel
|
|
@@ -640,12 +558,12 @@ def _build_node_grid(cell_ijk, cell_level, cell_grid: wp.Volume, temporary_store
|
|
|
640
558
|
cell_nodes = cache.borrow_temporary(temporary_store, shape=(cell_count, 8), dtype=wp.vec3i, device=cell_ijk.device)
|
|
641
559
|
wp.launch(
|
|
642
560
|
_cell_node_indices,
|
|
643
|
-
dim=cell_nodes.
|
|
644
|
-
inputs=[cell_ijk, cell_level, cell_nodes
|
|
561
|
+
dim=cell_nodes.shape,
|
|
562
|
+
inputs=[cell_ijk, cell_level, cell_nodes],
|
|
645
563
|
device=cell_ijk.device,
|
|
646
564
|
)
|
|
647
565
|
node_grid = wp.Volume.allocate_by_voxels(
|
|
648
|
-
cell_nodes.
|
|
566
|
+
cell_nodes.flatten(), voxel_size=cell_grid.get_voxel_size()[0], device=cell_ijk.device
|
|
649
567
|
)
|
|
650
568
|
|
|
651
569
|
return node_grid
|
|
@@ -655,11 +573,9 @@ def _build_cell_face_grid(cell_ijk, cell_level, grid: wp.Volume, temporary_store
|
|
|
655
573
|
cell_count = cell_ijk.shape[0]
|
|
656
574
|
|
|
657
575
|
cell_faces = cache.borrow_temporary(temporary_store, shape=(cell_count, 6), dtype=wp.vec3i, device=cell_ijk.device)
|
|
658
|
-
wp.launch(
|
|
659
|
-
_cell_face_indices, dim=cell_count, inputs=[cell_ijk, cell_level, cell_faces.array], device=cell_ijk.device
|
|
660
|
-
)
|
|
576
|
+
wp.launch(_cell_face_indices, dim=cell_count, inputs=[cell_ijk, cell_level, cell_faces], device=cell_ijk.device)
|
|
661
577
|
face_grid = wp.Volume.allocate_by_voxels(
|
|
662
|
-
cell_faces.
|
|
578
|
+
cell_faces.flatten(), voxel_size=grid.get_voxel_size()[0], device=cell_ijk.device
|
|
663
579
|
)
|
|
664
580
|
|
|
665
581
|
return face_grid
|
|
@@ -680,8 +596,8 @@ def _build_completed_face_grid(
|
|
|
680
596
|
additional_face_count = cache.borrow_temporary(temporary_store, shape=1, dtype=int, device=device)
|
|
681
597
|
|
|
682
598
|
# Count the number of supplemental faces we need to add at resolution boundaries
|
|
683
|
-
cell_face_grid.get_voxels(out=cell_face_ijk
|
|
684
|
-
additional_face_count.
|
|
599
|
+
cell_face_grid.get_voxels(out=cell_face_ijk)
|
|
600
|
+
additional_face_count.zero_()
|
|
685
601
|
wp.launch(
|
|
686
602
|
_count_multires_faces,
|
|
687
603
|
dim=cell_face_count,
|
|
@@ -690,15 +606,15 @@ def _build_completed_face_grid(
|
|
|
690
606
|
cell_grid.id,
|
|
691
607
|
level_count,
|
|
692
608
|
cell_level,
|
|
693
|
-
cell_face_ijk
|
|
694
|
-
additional_face_count
|
|
609
|
+
cell_face_ijk,
|
|
610
|
+
additional_face_count,
|
|
695
611
|
],
|
|
696
612
|
)
|
|
697
613
|
|
|
698
614
|
# Cat these new faces with the original ones
|
|
699
|
-
cat_face_count = cell_face_count + int(additional_face_count.
|
|
615
|
+
cat_face_count = cell_face_count + int(additional_face_count.numpy()[0])
|
|
700
616
|
cat_face_ijk = cache.borrow_temporary(temporary_store, shape=(cat_face_count,), dtype=wp.vec3i, device=device)
|
|
701
|
-
wp.copy(src=cell_face_ijk
|
|
617
|
+
wp.copy(src=cell_face_ijk, dest=cat_face_ijk, dest_offset=cat_face_count - cell_face_count)
|
|
702
618
|
|
|
703
619
|
wp.launch(
|
|
704
620
|
_fill_multires_faces,
|
|
@@ -708,15 +624,15 @@ def _build_completed_face_grid(
|
|
|
708
624
|
cell_grid.id,
|
|
709
625
|
level_count,
|
|
710
626
|
cell_level,
|
|
711
|
-
cell_face_ijk
|
|
712
|
-
additional_face_count
|
|
713
|
-
cat_face_ijk
|
|
627
|
+
cell_face_ijk,
|
|
628
|
+
additional_face_count,
|
|
629
|
+
cat_face_ijk,
|
|
714
630
|
],
|
|
715
631
|
)
|
|
716
632
|
|
|
717
633
|
# Now recreate a new grid with all those faces
|
|
718
634
|
face_grid = wp.Volume.allocate_by_voxels(
|
|
719
|
-
cat_face_ijk.
|
|
635
|
+
cat_face_ijk.flatten(), voxel_size=cell_face_grid.get_voxel_size(), device=device
|
|
720
636
|
)
|
|
721
637
|
|
|
722
638
|
return face_grid
|
|
@@ -729,11 +645,11 @@ def _build_stacked_face_grid(cell_ijk, cell_level, grid: wp.Volume, temporary_st
|
|
|
729
645
|
wp.launch(
|
|
730
646
|
_cell_stacked_face_indices,
|
|
731
647
|
dim=cell_count,
|
|
732
|
-
inputs=[cell_ijk, cell_level, cell_faces
|
|
648
|
+
inputs=[cell_ijk, cell_level, cell_faces],
|
|
733
649
|
device=cell_ijk.device,
|
|
734
650
|
)
|
|
735
651
|
face_grid = wp.Volume.allocate_by_voxels(
|
|
736
|
-
cell_faces.
|
|
652
|
+
cell_faces.flatten(), voxel_size=grid.get_voxel_size()[0], device=cell_ijk.device
|
|
737
653
|
)
|
|
738
654
|
|
|
739
655
|
return face_grid
|
|
@@ -746,11 +662,11 @@ def _build_stacked_edge_grid(cell_ijk, cell_level, grid: wp.Volume, temporary_st
|
|
|
746
662
|
wp.launch(
|
|
747
663
|
_cell_stacked_edge_indices,
|
|
748
664
|
dim=cell_count,
|
|
749
|
-
inputs=[cell_ijk, cell_level, cell_edges
|
|
665
|
+
inputs=[cell_ijk, cell_level, cell_edges],
|
|
750
666
|
device=cell_ijk.device,
|
|
751
667
|
)
|
|
752
668
|
edge_grid = wp.Volume.allocate_by_voxels(
|
|
753
|
-
cell_edges.
|
|
669
|
+
cell_edges.flatten(), voxel_size=grid.get_voxel_size()[0], device=cell_ijk.device
|
|
754
670
|
)
|
|
755
671
|
|
|
756
672
|
return edge_grid
|
|
@@ -782,7 +698,7 @@ def _count_multires_faces(
|
|
|
782
698
|
):
|
|
783
699
|
face = wp.tid()
|
|
784
700
|
|
|
785
|
-
axis, ijk = _extract_axis_flag(face_ijk[face])
|
|
701
|
+
axis, ijk = NanogridBase._extract_axis_flag(face_ijk[face])
|
|
786
702
|
|
|
787
703
|
plus_cell_index, minus_cell_index = _find_face_neighbours(cell_grid, ijk, axis, level_count, cell_level)
|
|
788
704
|
|
|
@@ -809,7 +725,7 @@ def _fill_multires_faces(
|
|
|
809
725
|
):
|
|
810
726
|
face = wp.tid()
|
|
811
727
|
|
|
812
|
-
axis, ijk = _extract_axis_flag(face_ijk[face])
|
|
728
|
+
axis, ijk = NanogridBase._extract_axis_flag(face_ijk[face])
|
|
813
729
|
plus_cell_index, minus_cell_index = _find_face_neighbours(cell_grid, ijk, axis, level_count, cell_level)
|
|
814
730
|
|
|
815
731
|
if plus_cell_index == -1 or minus_cell_index == -1:
|
|
@@ -834,7 +750,7 @@ def _fill_multires_faces(
|
|
|
834
750
|
f_ijk = base_ijk
|
|
835
751
|
f_ijk[(axis + 1) % 3] |= (f & side_mask) << fine_level
|
|
836
752
|
f_ijk[(axis + 2) % 3] |= (f >> level_diff) << fine_level
|
|
837
|
-
added_ijk[offset + f] = _add_axis_flag(f_ijk, axis)
|
|
753
|
+
added_ijk[offset + f] = NanogridBase._add_axis_flag(f_ijk, axis)
|
|
838
754
|
|
|
839
755
|
|
|
840
756
|
@wp.kernel
|
|
@@ -849,7 +765,7 @@ def _build_face_indices_and_flags(
|
|
|
849
765
|
):
|
|
850
766
|
face = wp.tid()
|
|
851
767
|
|
|
852
|
-
axis, ijk = _extract_axis_flag(face_ijk[face])
|
|
768
|
+
axis, ijk = NanogridBase._extract_axis_flag(face_ijk[face])
|
|
853
769
|
|
|
854
770
|
plus_cell_index, minus_cell_index = _find_face_neighbours(cell_grid, ijk, axis, level_count, cell_level)
|
|
855
771
|
|
|
@@ -859,8 +775,8 @@ def _build_face_indices_and_flags(
|
|
|
859
775
|
face_level = wp.min(cell_level[inner_cell], cell_level[outer_cell])
|
|
860
776
|
|
|
861
777
|
face_ijk[face] = ijk
|
|
862
|
-
flags = _make_face_flags(axis, plus_cell_index, minus_cell_index) | (face_level << _FACE_LEVEL_BIT)
|
|
778
|
+
flags = NanogridBase._make_face_flags(axis, plus_cell_index, minus_cell_index) | (face_level << _FACE_LEVEL_BIT)
|
|
863
779
|
face_flags[face] = flags
|
|
864
|
-
boundary_face_mask[face] = _get_boundary_mask(flags)
|
|
780
|
+
boundary_face_mask[face] = NanogridBase._get_boundary_mask(flags)
|
|
865
781
|
|
|
866
782
|
face_cell_indices[face] = wp.vec2i(inner_cell, outer_cell)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import warp as wp
|
|
19
|
+
from warp._src.fem.types import Coords
|
|
20
|
+
|
|
21
|
+
_wp_module_name_ = "warp.fem.geometry.closest_point"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@wp.func
|
|
25
|
+
def project_on_seg_at_origin(q: Any, seg: Any, len_sq: float):
|
|
26
|
+
s = wp.clamp(wp.dot(q, seg) / len_sq, 0.0, 1.0)
|
|
27
|
+
return wp.length_sq(q - s * seg), s
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@wp.func
|
|
31
|
+
def project_on_tri_at_origin(q: Any, e1: Any, e2: Any):
|
|
32
|
+
e1e1 = wp.dot(e1, e1)
|
|
33
|
+
e1e2 = wp.dot(e1, e2)
|
|
34
|
+
e2e2 = wp.dot(e2, e2)
|
|
35
|
+
|
|
36
|
+
det = e1e1 * e2e2 - e1e2 * e1e2
|
|
37
|
+
|
|
38
|
+
if det > e1e1 * e2e2 * 1.0e-6:
|
|
39
|
+
e1p = wp.dot(e1, q)
|
|
40
|
+
e2p = wp.dot(e2, q)
|
|
41
|
+
|
|
42
|
+
s = (e2e2 * e1p - e1e2 * e2p) / det
|
|
43
|
+
t = (e1e1 * e2p - e1e2 * e1p) / det
|
|
44
|
+
|
|
45
|
+
if s >= 0.0 and t >= 0.0 and s + t <= 1.0:
|
|
46
|
+
# point inside triangle (distance can be non-zero in 3D case)
|
|
47
|
+
return wp.length_sq(q - s * e1 - t * e2), Coords(1.0 - s - t, s, t)
|
|
48
|
+
|
|
49
|
+
d1, s1 = project_on_seg_at_origin(q, e1, e1e1)
|
|
50
|
+
d2, s2 = project_on_seg_at_origin(q, e2, e2e2)
|
|
51
|
+
d12, s12 = project_on_seg_at_origin(q - e1, e2 - e1, wp.length_sq(e2 - e1))
|
|
52
|
+
|
|
53
|
+
if d1 <= d2:
|
|
54
|
+
if d1 <= d12:
|
|
55
|
+
return d1, Coords(1.0 - s1, s1, 0.0)
|
|
56
|
+
elif d2 <= d12:
|
|
57
|
+
return d2, Coords(1.0 - s2, 0.0, s2)
|
|
58
|
+
|
|
59
|
+
return d12, Coords(0.0, 1.0 - s12, s12)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@wp.func
|
|
63
|
+
def project_on_tet_at_origin(q: wp.vec3, e1: wp.vec3, e2: wp.vec3, e3: wp.vec3):
|
|
64
|
+
mat = wp.inverse(wp.matrix_from_cols(e1, e2, e3))
|
|
65
|
+
coords = mat * q
|
|
66
|
+
|
|
67
|
+
if wp.min(coords) >= 0.0 and coords[0] + coords[1] + coords[2] <= 1.0:
|
|
68
|
+
return 0.0, coords
|
|
69
|
+
|
|
70
|
+
# Not inside tet, compare closest point on each tri
|
|
71
|
+
|
|
72
|
+
d12, s12 = project_on_tri_at_origin(q, e1, e2)
|
|
73
|
+
d23, s23 = project_on_tri_at_origin(q, e2, e3)
|
|
74
|
+
d31, s31 = project_on_tri_at_origin(q, e3, e1)
|
|
75
|
+
d123, s123 = project_on_tri_at_origin(q - e1, e2 - e1, e3 - e1)
|
|
76
|
+
|
|
77
|
+
dmin = wp.min(wp.vec4(d12, d23, d31, d123))
|
|
78
|
+
|
|
79
|
+
if dmin == d12:
|
|
80
|
+
return dmin, Coords(s12[1], s12[2], 0.0)
|
|
81
|
+
elif dmin == d23:
|
|
82
|
+
return dmin, Coords(0.0, s23[1], s23[2])
|
|
83
|
+
elif dmin == d31:
|
|
84
|
+
return dmin, Coords(s31[2], 0.0, s31[1])
|
|
85
|
+
else:
|
|
86
|
+
return dmin, s123
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@wp.func
|
|
90
|
+
def project_on_box_at_origin(coords: wp.vec3, sizes: wp.vec3):
|
|
91
|
+
proj_coords = wp.min(wp.max(coords, wp.vec3(0.0)), sizes)
|
|
92
|
+
return wp.length_sq(coords - proj_coords), wp.cw_div(proj_coords, sizes)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@wp.func
|
|
96
|
+
def project_on_box_at_origin(coords: wp.vec2, sizes: wp.vec2):
|
|
97
|
+
proj_coords = wp.min(wp.max(coords, wp.vec2(0.0)), sizes)
|
|
98
|
+
norm_coords = wp.cw_div(proj_coords, sizes)
|
|
99
|
+
return wp.length_sq(coords - proj_coords), Coords(norm_coords[0], norm_coords[1], 0.0)
|