warp-lang 0.9.0__py3-none-win_amd64.whl → 0.11.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +15 -7
- warp/__init__.pyi +1 -0
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +22 -443
- warp/build_dll.py +384 -0
- warp/builtins.py +998 -488
- warp/codegen.py +1307 -739
- warp/config.py +5 -3
- warp/constants.py +6 -0
- warp/context.py +1291 -548
- warp/dlpack.py +31 -31
- warp/fabric.py +326 -0
- warp/fem/__init__.py +27 -0
- warp/fem/cache.py +389 -0
- warp/fem/dirichlet.py +181 -0
- warp/fem/domain.py +263 -0
- warp/fem/field/__init__.py +101 -0
- warp/fem/field/field.py +149 -0
- warp/fem/field/nodal_field.py +299 -0
- warp/fem/field/restriction.py +21 -0
- warp/fem/field/test.py +181 -0
- warp/fem/field/trial.py +183 -0
- warp/fem/geometry/__init__.py +19 -0
- warp/fem/geometry/closest_point.py +70 -0
- warp/fem/geometry/deformed_geometry.py +271 -0
- warp/fem/geometry/element.py +744 -0
- warp/fem/geometry/geometry.py +186 -0
- warp/fem/geometry/grid_2d.py +373 -0
- warp/fem/geometry/grid_3d.py +435 -0
- warp/fem/geometry/hexmesh.py +953 -0
- warp/fem/geometry/partition.py +376 -0
- warp/fem/geometry/quadmesh_2d.py +532 -0
- warp/fem/geometry/tetmesh.py +840 -0
- warp/fem/geometry/trimesh_2d.py +577 -0
- warp/fem/integrate.py +1616 -0
- warp/fem/operator.py +191 -0
- warp/fem/polynomial.py +213 -0
- warp/fem/quadrature/__init__.py +2 -0
- warp/fem/quadrature/pic_quadrature.py +245 -0
- warp/fem/quadrature/quadrature.py +294 -0
- warp/fem/space/__init__.py +292 -0
- warp/fem/space/basis_space.py +489 -0
- warp/fem/space/collocated_function_space.py +105 -0
- warp/fem/space/dof_mapper.py +236 -0
- warp/fem/space/function_space.py +145 -0
- warp/fem/space/grid_2d_function_space.py +267 -0
- warp/fem/space/grid_3d_function_space.py +306 -0
- warp/fem/space/hexmesh_function_space.py +352 -0
- warp/fem/space/partition.py +350 -0
- warp/fem/space/quadmesh_2d_function_space.py +369 -0
- warp/fem/space/restriction.py +160 -0
- warp/fem/space/shape/__init__.py +15 -0
- warp/fem/space/shape/cube_shape_function.py +738 -0
- warp/fem/space/shape/shape_function.py +103 -0
- warp/fem/space/shape/square_shape_function.py +611 -0
- warp/fem/space/shape/tet_shape_function.py +567 -0
- warp/fem/space/shape/triangle_shape_function.py +429 -0
- warp/fem/space/tetmesh_function_space.py +292 -0
- warp/fem/space/topology.py +295 -0
- warp/fem/space/trimesh_2d_function_space.py +221 -0
- warp/fem/types.py +77 -0
- warp/fem/utils.py +495 -0
- warp/native/array.h +164 -55
- warp/native/builtin.h +150 -174
- warp/native/bvh.cpp +75 -328
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +37 -45
- warp/native/clang/clang.cpp +136 -24
- warp/native/crt.cpp +1 -76
- warp/native/crt.h +111 -104
- warp/native/cuda_crt.h +1049 -0
- warp/native/cuda_util.cpp +15 -3
- warp/native/cuda_util.h +3 -1
- warp/native/cutlass/tools/library/scripts/conv2d_operation.py +463 -0
- warp/native/cutlass/tools/library/scripts/conv3d_operation.py +321 -0
- warp/native/cutlass/tools/library/scripts/gemm_operation.py +988 -0
- warp/native/cutlass/tools/library/scripts/generator.py +4625 -0
- warp/native/cutlass/tools/library/scripts/library.py +799 -0
- warp/native/cutlass/tools/library/scripts/manifest.py +402 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/docs/source/conf.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/conv/conv2d_f16_sm80.py +106 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/gemm/gemm_f32_sm80.py +91 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/setup.py +80 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/__init__.py +48 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/arguments.py +118 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/c_types.py +241 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/compiler.py +432 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/conv2d_operation.py +631 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/epilogue.py +1026 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/frontend.py +104 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/gemm_operation.py +1276 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/library.py +744 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/memory_manager.py +74 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/operation.py +110 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/parser.py +619 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/reduction_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/tensor_ref.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/__init__.py +4 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/conv2d_testbed.py +646 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_grouped_testbed.py +235 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_testbed.py +557 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/profiler.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/type_hint.py +39 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/__init__.py +1 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/device.py +76 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/reference_model.py +255 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +201 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +177 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +98 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +95 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_few_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +163 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_fixed_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +187 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +309 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +54 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_strided_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +253 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +97 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +242 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/run_all_tests.py +10 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/frontend/test_frontend.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_bf16_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f16_sm80.py +447 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f32_sm80.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f64_sm80.py +102 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_grouped_sm80.py +203 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_s8_sm80.py +229 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/run_all_tests.py +9 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/unit/test_sm80.py +453 -0
- warp/native/cutlass/tools/library/scripts/rank_2k_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/rank_k_operation.py +387 -0
- warp/native/cutlass/tools/library/scripts/rt.py +796 -0
- warp/native/cutlass/tools/library/scripts/symm_operation.py +400 -0
- warp/native/cutlass/tools/library/scripts/trmm_operation.py +407 -0
- warp/native/cutlass_gemm.cu +5 -3
- warp/native/exports.h +1240 -949
- warp/native/fabric.h +228 -0
- warp/native/hashgrid.cpp +4 -4
- warp/native/hashgrid.h +22 -2
- warp/native/initializer_array.h +2 -2
- warp/native/intersect.h +22 -7
- warp/native/intersect_adj.h +8 -8
- warp/native/intersect_tri.h +13 -16
- warp/native/marching.cu +157 -161
- warp/native/mat.h +119 -19
- warp/native/matnn.h +2 -2
- warp/native/mesh.cpp +108 -83
- warp/native/mesh.cu +243 -6
- warp/native/mesh.h +1547 -458
- warp/native/nanovdb/NanoVDB.h +1 -1
- warp/native/noise.h +272 -329
- warp/native/quat.h +51 -8
- warp/native/rand.h +45 -35
- warp/native/range.h +6 -2
- warp/native/reduce.cpp +157 -0
- warp/native/reduce.cu +348 -0
- warp/native/runlength_encode.cpp +62 -0
- warp/native/runlength_encode.cu +46 -0
- warp/native/scan.cu +11 -13
- warp/native/scan.h +1 -0
- warp/native/solid_angle.h +442 -0
- warp/native/sort.cpp +13 -0
- warp/native/sort.cu +9 -1
- warp/native/sparse.cpp +338 -0
- warp/native/sparse.cu +545 -0
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +30 -0
- warp/native/vec.h +126 -24
- warp/native/volume.h +120 -0
- warp/native/warp.cpp +658 -53
- warp/native/warp.cu +660 -68
- warp/native/warp.h +112 -12
- warp/optim/__init__.py +1 -0
- warp/optim/linear.py +922 -0
- warp/optim/sgd.py +92 -0
- warp/render/render_opengl.py +392 -152
- warp/render/render_usd.py +11 -11
- warp/sim/__init__.py +2 -2
- warp/sim/articulation.py +385 -185
- warp/sim/collide.py +21 -8
- warp/sim/import_mjcf.py +297 -106
- warp/sim/import_urdf.py +389 -210
- warp/sim/import_usd.py +198 -97
- warp/sim/inertia.py +17 -18
- warp/sim/integrator_euler.py +14 -8
- warp/sim/integrator_xpbd.py +161 -19
- warp/sim/model.py +795 -291
- warp/sim/optimizer.py +2 -6
- warp/sim/render.py +65 -3
- warp/sim/utils.py +3 -0
- warp/sparse.py +1227 -0
- warp/stubs.py +665 -223
- warp/tape.py +66 -15
- warp/tests/__main__.py +3 -6
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- warp/tests/assets/torus.usda +105 -105
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/disabled_kinematics.py +239 -0
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +103 -106
- warp/tests/test_arithmetic.py +128 -74
- warp/tests/test_array.py +1497 -211
- warp/tests/test_array_reduce.py +150 -0
- warp/tests/test_atomic.py +64 -28
- warp/tests/test_bool.py +99 -0
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +75 -43
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +233 -128
- warp/tests/test_compile_consts.py +28 -20
- warp/tests/test_conditional.py +108 -24
- warp/tests/test_copy.py +10 -12
- warp/tests/test_ctypes.py +112 -88
- warp/tests/test_dense.py +21 -14
- warp/tests/test_devices.py +98 -0
- warp/tests/test_dlpack.py +136 -108
- warp/tests/test_examples.py +277 -0
- warp/tests/test_fabricarray.py +955 -0
- warp/tests/test_fast_math.py +15 -11
- warp/tests/test_fem.py +1271 -0
- warp/tests/test_fp16.py +53 -19
- warp/tests/test_func.py +187 -74
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +180 -116
- warp/tests/test_grad_customs.py +176 -0
- warp/tests/test_hash_grid.py +52 -37
- warp/tests/test_import.py +10 -23
- warp/tests/test_indexedarray.py +577 -24
- warp/tests/test_intersect.py +18 -9
- warp/tests/test_large.py +141 -0
- warp/tests/test_launch.py +251 -15
- warp/tests/test_lerp.py +64 -65
- warp/tests/test_linear_solvers.py +154 -0
- warp/tests/test_lvalue.py +493 -0
- warp/tests/test_marching_cubes.py +12 -13
- warp/tests/test_mat.py +508 -2778
- warp/tests/test_mat_lite.py +115 -0
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +103 -9
- warp/tests/test_matmul.py +305 -69
- warp/tests/test_matmul_lite.py +410 -0
- warp/tests/test_mesh.py +71 -14
- warp/tests/test_mesh_query_aabb.py +41 -25
- warp/tests/test_mesh_query_point.py +325 -34
- warp/tests/test_mesh_query_ray.py +39 -22
- warp/tests/test_mlp.py +30 -22
- warp/tests/test_model.py +92 -89
- warp/tests/test_modules_lite.py +39 -0
- warp/tests/test_multigpu.py +88 -114
- warp/tests/test_noise.py +12 -11
- warp/tests/test_operators.py +16 -20
- warp/tests/test_options.py +11 -11
- warp/tests/test_pinned.py +17 -18
- warp/tests/test_print.py +32 -11
- warp/tests/test_quat.py +275 -129
- warp/tests/test_rand.py +18 -16
- warp/tests/test_reload.py +38 -34
- warp/tests/test_rounding.py +50 -43
- warp/tests/test_runlength_encode.py +190 -0
- warp/tests/test_smoothstep.py +9 -11
- warp/tests/test_snippet.py +143 -0
- warp/tests/test_sparse.py +460 -0
- warp/tests/test_spatial.py +276 -243
- warp/tests/test_streams.py +110 -85
- warp/tests/test_struct.py +331 -85
- warp/tests/test_tape.py +39 -21
- warp/tests/test_torch.py +118 -89
- warp/tests/test_transient_module.py +12 -13
- warp/tests/test_types.py +614 -0
- warp/tests/test_utils.py +494 -0
- warp/tests/test_vec.py +354 -1987
- warp/tests/test_vec_lite.py +73 -0
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +457 -293
- warp/tests/test_volume_write.py +124 -134
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +341 -0
- warp/tests/unittest_utils.py +568 -0
- warp/tests/unused_test_misc.py +71 -0
- warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
- warp/thirdparty/appdirs.py +36 -45
- warp/thirdparty/unittest_parallel.py +549 -0
- warp/torch.py +72 -30
- warp/types.py +1744 -713
- warp/utils.py +360 -350
- warp_lang-0.11.0.dist-info/LICENSE.md +36 -0
- warp_lang-0.11.0.dist-info/METADATA +238 -0
- warp_lang-0.11.0.dist-info/RECORD +332 -0
- {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/WHEEL +1 -1
- warp/bin/warp-clang.exp +0 -0
- warp/bin/warp-clang.lib +0 -0
- warp/bin/warp.exp +0 -0
- warp/bin/warp.lib +0 -0
- warp/tests/test_all.py +0 -215
- warp/tests/test_array_scan.py +0 -60
- warp/tests/test_base.py +0 -208
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- warp_lang-0.9.0.dist-info/METADATA +0 -20
- warp_lang-0.9.0.dist-info/RECORD +0 -177
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .element import Element
|
|
2
|
+
from .geometry import Geometry
|
|
3
|
+
from .deformed_geometry import DeformedGeometry
|
|
4
|
+
|
|
5
|
+
from .partition import (
|
|
6
|
+
GeometryPartition,
|
|
7
|
+
WholeGeometryPartition,
|
|
8
|
+
LinearGeometryPartition,
|
|
9
|
+
ExplicitGeometryPartition,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
from .grid_2d import Grid2D
|
|
14
|
+
from .grid_3d import Grid3D
|
|
15
|
+
|
|
16
|
+
from .trimesh_2d import Trimesh2D
|
|
17
|
+
from .tetmesh import Tetmesh
|
|
18
|
+
from .quadmesh_2d import Quadmesh2D
|
|
19
|
+
from .hexmesh import Hexmesh
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import warp as wp
|
|
4
|
+
|
|
5
|
+
from warp.fem.types import Coords
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@wp.func
|
|
9
|
+
def project_on_seg_at_origin(q: Any, seg: Any, len_sq: float):
|
|
10
|
+
s = wp.clamp(wp.dot(q, seg) / len_sq, 0.0, 1.0)
|
|
11
|
+
return wp.length_sq(q - s * seg), s
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@wp.func
|
|
15
|
+
def project_on_tri_at_origin(q: Any, e1: Any, e2: Any):
|
|
16
|
+
e1e1 = wp.dot(e1, e1)
|
|
17
|
+
e1e2 = wp.dot(e1, e2)
|
|
18
|
+
e2e2 = wp.dot(e2, e2)
|
|
19
|
+
|
|
20
|
+
det = e1e1 * e2e2 - e1e2 * e1e2
|
|
21
|
+
|
|
22
|
+
if det > e1e1 * e2e2 * 1.0e-6:
|
|
23
|
+
e1p = wp.dot(e1, q)
|
|
24
|
+
e2p = wp.dot(e2, q)
|
|
25
|
+
|
|
26
|
+
s = (e2e2 * e1p - e1e2 * e2p) / det
|
|
27
|
+
t = (e1e1 * e2p - e1e2 * e1p) / det
|
|
28
|
+
|
|
29
|
+
if s >= 0.0 and t >= 0.0 and s + t <= 1.0:
|
|
30
|
+
# point inside triangle (distance can be non-zero in 3D case)
|
|
31
|
+
return wp.length_sq(q - s * e1 - t * e2), Coords(1.0 - s - t, s, t)
|
|
32
|
+
|
|
33
|
+
d1, s1 = project_on_seg_at_origin(q, e1, e1e1)
|
|
34
|
+
d2, s2 = project_on_seg_at_origin(q, e2, e2e2)
|
|
35
|
+
d12, s12 = project_on_seg_at_origin(q - e1, e2 - e1, wp.length_sq(e2 - e1))
|
|
36
|
+
|
|
37
|
+
if d1 <= d2:
|
|
38
|
+
if d1 <= d12:
|
|
39
|
+
return d1, Coords(1.0 - s1, s1, 0.0)
|
|
40
|
+
elif d2 <= d12:
|
|
41
|
+
return d2, Coords(1.0 - s2, 0.0, s2)
|
|
42
|
+
|
|
43
|
+
return d12, Coords(0.0, 1.0 - s12, s12)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@wp.func
|
|
47
|
+
def project_on_tet_at_origin(q: wp.vec3, e1: wp.vec3, e2: wp.vec3, e3: wp.vec3):
|
|
48
|
+
mat = wp.inverse(wp.mat33(e1, e2, e3))
|
|
49
|
+
coords = mat * q
|
|
50
|
+
|
|
51
|
+
if wp.min(coords) >= 0.0 and coords[0] + coords[1] + coords[2] <= 1.0:
|
|
52
|
+
return 0.0, coords
|
|
53
|
+
|
|
54
|
+
# Not inside tet, compare closest point on each tri
|
|
55
|
+
|
|
56
|
+
d12, s12 = project_on_tri_at_origin(q, e1, e2)
|
|
57
|
+
d23, s23 = project_on_tri_at_origin(q, e2, e3)
|
|
58
|
+
d31, s31 = project_on_tri_at_origin(q, e3, e1)
|
|
59
|
+
d123, s123 = project_on_tri_at_origin(q - e1, e2 - e1, e3 - e1)
|
|
60
|
+
|
|
61
|
+
dmin = wp.min(wp.vec4(d12, d23, d31, d123))
|
|
62
|
+
|
|
63
|
+
if dmin == d12:
|
|
64
|
+
return dmin, Coords(s12[1], s12[2], 0.0)
|
|
65
|
+
elif dmin == d23:
|
|
66
|
+
return dmin, Coords(0.0, s23[1], s23[2])
|
|
67
|
+
elif dmin == d31:
|
|
68
|
+
return dmin, Coords(s31[2], 0.0, s31[1])
|
|
69
|
+
else:
|
|
70
|
+
return dmin, s123
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import warp as wp
|
|
4
|
+
|
|
5
|
+
from .geometry import Geometry
|
|
6
|
+
|
|
7
|
+
from warp.fem.types import Sample, ElementIndex, Coords, make_free_sample
|
|
8
|
+
from warp.fem import cache
|
|
9
|
+
|
|
10
|
+
_mat32 = wp.mat(shape=(3, 2), dtype=float)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DeformedGeometry(Geometry):
|
|
14
|
+
def __init__(self, field):
|
|
15
|
+
"""Constructs a Deformed Geometry from a displacement field defined over a base geometry"""
|
|
16
|
+
|
|
17
|
+
from warp.fem.field import DiscreteField
|
|
18
|
+
|
|
19
|
+
self.field: DiscreteField = field
|
|
20
|
+
self.base = self.field.space.geometry
|
|
21
|
+
self.dimension = self.base.dimension
|
|
22
|
+
|
|
23
|
+
if not wp.types.type_is_vector(field.dtype) or wp.types.type_length(field.dtype) != self.dimension:
|
|
24
|
+
raise ValueError("Invalid value type for position field")
|
|
25
|
+
|
|
26
|
+
self.CellArg = self.field.ElementEvalArg
|
|
27
|
+
|
|
28
|
+
self.field_trace = field.trace()
|
|
29
|
+
self.SideArg = self._make_side_arg()
|
|
30
|
+
self.SideIndexArg = self.base.SideIndexArg
|
|
31
|
+
|
|
32
|
+
self.cell_count = self.base.cell_count
|
|
33
|
+
self.vertex_count = self.base.vertex_count
|
|
34
|
+
self.side_count = self.base.side_count
|
|
35
|
+
self.boundary_side_count = self.base.boundary_side_count
|
|
36
|
+
self.reference_cell = self.base.reference_cell
|
|
37
|
+
self.reference_side = self.base.reference_side
|
|
38
|
+
|
|
39
|
+
self.side_index_arg_value = self.base.side_index_arg_value
|
|
40
|
+
|
|
41
|
+
self.cell_position = self._make_cell_position()
|
|
42
|
+
self.cell_deformation_gradient = self._make_cell_deformation_gradient()
|
|
43
|
+
self.cell_inverse_deformation_gradient = self._make_cell_inverse_deformation_gradient()
|
|
44
|
+
self.cell_measure = self._make_cell_measure()
|
|
45
|
+
|
|
46
|
+
self.boundary_side_index = self.base.boundary_side_index
|
|
47
|
+
|
|
48
|
+
self.side_to_cell_arg = self._make_side_to_cell_arg()
|
|
49
|
+
self.side_position = self._make_side_position()
|
|
50
|
+
self.side_deformation_gradient = self._make_side_deformation_gradient()
|
|
51
|
+
self.side_inner_cell_index = self._make_side_inner_cell_index()
|
|
52
|
+
self.side_outer_cell_index = self._make_side_outer_cell_index()
|
|
53
|
+
self.side_inner_cell_coords = self._make_side_inner_cell_coords()
|
|
54
|
+
self.side_outer_cell_coords = self._make_side_outer_cell_coords()
|
|
55
|
+
self.side_from_cell_coords = self._make_side_from_cell_coords()
|
|
56
|
+
self.side_inner_inverse_deformation_gradient = self._make_side_inner_inverse_deformation_gradient()
|
|
57
|
+
self.side_outer_inverse_deformation_gradient = self._make_side_outer_inverse_deformation_gradient()
|
|
58
|
+
self.side_measure = self._make_side_measure()
|
|
59
|
+
self.side_measure_ratio = self._make_side_measure_ratio()
|
|
60
|
+
self.side_normal = self._make_side_normal()
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def name(self):
|
|
64
|
+
return f"DefGeo_{self.field.name}"
|
|
65
|
+
|
|
66
|
+
# Geometry device interface
|
|
67
|
+
|
|
68
|
+
@cache.cached_arg_value
|
|
69
|
+
def cell_arg_value(self, device) -> "DeformedGeometry.CellArg":
|
|
70
|
+
args = self.CellArg()
|
|
71
|
+
|
|
72
|
+
args.elt_arg = self.base.cell_arg_value(device)
|
|
73
|
+
args.eval_arg = self.field.eval_arg_value(device)
|
|
74
|
+
|
|
75
|
+
return args
|
|
76
|
+
|
|
77
|
+
def _make_cell_position(self):
|
|
78
|
+
@cache.dynamic_func(suffix=self.name)
|
|
79
|
+
def cell_position(cell_arg: self.CellArg, s: Sample):
|
|
80
|
+
return self.field.eval_inner(cell_arg, s) + self.base.cell_position(cell_arg.elt_arg, s)
|
|
81
|
+
|
|
82
|
+
return cell_position
|
|
83
|
+
|
|
84
|
+
def _make_cell_deformation_gradient(self):
|
|
85
|
+
@cache.dynamic_func(suffix=self.name)
|
|
86
|
+
def cell_deformation_gradient(cell_arg: self.CellArg, s: Sample):
|
|
87
|
+
return self.field.eval_reference_grad_inner(cell_arg, s) + self.base.cell_deformation_gradient(
|
|
88
|
+
cell_arg.elt_arg, s
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return cell_deformation_gradient
|
|
92
|
+
|
|
93
|
+
def _make_cell_inverse_deformation_gradient(self):
|
|
94
|
+
@cache.dynamic_func(suffix=self.name)
|
|
95
|
+
def cell_inverse_deformation_gradient(cell_arg: self.CellArg, s: Sample):
|
|
96
|
+
return wp.inverse(self.cell_deformation_gradient(cell_arg, s))
|
|
97
|
+
|
|
98
|
+
return cell_inverse_deformation_gradient
|
|
99
|
+
|
|
100
|
+
def _make_cell_measure(self):
|
|
101
|
+
REF_MEASURE = wp.constant(self.reference_cell().measure())
|
|
102
|
+
|
|
103
|
+
@cache.dynamic_func(suffix=self.name)
|
|
104
|
+
def cell_measure(args: self.CellArg, s: Sample):
|
|
105
|
+
return wp.abs(wp.determinant(self.cell_deformation_gradient(args, s))) * REF_MEASURE
|
|
106
|
+
|
|
107
|
+
return cell_measure
|
|
108
|
+
|
|
109
|
+
@wp.func
|
|
110
|
+
def cell_normal(args: Any, s: Sample):
|
|
111
|
+
return wp.vec2(0.0)
|
|
112
|
+
|
|
113
|
+
def _make_side_arg(self):
|
|
114
|
+
@cache.dynamic_struct(suffix=self.name)
|
|
115
|
+
class SideArg:
|
|
116
|
+
base_arg: self.base.SideArg
|
|
117
|
+
trace_arg: self.field_trace.EvalArg
|
|
118
|
+
field_arg: self.field.EvalArg
|
|
119
|
+
|
|
120
|
+
return SideArg
|
|
121
|
+
|
|
122
|
+
@cache.cached_arg_value
|
|
123
|
+
def side_arg_value(self, device) -> "DeformedGeometry.SideArg":
|
|
124
|
+
args = self.SideArg()
|
|
125
|
+
|
|
126
|
+
args.base_arg = self.base.side_arg_value(device)
|
|
127
|
+
args.field_arg = self.field.eval_arg_value(device)
|
|
128
|
+
args.trace_arg = self.field_trace.eval_arg_value(device)
|
|
129
|
+
|
|
130
|
+
return args
|
|
131
|
+
|
|
132
|
+
def _make_side_position(self):
|
|
133
|
+
@cache.dynamic_func(suffix=self.name)
|
|
134
|
+
def side_position(args: self.SideArg, s: Sample):
|
|
135
|
+
trace_arg = self.field_trace.ElementEvalArg(args.base_arg, args.trace_arg)
|
|
136
|
+
return self.field_trace.eval_inner(trace_arg, s) + self.base.side_position(args.base_arg, s)
|
|
137
|
+
|
|
138
|
+
return side_position
|
|
139
|
+
|
|
140
|
+
def _make_side_deformation_gradient(self):
|
|
141
|
+
@cache.dynamic_func(suffix=self.name)
|
|
142
|
+
def side_deformation_gradient(args: self.SideArg, s: Sample):
|
|
143
|
+
base_def_grad = self.base.side_deformation_gradient(args.base_arg, s)
|
|
144
|
+
trace_arg = self.field_trace.ElementEvalArg(args.base_arg, args.trace_arg)
|
|
145
|
+
|
|
146
|
+
Du = self.field_trace.eval_grad_inner(trace_arg, s)
|
|
147
|
+
return base_def_grad + Du * base_def_grad
|
|
148
|
+
|
|
149
|
+
return side_deformation_gradient
|
|
150
|
+
|
|
151
|
+
def _make_side_inner_inverse_deformation_gradient(self):
|
|
152
|
+
@cache.dynamic_func(suffix=self.name)
|
|
153
|
+
def side_inner_inverse_deformation_gradient(args: self.SideArg, s: Sample):
|
|
154
|
+
cell_index = self.side_inner_cell_index(args, s.element_index)
|
|
155
|
+
cell_coords = self.side_inner_cell_coords(args, s.element_index, s.element_coords)
|
|
156
|
+
cell_arg = self.side_to_cell_arg(args)
|
|
157
|
+
return self.cell_inverse_deformation_gradient(cell_arg, make_free_sample(cell_index, cell_coords))
|
|
158
|
+
|
|
159
|
+
def _make_side_outer_inverse_deformation_gradient(self):
|
|
160
|
+
@cache.dynamic_func(suffix=self.name)
|
|
161
|
+
def side_outer_inverse_deformation_gradient(args: self.SideArg, s: Sample):
|
|
162
|
+
cell_index = self.side_outer_cell_index(args, s.element_index)
|
|
163
|
+
cell_coords = self.side_outer_cell_coords(args, s.element_index, s.element_coords)
|
|
164
|
+
cell_arg = self.side_to_cell_arg(args)
|
|
165
|
+
return self.cell_inverse_deformation_gradient(cell_arg, make_free_sample(cell_index, cell_coords))
|
|
166
|
+
|
|
167
|
+
@wp.func
|
|
168
|
+
def _side_measure(F: wp.vec2):
|
|
169
|
+
return wp.length(F)
|
|
170
|
+
|
|
171
|
+
@wp.func
|
|
172
|
+
def _side_measure(F: _mat32):
|
|
173
|
+
Fcross = wp.vec3(
|
|
174
|
+
F[1, 0] * F[2, 1] - F[2, 0] * F[1, 1],
|
|
175
|
+
F[2, 0] * F[0, 1] - F[0, 0] * F[2, 1],
|
|
176
|
+
F[0, 0] * F[1, 1] - F[1, 0] * F[0, 1],
|
|
177
|
+
)
|
|
178
|
+
return wp.length(Fcross)
|
|
179
|
+
|
|
180
|
+
@wp.func
|
|
181
|
+
def _side_normal(F: wp.vec2):
|
|
182
|
+
return wp.normalize(wp.vec2(-F[1], F[0]))
|
|
183
|
+
|
|
184
|
+
@wp.func
|
|
185
|
+
def _side_normal(F: _mat32):
|
|
186
|
+
Fcross = wp.vec3(
|
|
187
|
+
F[1, 0] * F[2, 1] - F[2, 0] * F[1, 1],
|
|
188
|
+
F[2, 0] * F[0, 1] - F[0, 0] * F[2, 1],
|
|
189
|
+
F[0, 0] * F[1, 1] - F[1, 0] * F[0, 1],
|
|
190
|
+
)
|
|
191
|
+
return wp.normalize(Fcross)
|
|
192
|
+
|
|
193
|
+
def _make_side_measure(self):
|
|
194
|
+
REF_MEASURE = wp.constant(self.reference_side().measure())
|
|
195
|
+
|
|
196
|
+
@cache.dynamic_func(suffix=self.name)
|
|
197
|
+
def side_measure(args: self.SideArg, s: Sample):
|
|
198
|
+
F = self.side_deformation_gradient(args, s)
|
|
199
|
+
return DeformedGeometry._side_measure(F) * REF_MEASURE
|
|
200
|
+
|
|
201
|
+
return side_measure
|
|
202
|
+
|
|
203
|
+
def _make_side_measure_ratio(self):
|
|
204
|
+
@cache.dynamic_func(suffix=self.name)
|
|
205
|
+
def side_measure_ratio(args: self.SideArg, s: Sample):
|
|
206
|
+
inner = self.side_inner_cell_index(args, s.element_index)
|
|
207
|
+
outer = self.side_outer_cell_index(args, s.element_index)
|
|
208
|
+
inner_coords = self.side_inner_cell_coords(args, s.element_index, s.element_coords)
|
|
209
|
+
outer_coords = self.side_outer_cell_coords(args, s.element_index, s.element_coords)
|
|
210
|
+
cell_arg = self.side_to_cell_arg(args)
|
|
211
|
+
return self.side_measure(args, s) / wp.min(
|
|
212
|
+
self.cell_measure(cell_arg, make_free_sample(inner, inner_coords)),
|
|
213
|
+
self.cell_measure(cell_arg, make_free_sample(outer, outer_coords)),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return side_measure_ratio
|
|
217
|
+
|
|
218
|
+
def _make_side_normal(self):
|
|
219
|
+
@cache.dynamic_func(suffix=self.name)
|
|
220
|
+
def side_normal(args: self.SideArg, s: Sample):
|
|
221
|
+
F = self.side_deformation_gradient(args, s)
|
|
222
|
+
return DeformedGeometry._side_normal(F)
|
|
223
|
+
|
|
224
|
+
return side_normal
|
|
225
|
+
|
|
226
|
+
def _make_side_inner_cell_index(self):
|
|
227
|
+
@cache.dynamic_func(suffix=self.name)
|
|
228
|
+
def side_inner_cell_index(args: self.SideArg, side_index: ElementIndex):
|
|
229
|
+
return self.base.side_inner_cell_index(args.base_arg, side_index)
|
|
230
|
+
|
|
231
|
+
return side_inner_cell_index
|
|
232
|
+
|
|
233
|
+
def _make_side_outer_cell_index(self):
|
|
234
|
+
@cache.dynamic_func(suffix=self.name)
|
|
235
|
+
def side_outer_cell_index(args: self.SideArg, side_index: ElementIndex):
|
|
236
|
+
return self.base.side_outer_cell_index(args.base_arg, side_index)
|
|
237
|
+
|
|
238
|
+
return side_outer_cell_index
|
|
239
|
+
|
|
240
|
+
def _make_side_inner_cell_coords(self):
|
|
241
|
+
@cache.dynamic_func(suffix=self.name)
|
|
242
|
+
def side_inner_cell_coords(args: self.SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
243
|
+
return self.base.side_inner_cell_coords(args.base_arg, side_index, side_coords)
|
|
244
|
+
|
|
245
|
+
return side_inner_cell_coords
|
|
246
|
+
|
|
247
|
+
def _make_side_outer_cell_coords(self):
|
|
248
|
+
@cache.dynamic_func(suffix=self.name)
|
|
249
|
+
def side_outer_cell_coords(args: self.SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
250
|
+
return self.base.side_outer_cell_coords(args.base_arg, side_index, side_coords)
|
|
251
|
+
|
|
252
|
+
return side_outer_cell_coords
|
|
253
|
+
|
|
254
|
+
def _make_side_from_cell_coords(self):
|
|
255
|
+
@cache.dynamic_func(suffix=self.name)
|
|
256
|
+
def side_from_cell_coords(
|
|
257
|
+
args: self.SideArg,
|
|
258
|
+
side_index: ElementIndex,
|
|
259
|
+
cell_index: ElementIndex,
|
|
260
|
+
cell_coords: Coords,
|
|
261
|
+
):
|
|
262
|
+
return self.base.side_from_cell_coords(args.base_arg, side_index, cell_index, cell_coords)
|
|
263
|
+
|
|
264
|
+
return side_from_cell_coords
|
|
265
|
+
|
|
266
|
+
def _make_side_to_cell_arg(self):
|
|
267
|
+
@cache.dynamic_func(suffix=self.name)
|
|
268
|
+
def side_to_cell_arg(side_arg: self.SideArg):
|
|
269
|
+
return self.CellArg(self.base.side_to_cell_arg(side_arg.base_arg), side_arg.field_arg)
|
|
270
|
+
|
|
271
|
+
return side_to_cell_arg
|