warp-lang 1.9.0__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 +2302 -307
- 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} +1546 -224
- 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 -471
- warp/codegen.py +6 -4246
- warp/constants.py +6 -39
- warp/context.py +12 -7851
- 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 +3 -2
- 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 -342
- warp/jax_experimental/ffi.py +17 -853
- warp/jax_experimental/xla_ffi.py +5 -596
- warp/marching_cubes.py +5 -689
- warp/math.py +16 -393
- warp/native/array.h +385 -37
- warp/native/builtin.h +316 -39
- 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/sort.cu +22 -13
- warp/native/sort.h +2 -0
- warp/native/sparse.cu +7 -3
- warp/native/spatial.h +12 -0
- warp/native/tile.h +837 -70
- 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 -53
- 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 +60 -32
- warp/native/warp.cu +581 -280
- warp/native/warp.h +14 -11
- 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 -3616
- warp/render/render_usd.py +6 -918
- 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_hash_grid.py +38 -0
- 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 +1382 -79
- 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 +580 -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 +34 -15
- 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 +60 -14
- 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 +49 -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_tuple.py +96 -0
- warp/tests/test_types.py +82 -9
- 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 +239 -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 -5750
- warp/utils.py +10 -1659
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0.dist-info}/METADATA +47 -103
- 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.0.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.0.dist-info → warp_lang-1.10.0.dist-info}/WHEEL +0 -0
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0.dist-info}/top_level.txt +0 -0
|
@@ -18,104 +18,74 @@ from typing import Any, Optional
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
|
|
20
20
|
import warp as wp
|
|
21
|
-
from warp.fem import cache, utils
|
|
22
|
-
from warp.fem.types import NULL_ELEMENT_INDEX, OUTSIDE, Coords, ElementIndex, Sample, make_free_sample
|
|
21
|
+
from warp._src.fem import cache, utils
|
|
22
|
+
from warp._src.fem.types import NULL_ELEMENT_INDEX, OUTSIDE, Coords, ElementIndex, Sample, make_free_sample
|
|
23
23
|
|
|
24
|
-
from .element import
|
|
24
|
+
from .element import Element
|
|
25
25
|
from .geometry import Geometry
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
# Morton indexing allows for
|
|
29
|
-
GRID_AXIS_FLAG = wp.constant(wp.int32(1 << 20))
|
|
27
|
+
_wp_module_name_ = "warp.fem.geometry.nanogrid"
|
|
30
28
|
|
|
31
|
-
FACE_AXIS_MASK = wp.constant(wp.uint8((1 << 2) - 1))
|
|
32
|
-
FACE_INNER_OFFSET_BIT = wp.constant(wp.uint8(2))
|
|
33
|
-
FACE_OUTER_OFFSET_BIT = wp.constant(wp.uint8(3))
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _add_axis_flag(ijk: wp.vec3i, axis: int):
|
|
38
|
-
coord = ijk[axis]
|
|
39
|
-
ijk[axis] = wp.where(coord < 0, coord & (~GRID_AXIS_FLAG), coord | GRID_AXIS_FLAG)
|
|
40
|
-
return ijk
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@wp.func
|
|
44
|
-
def _extract_axis_flag(ijk: wp.vec3i):
|
|
45
|
-
for ax in range(3):
|
|
46
|
-
coord = ijk[ax]
|
|
47
|
-
if coord < 0:
|
|
48
|
-
if (ijk[ax] & GRID_AXIS_FLAG) == 0:
|
|
49
|
-
ijk[ax] = ijk[ax] | GRID_AXIS_FLAG
|
|
50
|
-
return ax, ijk
|
|
51
|
-
else:
|
|
52
|
-
if (ijk[ax] & GRID_AXIS_FLAG) != 0:
|
|
53
|
-
ijk[ax] = ijk[ax] & (~GRID_AXIS_FLAG)
|
|
54
|
-
return ax, ijk
|
|
55
|
-
|
|
56
|
-
return -1, ijk
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@wp.struct
|
|
60
|
-
class NanogridCellArg:
|
|
61
|
-
# Utility device functions
|
|
62
|
-
cell_grid: wp.uint64
|
|
63
|
-
cell_ijk: wp.array(dtype=wp.vec3i)
|
|
64
|
-
inverse_transform: wp.mat33
|
|
65
|
-
cell_volume: float
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@wp.struct
|
|
69
|
-
class NanogridSideArg:
|
|
70
|
-
# Utility device functions
|
|
71
|
-
cell_arg: NanogridCellArg
|
|
72
|
-
face_ijk: wp.array(dtype=wp.vec3i)
|
|
73
|
-
face_flags: wp.array(dtype=wp.uint8)
|
|
74
|
-
face_areas: wp.vec3
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class Nanogrid(Geometry):
|
|
78
|
-
"""Sparse grid geometry"""
|
|
30
|
+
class NanogridBase(Geometry):
|
|
31
|
+
"""Base class for regular and adaptive Nanogrid"""
|
|
79
32
|
|
|
80
33
|
dimension = 3
|
|
81
34
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
35
|
+
# Flag used for building edge/face grids to disambiguiate axis within the grid
|
|
36
|
+
# Morton indexing allows for
|
|
37
|
+
GRID_AXIS_FLAG = wp.constant(wp.int32(1 << 20))
|
|
85
38
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
be created for all leaf voxels.
|
|
90
|
-
temporary_store: shared pool from which to allocate temporary arrays
|
|
91
|
-
"""
|
|
39
|
+
FACE_AXIS_MASK = wp.constant(wp.uint8((1 << 2) - 1))
|
|
40
|
+
FACE_INNER_OFFSET_BIT = wp.constant(wp.uint8(2))
|
|
41
|
+
FACE_OUTER_OFFSET_BIT = wp.constant(wp.uint8(3))
|
|
92
42
|
|
|
93
|
-
|
|
94
|
-
self
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
cell_grid: wp.Volume,
|
|
46
|
+
cell_ijk: wp.array(dtype=wp.vec3i),
|
|
47
|
+
node_grid: wp.Volume,
|
|
48
|
+
node_ijk: wp.array(dtype=wp.vec3i),
|
|
49
|
+
):
|
|
50
|
+
self._cell_grid = cell_grid
|
|
51
|
+
self._cell_ijk = cell_ijk
|
|
52
|
+
self._node_grid = node_grid
|
|
53
|
+
self._node_ijk = node_ijk
|
|
95
54
|
|
|
96
|
-
|
|
55
|
+
self._face_grid = None
|
|
56
|
+
self._face_ijk = None
|
|
57
|
+
self._boundary_face_indices = None
|
|
97
58
|
|
|
98
|
-
|
|
99
|
-
self.
|
|
100
|
-
grid.get_voxels(out=self._cell_ijk)
|
|
59
|
+
self._cell_grid_info = cell_grid.get_grid_info()
|
|
60
|
+
self._init_transform()
|
|
101
61
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
self._node_ijk = wp.array(shape=(node_count,), dtype=wp.vec3i, device=device)
|
|
105
|
-
self._node_grid.get_voxels(out=self._node_ijk)
|
|
62
|
+
def reference_cell(self) -> Element:
|
|
63
|
+
return Element.CUBE
|
|
106
64
|
|
|
107
|
-
|
|
108
|
-
|
|
65
|
+
def reference_side(self) -> Element:
|
|
66
|
+
return Element.SQUARE
|
|
109
67
|
|
|
110
|
-
|
|
111
|
-
self.
|
|
68
|
+
def _init_transform(self):
|
|
69
|
+
transform = np.array(self.transform).reshape(3, 3)
|
|
112
70
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
71
|
+
diag = np.diag(transform)
|
|
72
|
+
if np.max(np.abs(transform - np.diag(diag))) < 1.0e-6 * np.max(diag):
|
|
73
|
+
# Rectangular voxels
|
|
74
|
+
self._inverse_transform = wp.mat33f(
|
|
75
|
+
1.0 / diag[0], 0.0, 0.0, 0.0, 1.0 / diag[1], 0.0, 0.0, 0.0, 1.0 / diag[2]
|
|
76
|
+
)
|
|
77
|
+
self._cell_volume = wp.float32(diag[0] * diag[1] * diag[2])
|
|
78
|
+
self._face_areas = wp.vec3(diag[1] * diag[2], diag[2] * diag[0], diag[0] * diag[1])
|
|
79
|
+
else:
|
|
80
|
+
self._inverse_transform = wp.mat33f(np.linalg.inv(transform))
|
|
81
|
+
self._cell_volume = wp.float32(abs(np.linalg.det(transform)))
|
|
82
|
+
self._face_areas = wp.vec3(
|
|
83
|
+
tuple(np.linalg.norm(np.cross(transform[:, k - 2], transform[:, k - 1])) for k in range(3))
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def transform(self):
|
|
88
|
+
return self._cell_grid_info.transform_matrix
|
|
119
89
|
|
|
120
90
|
@property
|
|
121
91
|
def cell_grid(self) -> wp.Volume:
|
|
@@ -130,11 +100,6 @@ class Nanogrid(Geometry):
|
|
|
130
100
|
self._ensure_face_grid()
|
|
131
101
|
return self._face_grid
|
|
132
102
|
|
|
133
|
-
@property
|
|
134
|
-
def edge_grid(self) -> wp.Volume:
|
|
135
|
-
self._ensure_edge_grid()
|
|
136
|
-
return self._edge_grid
|
|
137
|
-
|
|
138
103
|
def cell_count(self):
|
|
139
104
|
return self._cell_ijk.shape[0]
|
|
140
105
|
|
|
@@ -149,77 +114,19 @@ class Nanogrid(Geometry):
|
|
|
149
114
|
self._ensure_face_grid()
|
|
150
115
|
return self._boundary_face_indices.shape[0]
|
|
151
116
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
def reference_cell(self) -> Cube:
|
|
157
|
-
return Cube()
|
|
158
|
-
|
|
159
|
-
def reference_side(self) -> Square:
|
|
160
|
-
return Square()
|
|
161
|
-
|
|
162
|
-
CellArg = NanogridCellArg
|
|
163
|
-
|
|
164
|
-
@cache.cached_arg_value
|
|
165
|
-
def cell_arg_value(self, device) -> CellArg:
|
|
166
|
-
args = self.CellArg()
|
|
167
|
-
self.fill_cell_arg(args, device)
|
|
168
|
-
return args
|
|
169
|
-
|
|
170
|
-
def fill_cell_arg(self, arg, device):
|
|
171
|
-
arg.cell_grid = self._cell_grid.id
|
|
172
|
-
arg.cell_ijk = self._cell_ijk
|
|
173
|
-
|
|
174
|
-
arg.inverse_transform = self._inverse_transform
|
|
175
|
-
arg.cell_volume = self._cell_volume
|
|
176
|
-
|
|
177
|
-
@wp.func
|
|
178
|
-
def cell_position(args: CellArg, s: Sample):
|
|
179
|
-
uvw = wp.vec3(args.cell_ijk[s.element_index]) + s.element_coords
|
|
180
|
-
return wp.volume_index_to_world(args.cell_grid, uvw - wp.vec3(0.5))
|
|
181
|
-
|
|
182
|
-
@wp.func
|
|
183
|
-
def cell_deformation_gradient(args: CellArg, s: Sample):
|
|
184
|
-
return wp.inverse(args.inverse_transform)
|
|
185
|
-
|
|
186
|
-
@wp.func
|
|
187
|
-
def cell_inverse_deformation_gradient(args: CellArg, s: Sample):
|
|
188
|
-
return args.inverse_transform
|
|
189
|
-
|
|
190
|
-
def supports_cell_lookup(self, device):
|
|
191
|
-
return True
|
|
192
|
-
|
|
193
|
-
@wp.func
|
|
194
|
-
def _lookup_cell_index(args: NanogridCellArg, i: int, j: int, k: int):
|
|
195
|
-
return wp.volume_lookup_index(args.cell_grid, i, j, k)
|
|
196
|
-
|
|
197
|
-
@wp.func
|
|
198
|
-
def _cell_coordinates_local(args: NanogridCellArg, cell_index: int, uvw: wp.vec3):
|
|
199
|
-
ijk = wp.vec3(args.cell_ijk[cell_index])
|
|
200
|
-
rel_pos = uvw - ijk
|
|
201
|
-
return rel_pos
|
|
202
|
-
|
|
203
|
-
@wp.func
|
|
204
|
-
def _cell_closest_point_local(args: NanogridCellArg, cell_index: int, uvw: wp.vec3):
|
|
205
|
-
ijk = wp.vec3(args.cell_ijk[cell_index])
|
|
206
|
-
rel_pos = uvw - ijk
|
|
207
|
-
coords = wp.min(wp.max(rel_pos, wp.vec3(0.0)), wp.vec3(1.0))
|
|
208
|
-
return wp.length_sq(wp.volume_index_to_world_dir(args.cell_grid, coords - rel_pos)), coords
|
|
117
|
+
@wp.struct
|
|
118
|
+
class SideIndexArg:
|
|
119
|
+
boundary_face_indices: wp.array(dtype=int)
|
|
209
120
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return Nanogrid._cell_coordinates_local(args, cell_index, uvw)
|
|
121
|
+
def fill_side_index_arg(self, arg: SideIndexArg, device):
|
|
122
|
+
self._ensure_face_grid()
|
|
123
|
+
arg.boundary_face_indices = self._boundary_face_indices.to(device)
|
|
214
124
|
|
|
215
125
|
@wp.func
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
dist, coords = Nanogrid._cell_closest_point_local(args, cell_index, uvw)
|
|
219
|
-
return coords, dist
|
|
126
|
+
def boundary_side_index(args: SideIndexArg, boundary_side_index: int):
|
|
127
|
+
return args.boundary_face_indices[boundary_side_index]
|
|
220
128
|
|
|
221
|
-
|
|
222
|
-
def _make_filtered_cell_lookup(grid_geo, filter_func: wp.Function = None):
|
|
129
|
+
def make_filtered_cell_lookup(grid_geo, filter_func: wp.Function = None):
|
|
223
130
|
suffix = f"{grid_geo.name}{filter_func.key if filter_func is not None else ''}"
|
|
224
131
|
|
|
225
132
|
@cache.dynamic_func(suffix=suffix)
|
|
@@ -285,49 +192,53 @@ class Nanogrid(Geometry):
|
|
|
285
192
|
|
|
286
193
|
return cell_lookup
|
|
287
194
|
|
|
288
|
-
def
|
|
289
|
-
|
|
195
|
+
def _ensure_face_grid(self):
|
|
196
|
+
if self._face_ijk is None:
|
|
197
|
+
self._build_face_grid()
|
|
290
198
|
|
|
291
199
|
@wp.func
|
|
292
|
-
def
|
|
293
|
-
|
|
200
|
+
def _add_axis_flag(ijk: wp.vec3i, axis: int):
|
|
201
|
+
coord = ijk[axis]
|
|
202
|
+
ijk[axis] = wp.where(coord < 0, coord & (~NanogridBase.GRID_AXIS_FLAG), coord | NanogridBase.GRID_AXIS_FLAG)
|
|
203
|
+
return ijk
|
|
294
204
|
|
|
295
205
|
@wp.func
|
|
296
|
-
def
|
|
297
|
-
|
|
206
|
+
def _extract_axis_flag(ijk: wp.vec3i):
|
|
207
|
+
for ax in range(3):
|
|
208
|
+
coord = ijk[ax]
|
|
209
|
+
if coord < 0:
|
|
210
|
+
if (ijk[ax] & NanogridBase.GRID_AXIS_FLAG) == 0:
|
|
211
|
+
ijk[ax] = ijk[ax] | NanogridBase.GRID_AXIS_FLAG
|
|
212
|
+
return ax, ijk
|
|
213
|
+
else:
|
|
214
|
+
if (ijk[ax] & NanogridBase.GRID_AXIS_FLAG) != 0:
|
|
215
|
+
ijk[ax] = ijk[ax] & (~NanogridBase.GRID_AXIS_FLAG)
|
|
216
|
+
return ax, ijk
|
|
298
217
|
|
|
299
|
-
|
|
218
|
+
return -1, ijk
|
|
300
219
|
|
|
301
|
-
@
|
|
302
|
-
def
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return args
|
|
220
|
+
@wp.func
|
|
221
|
+
def _make_face_flags(axis: int, plus_cell_index: int, minus_cell_index: int):
|
|
222
|
+
plus_boundary = wp.uint8(wp.where(plus_cell_index == -1, 1, 0)) << NanogridBase.FACE_OUTER_OFFSET_BIT
|
|
223
|
+
minus_boundary = wp.uint8(wp.where(minus_cell_index == -1, 1, 0)) << NanogridBase.FACE_INNER_OFFSET_BIT
|
|
306
224
|
|
|
307
|
-
|
|
308
|
-
self._ensure_face_grid()
|
|
309
|
-
self.fill_cell_arg(arg.cell_arg, device)
|
|
310
|
-
arg.face_ijk = self._face_ijk.to(device)
|
|
311
|
-
arg.face_flags = self._face_flags.to(device)
|
|
312
|
-
arg.face_areas = self._face_areas
|
|
225
|
+
return wp.uint8(axis) | plus_boundary | minus_boundary
|
|
313
226
|
|
|
314
|
-
@wp.
|
|
315
|
-
|
|
316
|
-
|
|
227
|
+
@wp.func
|
|
228
|
+
def _get_boundary_mask(flags: wp.uint8):
|
|
229
|
+
return int((flags >> NanogridBase.FACE_OUTER_OFFSET_BIT) | (flags >> NanogridBase.FACE_INNER_OFFSET_BIT)) & 1
|
|
317
230
|
|
|
318
|
-
@
|
|
319
|
-
def
|
|
320
|
-
|
|
321
|
-
self.fill_side_index_arg(args, device)
|
|
322
|
-
return args
|
|
231
|
+
@wp.func
|
|
232
|
+
def _get_face_axis(flags: wp.uint8):
|
|
233
|
+
return wp.int32(flags & NanogridBase.FACE_AXIS_MASK)
|
|
323
234
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
235
|
+
@wp.func
|
|
236
|
+
def _get_face_inner_offset(flags: wp.uint8):
|
|
237
|
+
return wp.int32(flags >> NanogridBase.FACE_INNER_OFFSET_BIT) & 1
|
|
327
238
|
|
|
328
239
|
@wp.func
|
|
329
|
-
def
|
|
330
|
-
return
|
|
240
|
+
def _get_face_outer_offset(flags: wp.uint8):
|
|
241
|
+
return wp.int32(flags >> NanogridBase.FACE_OUTER_OFFSET_BIT) & 1
|
|
331
242
|
|
|
332
243
|
@wp.func
|
|
333
244
|
def _side_to_cell_coords(axis: int, flip: int, inner: float, side_coords: Coords):
|
|
@@ -342,16 +253,141 @@ class Nanogrid(Geometry):
|
|
|
342
253
|
return Coords(cell_coords[(axis + 1 + flip) % 3], cell_coords[(axis + 2 - flip) % 3], 0.0)
|
|
343
254
|
|
|
344
255
|
@wp.func
|
|
345
|
-
def
|
|
346
|
-
|
|
256
|
+
def _face_tangent_vecs(cell_grid: wp.uint64, axis: int, flip: int):
|
|
257
|
+
u_axis = wp.vec3()
|
|
258
|
+
v_axis = wp.vec3()
|
|
259
|
+
u_axis[(axis + 1 + flip) % 3] = 1.0
|
|
260
|
+
v_axis[(axis + 2 - flip) % 3] = 1.0
|
|
261
|
+
return wp.volume_index_to_world_dir(cell_grid, u_axis), wp.volume_index_to_world_dir(cell_grid, v_axis)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@wp.struct
|
|
265
|
+
class NanogridCellArg:
|
|
266
|
+
# Utility device functions
|
|
267
|
+
cell_grid: wp.uint64
|
|
268
|
+
cell_ijk: wp.array(dtype=wp.vec3i)
|
|
269
|
+
inverse_transform: wp.mat33
|
|
270
|
+
cell_volume: float
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@wp.struct
|
|
274
|
+
class NanogridSideArg:
|
|
275
|
+
# Utility device functions
|
|
276
|
+
cell_arg: NanogridCellArg
|
|
277
|
+
face_ijk: wp.array(dtype=wp.vec3i)
|
|
278
|
+
face_flags: wp.array(dtype=wp.uint8)
|
|
279
|
+
face_areas: wp.vec3
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class Nanogrid(NanogridBase):
|
|
283
|
+
"""Sparse grid geometry"""
|
|
284
|
+
|
|
285
|
+
def __init__(self, grid: wp.Volume, temporary_store: Optional[cache.TemporaryStore] = None):
|
|
286
|
+
"""
|
|
287
|
+
Constructs a sparse grid geometry from an in-memory NanoVDB volume.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
grid: The NanoVDB volume. Any type is accepted, but for indexing efficiency an index grid is recommended.
|
|
291
|
+
If `grid` is an 'on' index grid, cells will be created for active voxels only, otherwise cells will
|
|
292
|
+
be created for all leaf voxels.
|
|
293
|
+
temporary_store: shared pool from which to allocate temporary arrays
|
|
294
|
+
"""
|
|
295
|
+
|
|
296
|
+
self._cell_grid = grid
|
|
297
|
+
self._cell_grid_info = grid.get_grid_info()
|
|
298
|
+
|
|
299
|
+
device = self._cell_grid.device
|
|
300
|
+
cell_ijk = wp.array(dtype=wp.vec3i, shape=(grid.get_voxel_count(),), device=device)
|
|
301
|
+
grid.get_voxels(out=cell_ijk)
|
|
302
|
+
|
|
303
|
+
node_grid = _build_node_grid(cell_ijk, grid, temporary_store)
|
|
304
|
+
node_count = node_grid.get_voxel_count()
|
|
305
|
+
node_ijk = wp.array(shape=(node_count,), dtype=wp.vec3i, device=device)
|
|
306
|
+
node_grid.get_voxels(out=node_ijk)
|
|
307
|
+
|
|
308
|
+
super().__init__(grid, cell_ijk, node_grid, node_ijk)
|
|
309
|
+
|
|
310
|
+
self._edge_count = 0
|
|
311
|
+
self._edge_grid = None
|
|
312
|
+
|
|
313
|
+
@property
|
|
314
|
+
def edge_grid(self) -> wp.Volume:
|
|
315
|
+
self._ensure_edge_grid()
|
|
316
|
+
return self._edge_grid
|
|
317
|
+
|
|
318
|
+
def edge_count(self):
|
|
319
|
+
self._ensure_edge_grid()
|
|
320
|
+
return self._edge_count
|
|
321
|
+
|
|
322
|
+
CellArg = NanogridCellArg
|
|
323
|
+
|
|
324
|
+
def fill_cell_arg(self, arg, device):
|
|
325
|
+
arg.cell_grid = self._cell_grid.id
|
|
326
|
+
arg.cell_ijk = self._cell_ijk
|
|
327
|
+
|
|
328
|
+
arg.inverse_transform = self._inverse_transform
|
|
329
|
+
arg.cell_volume = self._cell_volume
|
|
347
330
|
|
|
348
331
|
@wp.func
|
|
349
|
-
def
|
|
350
|
-
|
|
332
|
+
def cell_position(args: CellArg, s: Sample):
|
|
333
|
+
uvw = wp.vec3(args.cell_ijk[s.element_index]) + s.element_coords
|
|
334
|
+
return wp.volume_index_to_world(args.cell_grid, uvw - wp.vec3(0.5))
|
|
351
335
|
|
|
352
336
|
@wp.func
|
|
353
|
-
def
|
|
354
|
-
return wp.
|
|
337
|
+
def cell_deformation_gradient(args: CellArg, s: Sample):
|
|
338
|
+
return wp.inverse(args.inverse_transform)
|
|
339
|
+
|
|
340
|
+
@wp.func
|
|
341
|
+
def cell_inverse_deformation_gradient(args: CellArg, s: Sample):
|
|
342
|
+
return args.inverse_transform
|
|
343
|
+
|
|
344
|
+
def supports_cell_lookup(self, device):
|
|
345
|
+
return True
|
|
346
|
+
|
|
347
|
+
@wp.func
|
|
348
|
+
def _lookup_cell_index(args: NanogridCellArg, i: int, j: int, k: int):
|
|
349
|
+
return wp.volume_lookup_index(args.cell_grid, i, j, k)
|
|
350
|
+
|
|
351
|
+
@wp.func
|
|
352
|
+
def _cell_coordinates_local(args: NanogridCellArg, cell_index: int, uvw: wp.vec3):
|
|
353
|
+
ijk = wp.vec3(args.cell_ijk[cell_index])
|
|
354
|
+
rel_pos = uvw - ijk
|
|
355
|
+
return rel_pos
|
|
356
|
+
|
|
357
|
+
@wp.func
|
|
358
|
+
def _cell_closest_point_local(args: NanogridCellArg, cell_index: int, uvw: wp.vec3):
|
|
359
|
+
ijk = wp.vec3(args.cell_ijk[cell_index])
|
|
360
|
+
rel_pos = uvw - ijk
|
|
361
|
+
coords = wp.min(wp.max(rel_pos, wp.vec3(0.0)), wp.vec3(1.0))
|
|
362
|
+
return wp.length_sq(wp.volume_index_to_world_dir(args.cell_grid, coords - rel_pos)), coords
|
|
363
|
+
|
|
364
|
+
@wp.func
|
|
365
|
+
def cell_coordinates(args: NanogridCellArg, cell_index: int, pos: wp.vec3):
|
|
366
|
+
uvw = wp.volume_world_to_index(args.cell_grid, pos) + wp.vec3(0.5)
|
|
367
|
+
return Nanogrid._cell_coordinates_local(args, cell_index, uvw)
|
|
368
|
+
|
|
369
|
+
@wp.func
|
|
370
|
+
def cell_closest_point(args: NanogridCellArg, cell_index: int, pos: wp.vec3):
|
|
371
|
+
uvw = wp.volume_world_to_index(args.cell_grid, pos) + wp.vec3(0.5)
|
|
372
|
+
dist, coords = Nanogrid._cell_closest_point_local(args, cell_index, uvw)
|
|
373
|
+
return coords, dist
|
|
374
|
+
|
|
375
|
+
@wp.func
|
|
376
|
+
def cell_measure(args: CellArg, s: Sample):
|
|
377
|
+
return args.cell_volume
|
|
378
|
+
|
|
379
|
+
@wp.func
|
|
380
|
+
def cell_normal(args: CellArg, s: Sample):
|
|
381
|
+
return wp.vec3(0.0)
|
|
382
|
+
|
|
383
|
+
SideArg = NanogridSideArg
|
|
384
|
+
|
|
385
|
+
def fill_side_arg(self, arg: SideArg, device):
|
|
386
|
+
self._ensure_face_grid()
|
|
387
|
+
self.fill_cell_arg(arg.cell_arg, device)
|
|
388
|
+
arg.face_ijk = self._face_ijk.to(device)
|
|
389
|
+
arg.face_flags = self._face_flags.to(device)
|
|
390
|
+
arg.face_areas = self._face_areas
|
|
355
391
|
|
|
356
392
|
@wp.func
|
|
357
393
|
def side_position(args: SideArg, s: Sample):
|
|
@@ -365,14 +401,6 @@ class Nanogrid(Geometry):
|
|
|
365
401
|
cell_grid = args.cell_arg.cell_grid
|
|
366
402
|
return wp.volume_index_to_world(cell_grid, uvw - wp.vec3(0.5))
|
|
367
403
|
|
|
368
|
-
@wp.func
|
|
369
|
-
def _face_tangent_vecs(cell_grid: wp.uint64, axis: int, flip: int):
|
|
370
|
-
u_axis = wp.vec3()
|
|
371
|
-
v_axis = wp.vec3()
|
|
372
|
-
u_axis[(axis + 1 + flip) % 3] = 1.0
|
|
373
|
-
v_axis[(axis + 2 - flip) % 3] = 1.0
|
|
374
|
-
return wp.volume_index_to_world_dir(cell_grid, u_axis), wp.volume_index_to_world_dir(cell_grid, v_axis)
|
|
375
|
-
|
|
376
404
|
@wp.func
|
|
377
405
|
def side_deformation_gradient(args: SideArg, s: Sample):
|
|
378
406
|
flags = args.face_flags[s.element_index]
|
|
@@ -509,19 +537,15 @@ class Nanogrid(Geometry):
|
|
|
509
537
|
_build_face_flags,
|
|
510
538
|
dim=face_count,
|
|
511
539
|
device=device,
|
|
512
|
-
inputs=[self._cell_grid.id, self._face_ijk, self._face_flags, boundary_face_mask
|
|
540
|
+
inputs=[self._cell_grid.id, self._face_ijk, self._face_flags, boundary_face_mask],
|
|
513
541
|
)
|
|
514
|
-
boundary_face_indices, _ = utils.masked_indices(boundary_face_mask
|
|
542
|
+
boundary_face_indices, _ = utils.masked_indices(boundary_face_mask)
|
|
515
543
|
self._boundary_face_indices = boundary_face_indices.detach()
|
|
516
544
|
|
|
517
545
|
def _build_edge_grid(self, temporary_store: Optional[cache.TemporaryStore] = None):
|
|
518
546
|
self._edge_grid = _build_edge_grid(self._cell_ijk, self._cell_grid, temporary_store)
|
|
519
547
|
self._edge_count = self._edge_grid.get_voxel_count()
|
|
520
548
|
|
|
521
|
-
def _ensure_face_grid(self):
|
|
522
|
-
if self._face_ijk is None:
|
|
523
|
-
self._build_face_grid()
|
|
524
|
-
|
|
525
549
|
def _ensure_edge_grid(self):
|
|
526
550
|
if self._edge_grid is None:
|
|
527
551
|
self._build_edge_grid()
|
|
@@ -543,13 +567,13 @@ def _cell_face_indices(
|
|
|
543
567
|
):
|
|
544
568
|
cell = wp.tid()
|
|
545
569
|
ijk = cell_ijk[cell]
|
|
546
|
-
node_ijk[cell, 0] = _add_axis_flag(ijk, 0)
|
|
547
|
-
node_ijk[cell, 1] = _add_axis_flag(ijk, 1)
|
|
548
|
-
node_ijk[cell, 2] = _add_axis_flag(ijk, 2)
|
|
570
|
+
node_ijk[cell, 0] = NanogridBase._add_axis_flag(ijk, 0)
|
|
571
|
+
node_ijk[cell, 1] = NanogridBase._add_axis_flag(ijk, 1)
|
|
572
|
+
node_ijk[cell, 2] = NanogridBase._add_axis_flag(ijk, 2)
|
|
549
573
|
|
|
550
|
-
node_ijk[cell, 3] = _add_axis_flag(ijk + wp.vec3i(1, 0, 0), 0)
|
|
551
|
-
node_ijk[cell, 4] = _add_axis_flag(ijk + wp.vec3i(0, 1, 0), 1)
|
|
552
|
-
node_ijk[cell, 5] = _add_axis_flag(ijk + wp.vec3i(0, 0, 1), 2)
|
|
574
|
+
node_ijk[cell, 3] = NanogridBase._add_axis_flag(ijk + wp.vec3i(1, 0, 0), 0)
|
|
575
|
+
node_ijk[cell, 4] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 1, 0), 1)
|
|
576
|
+
node_ijk[cell, 5] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 0, 1), 2)
|
|
553
577
|
|
|
554
578
|
|
|
555
579
|
@wp.kernel
|
|
@@ -559,32 +583,30 @@ def _cell_edge_indices(
|
|
|
559
583
|
):
|
|
560
584
|
cell = wp.tid()
|
|
561
585
|
ijk = cell_ijk[cell]
|
|
562
|
-
edge_ijk[cell, 0] = _add_axis_flag(ijk, 0)
|
|
563
|
-
edge_ijk[cell, 1] = _add_axis_flag(ijk, 1)
|
|
564
|
-
edge_ijk[cell, 2] = _add_axis_flag(ijk, 2)
|
|
586
|
+
edge_ijk[cell, 0] = NanogridBase._add_axis_flag(ijk, 0)
|
|
587
|
+
edge_ijk[cell, 1] = NanogridBase._add_axis_flag(ijk, 1)
|
|
588
|
+
edge_ijk[cell, 2] = NanogridBase._add_axis_flag(ijk, 2)
|
|
565
589
|
|
|
566
|
-
edge_ijk[cell, 3] = _add_axis_flag(ijk + wp.vec3i(0, 1, 0), 0)
|
|
567
|
-
edge_ijk[cell, 4] = _add_axis_flag(ijk + wp.vec3i(0, 0, 1), 1)
|
|
568
|
-
edge_ijk[cell, 5] = _add_axis_flag(ijk + wp.vec3i(1, 0, 0), 2)
|
|
590
|
+
edge_ijk[cell, 3] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 1, 0), 0)
|
|
591
|
+
edge_ijk[cell, 4] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 0, 1), 1)
|
|
592
|
+
edge_ijk[cell, 5] = NanogridBase._add_axis_flag(ijk + wp.vec3i(1, 0, 0), 2)
|
|
569
593
|
|
|
570
|
-
edge_ijk[cell, 6] = _add_axis_flag(ijk + wp.vec3i(0, 1, 1), 0)
|
|
571
|
-
edge_ijk[cell, 7] = _add_axis_flag(ijk + wp.vec3i(1, 0, 1), 1)
|
|
572
|
-
edge_ijk[cell, 8] = _add_axis_flag(ijk + wp.vec3i(1, 1, 0), 2)
|
|
594
|
+
edge_ijk[cell, 6] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 1, 1), 0)
|
|
595
|
+
edge_ijk[cell, 7] = NanogridBase._add_axis_flag(ijk + wp.vec3i(1, 0, 1), 1)
|
|
596
|
+
edge_ijk[cell, 8] = NanogridBase._add_axis_flag(ijk + wp.vec3i(1, 1, 0), 2)
|
|
573
597
|
|
|
574
|
-
edge_ijk[cell, 9] = _add_axis_flag(ijk + wp.vec3i(0, 0, 1), 0)
|
|
575
|
-
edge_ijk[cell, 10] = _add_axis_flag(ijk + wp.vec3i(1, 0, 0), 1)
|
|
576
|
-
edge_ijk[cell, 11] = _add_axis_flag(ijk + wp.vec3i(0, 1, 0), 2)
|
|
598
|
+
edge_ijk[cell, 9] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 0, 1), 0)
|
|
599
|
+
edge_ijk[cell, 10] = NanogridBase._add_axis_flag(ijk + wp.vec3i(1, 0, 0), 1)
|
|
600
|
+
edge_ijk[cell, 11] = NanogridBase._add_axis_flag(ijk + wp.vec3i(0, 1, 0), 2)
|
|
577
601
|
|
|
578
602
|
|
|
579
603
|
def _build_node_grid(cell_ijk, grid: wp.Volume, temporary_store: cache.TemporaryStore):
|
|
580
604
|
cell_count = cell_ijk.shape[0]
|
|
581
605
|
|
|
582
606
|
cell_nodes = cache.borrow_temporary(temporary_store, shape=(cell_count, 8), dtype=wp.vec3i, device=cell_ijk.device)
|
|
583
|
-
wp.launch(
|
|
584
|
-
_cell_node_indices, dim=cell_nodes.array.shape, inputs=[cell_ijk, cell_nodes.array], device=cell_ijk.device
|
|
585
|
-
)
|
|
607
|
+
wp.launch(_cell_node_indices, dim=cell_nodes.shape, inputs=[cell_ijk, cell_nodes], device=cell_ijk.device)
|
|
586
608
|
node_grid = wp.Volume.allocate_by_voxels(
|
|
587
|
-
cell_nodes.
|
|
609
|
+
cell_nodes.flatten(), voxel_size=grid.get_voxel_size(), device=cell_ijk.device
|
|
588
610
|
)
|
|
589
611
|
|
|
590
612
|
return node_grid
|
|
@@ -594,9 +616,9 @@ def _build_face_grid(cell_ijk, grid: wp.Volume, temporary_store: cache.Temporary
|
|
|
594
616
|
cell_count = cell_ijk.shape[0]
|
|
595
617
|
|
|
596
618
|
cell_faces = cache.borrow_temporary(temporary_store, shape=(cell_count, 6), dtype=wp.vec3i, device=cell_ijk.device)
|
|
597
|
-
wp.launch(_cell_face_indices, dim=cell_count, inputs=[cell_ijk, cell_faces
|
|
619
|
+
wp.launch(_cell_face_indices, dim=cell_count, inputs=[cell_ijk, cell_faces], device=cell_ijk.device)
|
|
598
620
|
face_grid = wp.Volume.allocate_by_voxels(
|
|
599
|
-
cell_faces.
|
|
621
|
+
cell_faces.flatten(), voxel_size=grid.get_voxel_size(), device=cell_ijk.device
|
|
600
622
|
)
|
|
601
623
|
|
|
602
624
|
return face_grid
|
|
@@ -606,27 +628,14 @@ def _build_edge_grid(cell_ijk, grid: wp.Volume, temporary_store: cache.Temporary
|
|
|
606
628
|
cell_count = cell_ijk.shape[0]
|
|
607
629
|
|
|
608
630
|
cell_edges = cache.borrow_temporary(temporary_store, shape=(cell_count, 12), dtype=wp.vec3i, device=cell_ijk.device)
|
|
609
|
-
wp.launch(_cell_edge_indices, dim=cell_count, inputs=[cell_ijk, cell_edges
|
|
631
|
+
wp.launch(_cell_edge_indices, dim=cell_count, inputs=[cell_ijk, cell_edges], device=cell_ijk.device)
|
|
610
632
|
edge_grid = wp.Volume.allocate_by_voxels(
|
|
611
|
-
cell_edges.
|
|
633
|
+
cell_edges.flatten(), voxel_size=grid.get_voxel_size(), device=cell_ijk.device
|
|
612
634
|
)
|
|
613
635
|
|
|
614
636
|
return edge_grid
|
|
615
637
|
|
|
616
638
|
|
|
617
|
-
@wp.func
|
|
618
|
-
def _make_face_flags(axis: int, plus_cell_index: int, minus_cell_index: int):
|
|
619
|
-
plus_boundary = wp.uint8(wp.where(plus_cell_index == -1, 1, 0)) << FACE_OUTER_OFFSET_BIT
|
|
620
|
-
minus_boundary = wp.uint8(wp.where(minus_cell_index == -1, 1, 0)) << FACE_INNER_OFFSET_BIT
|
|
621
|
-
|
|
622
|
-
return wp.uint8(axis) | plus_boundary | minus_boundary
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
@wp.func
|
|
626
|
-
def _get_boundary_mask(flags: wp.uint8):
|
|
627
|
-
return int((flags >> FACE_OUTER_OFFSET_BIT) | (flags >> FACE_INNER_OFFSET_BIT)) & 1
|
|
628
|
-
|
|
629
|
-
|
|
630
639
|
@wp.kernel
|
|
631
640
|
def _build_face_flags(
|
|
632
641
|
cell_grid: wp.uint64,
|
|
@@ -636,7 +645,7 @@ def _build_face_flags(
|
|
|
636
645
|
):
|
|
637
646
|
face = wp.tid()
|
|
638
647
|
|
|
639
|
-
axis, ijk = _extract_axis_flag(face_ijk[face])
|
|
648
|
+
axis, ijk = NanogridBase._extract_axis_flag(face_ijk[face])
|
|
640
649
|
|
|
641
650
|
ijk_minus = ijk
|
|
642
651
|
ijk_minus[axis] -= 1
|
|
@@ -646,6 +655,6 @@ def _build_face_flags(
|
|
|
646
655
|
|
|
647
656
|
face_ijk[face] = ijk
|
|
648
657
|
|
|
649
|
-
flags = _make_face_flags(axis, plus_cell_index, minus_cell_index)
|
|
658
|
+
flags = NanogridBase._make_face_flags(axis, plus_cell_index, minus_cell_index)
|
|
650
659
|
face_flags[face] = flags
|
|
651
|
-
boundary_face_mask[face] = _get_boundary_mask(flags)
|
|
660
|
+
boundary_face_mask[face] = NanogridBase._get_boundary_mask(flags)
|