warp-lang 0.10.1__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 +10 -4
- warp/__init__.pyi +1 -0
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +5 -3
- warp/build_dll.py +29 -9
- warp/builtins.py +868 -507
- warp/codegen.py +1074 -638
- warp/config.py +3 -3
- warp/constants.py +6 -0
- warp/context.py +715 -222
- 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 +147 -44
- warp/native/builtin.h +122 -149
- warp/native/bvh.cpp +73 -325
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +34 -43
- warp/native/clang/clang.cpp +13 -8
- warp/native/crt.h +2 -0
- warp/native/cuda_crt.h +5 -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 -952
- warp/native/fabric.h +228 -0
- warp/native/hashgrid.cpp +4 -4
- warp/native/hashgrid.h +22 -2
- warp/native/intersect.h +22 -7
- warp/native/intersect_adj.h +8 -8
- warp/native/intersect_tri.h +1 -1
- warp/native/marching.cu +157 -161
- warp/native/mat.h +80 -19
- warp/native/matnn.h +2 -2
- warp/native/mesh.cpp +33 -108
- warp/native/mesh.cu +114 -23
- warp/native/mesh.h +446 -46
- 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 +1 -1
- warp/native/reduce.cu +10 -12
- warp/native/runlength_encode.cu +6 -10
- warp/native/scan.cu +8 -11
- warp/native/sparse.cpp +4 -4
- warp/native/sparse.cu +164 -154
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +14 -30
- warp/native/vec.h +107 -23
- warp/native/volume.h +120 -0
- warp/native/warp.cpp +560 -30
- warp/native/warp.cu +431 -44
- warp/native/warp.h +13 -4
- warp/optim/__init__.py +1 -0
- warp/optim/linear.py +922 -0
- warp/optim/sgd.py +92 -0
- warp/render/render_opengl.py +335 -119
- warp/render/render_usd.py +11 -11
- warp/sim/__init__.py +2 -2
- warp/sim/articulation.py +385 -185
- warp/sim/collide.py +8 -0
- 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 +158 -16
- warp/sim/model.py +795 -291
- warp/sim/render.py +3 -3
- warp/sim/utils.py +3 -0
- warp/sparse.py +640 -150
- warp/stubs.py +606 -267
- warp/tape.py +61 -10
- warp/tests/__main__.py +3 -6
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- 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 +212 -97
- warp/tests/test_array_reduce.py +57 -23
- 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 +42 -18
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +208 -130
- 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 +75 -75
- 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 -86
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +178 -109
- 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 +32 -31
- warp/tests/test_intersect.py +18 -9
- warp/tests/test_large.py +141 -0
- warp/tests/test_launch.py +14 -41
- 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 +517 -2898
- 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 +140 -22
- 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 +168 -20
- warp/tests/test_smoothstep.py +9 -11
- warp/tests/test_snippet.py +143 -0
- warp/tests/test_sparse.py +261 -63
- warp/tests/test_spatial.py +276 -243
- warp/tests/test_streams.py +110 -85
- warp/tests/test_struct.py +268 -63
- 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 -2050
- 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 +9 -6
- warp/types.py +1089 -366
- warp/utils.py +93 -387
- warp_lang-0.11.0.dist-info/METADATA +238 -0
- warp_lang-0.11.0.dist-info/RECORD +332 -0
- {warp_lang-0.10.1.dist-info → warp_lang-0.11.0.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -219
- 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.10.1.dist-info/METADATA +0 -21
- warp_lang-0.10.1.dist-info/RECORD +0 -188
- /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.10.1.dist-info → warp_lang-0.11.0.dist-info}/LICENSE.md +0 -0
- {warp_lang-0.10.1.dist-info → warp_lang-0.11.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import warp as wp
|
|
4
|
+
|
|
5
|
+
from warp.fem.types import Sample, ElementIndex, Coords
|
|
6
|
+
from warp.fem import cache
|
|
7
|
+
|
|
8
|
+
from .element import Element
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Geometry:
|
|
12
|
+
"""
|
|
13
|
+
Interface class for discrete geometries
|
|
14
|
+
|
|
15
|
+
A geometry is composed of cells and sides. Sides may be boundary or interior (between cells).
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
dimension: int = 0
|
|
19
|
+
|
|
20
|
+
def cell_count(self):
|
|
21
|
+
"""Number of cells in the geometry"""
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
24
|
+
def side_count(self):
|
|
25
|
+
"""Number of sides in the geometry"""
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
|
|
28
|
+
def boundary_side_count(self):
|
|
29
|
+
"""Number of boundary sides (sides with a single neighbour cell) in the geometry"""
|
|
30
|
+
raise NotImplementedError
|
|
31
|
+
|
|
32
|
+
def reference_cell(self) -> Element:
|
|
33
|
+
"""Prototypical element for a cell"""
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
def reference_side(self) -> Element:
|
|
37
|
+
"""Prototypical element for a side"""
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def name(self) -> str:
|
|
42
|
+
return self.__class__.__name__
|
|
43
|
+
|
|
44
|
+
def __str__(self) -> str:
|
|
45
|
+
return self.name
|
|
46
|
+
|
|
47
|
+
CellArg: wp.codegen.Struct
|
|
48
|
+
"""Structure containing arguments to be passed to device functions evaluating cell-related quantities"""
|
|
49
|
+
|
|
50
|
+
SideArg: wp.codegen.Struct
|
|
51
|
+
"""Structure containing arguments to be passed to device functions evaluating side-related quantities"""
|
|
52
|
+
|
|
53
|
+
SideIndexArg: wp.codegen.Struct
|
|
54
|
+
"""Structure containing arguments to be passed to device functions for indexing sides"""
|
|
55
|
+
|
|
56
|
+
@staticmethod
|
|
57
|
+
def cell_arg_value(self, device) -> "Geometry.CellArg":
|
|
58
|
+
"""Value of the arguments to be passed to cell-related device functions"""
|
|
59
|
+
raise NotImplementedError
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def cell_position(args: "Geometry.CellArg", s: "Sample"):
|
|
63
|
+
"""Device function returning the world position of a cell sample point"""
|
|
64
|
+
raise NotImplementedError
|
|
65
|
+
|
|
66
|
+
@staticmethod
|
|
67
|
+
def cell_deformation_gradient(args: "Geometry.CellArg", s: "Sample"):
|
|
68
|
+
"""Device function returning the transpose of the gradient of world position with respect to reference cell"""
|
|
69
|
+
raise NotImplementedError
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def cell_inverse_deformation_gradient(args: "Geometry.CellArg", cell_index: ElementIndex, coords: Coords):
|
|
73
|
+
"""Device function returning the matrix right-transforming a gradient w.r.t. cell space to a gradient w.r.t. world space
|
|
74
|
+
(i.e. the inverse deformation gradient)
|
|
75
|
+
"""
|
|
76
|
+
raise NotImplementedError
|
|
77
|
+
|
|
78
|
+
@staticmethod
|
|
79
|
+
def cell_lookup(args: "Geometry.CellArg", pos: Any):
|
|
80
|
+
"""Device function returning the cell sample point corresponding to a world position"""
|
|
81
|
+
raise NotImplementedError
|
|
82
|
+
|
|
83
|
+
@staticmethod
|
|
84
|
+
def cell_lookup(args: "Geometry.CellArg", pos: Any, guess: "Sample"):
|
|
85
|
+
"""Device function returning the cell sample point corresponding to a world position. Can use guess for faster lookup"""
|
|
86
|
+
raise NotImplementedError
|
|
87
|
+
|
|
88
|
+
@staticmethod
|
|
89
|
+
def cell_measure(args: "Geometry.CellArg", s: "Sample"):
|
|
90
|
+
"""Device function returning the measure determinant (e.g. volume, area) at a given point"""
|
|
91
|
+
raise NotImplementedError
|
|
92
|
+
|
|
93
|
+
@wp.func
|
|
94
|
+
def cell_measure_ratio(args: Any, s: Sample):
|
|
95
|
+
return 1.0
|
|
96
|
+
|
|
97
|
+
@staticmethod
|
|
98
|
+
def cell_normal(args: "Geometry.CellArg", s: "Sample"):
|
|
99
|
+
"""Device function returning the element normal at a sample point.
|
|
100
|
+
|
|
101
|
+
For elements with the same dimension as the embedding space, this will be zero."""
|
|
102
|
+
raise NotImplementedError
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def side_arg_value(self, device) -> "Geometry.SideArg":
|
|
106
|
+
"""Value of the arguments to be passed to side-related device functions"""
|
|
107
|
+
raise NotImplementedError
|
|
108
|
+
|
|
109
|
+
@staticmethod
|
|
110
|
+
def boundary_side_index(args: "Geometry.SideIndexArg", boundary_side_index: int):
|
|
111
|
+
"""Device function returning the side index corresponding to a boundary side"""
|
|
112
|
+
raise NotImplementedError
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def side_position(args: "Geometry.SideArg", s: "Sample"):
|
|
116
|
+
"""Device function returning the side position at a sample point"""
|
|
117
|
+
raise NotImplementedError
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def side_deformation_gradient(args: "Geometry.CellArg", s: "Sample"):
|
|
121
|
+
"""Device function returning the gradient of world position with respect to reference cell"""
|
|
122
|
+
raise NotImplementedError
|
|
123
|
+
|
|
124
|
+
@staticmethod
|
|
125
|
+
def side_inner_inverse_deformation_gradient(args: "Geometry.CellArg", side_index: ElementIndex, coords: Coords):
|
|
126
|
+
"""Device function returning the matrix right-transforming a gradient w.r.t. inner cell space to a gradient w.r.t. world space
|
|
127
|
+
(i.e. the inverse deformation gradient)
|
|
128
|
+
"""
|
|
129
|
+
raise NotImplementedError
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def side_outer_inverse_deformation_gradient(args: "Geometry.CellArg", side_index: ElementIndex, coords: Coords):
|
|
133
|
+
"""Device function returning the matrix right-transforming a gradient w.r.t. outer cell space to a gradient w.r.t. world space
|
|
134
|
+
(i.e. the inverse deformation gradient)
|
|
135
|
+
"""
|
|
136
|
+
raise NotImplementedError
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def side_measure(args: "Geometry.SideArg", s: "Sample"):
|
|
140
|
+
"""Device function returning the measure determinant (e.g. volume, area) at a given point"""
|
|
141
|
+
raise NotImplementedError
|
|
142
|
+
|
|
143
|
+
@staticmethod
|
|
144
|
+
def side_measure_ratio(args: "Geometry.SideArg", s: "Sample"):
|
|
145
|
+
"""Device function returning the ratio of the measure of a side to that of its neighbour cells"""
|
|
146
|
+
raise NotImplementedError
|
|
147
|
+
|
|
148
|
+
@staticmethod
|
|
149
|
+
def side_normal(args: "Geometry.SideArg", s: "Sample"):
|
|
150
|
+
"""Device function returning the element normal at a sample point"""
|
|
151
|
+
raise NotImplementedError
|
|
152
|
+
|
|
153
|
+
@staticmethod
|
|
154
|
+
def side_inner_cell_index(args: "Geometry.SideArg", side_index: ElementIndex):
|
|
155
|
+
"""Device function returning the inner cell index for a given side"""
|
|
156
|
+
raise NotImplementedError
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def side_outer_cell_index(args: "Geometry.SideArg", side_index: ElementIndex):
|
|
160
|
+
"""Device function returning the outer cell index for a given side"""
|
|
161
|
+
raise NotImplementedError
|
|
162
|
+
|
|
163
|
+
@staticmethod
|
|
164
|
+
def side_inner_cell_coords(args: "Geometry.SideArg", side_index: ElementIndex, side_coords: Coords):
|
|
165
|
+
"""Device function returning the coordinates of a point on a side in the inner cell"""
|
|
166
|
+
raise NotImplementedError
|
|
167
|
+
|
|
168
|
+
@staticmethod
|
|
169
|
+
def side_outer_cell_coords(args: "Geometry.SideArg", side_index: ElementIndex, side_coords: Coords):
|
|
170
|
+
"""Device function returning the coordinates of a point on a side in the outer cell"""
|
|
171
|
+
raise NotImplementedError
|
|
172
|
+
|
|
173
|
+
@staticmethod
|
|
174
|
+
def side_from_cell_coords(
|
|
175
|
+
args: "Geometry.SideArg",
|
|
176
|
+
side_index: ElementIndex,
|
|
177
|
+
element_index: ElementIndex,
|
|
178
|
+
element_coords: Coords,
|
|
179
|
+
):
|
|
180
|
+
"""Device function converting coordinates on a cell to coordinates on a side, or ``OUTSIDE``"""
|
|
181
|
+
raise NotImplementedError
|
|
182
|
+
|
|
183
|
+
@staticmethod
|
|
184
|
+
def side_to_cell_arg(side_arg: "Geometry.SideArg"):
|
|
185
|
+
"""Device function converting a side-related argument value to a cell-related argument value, for promoting trace samples to the full space"""
|
|
186
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import warp as wp
|
|
2
|
+
|
|
3
|
+
from warp.fem.types import ElementIndex, Coords, Sample, make_free_sample, OUTSIDE
|
|
4
|
+
from warp.fem.cache import cached_arg_value
|
|
5
|
+
|
|
6
|
+
from .geometry import Geometry
|
|
7
|
+
from .element import Square, LinearEdge
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@wp.struct
|
|
11
|
+
class Grid2DCellArg:
|
|
12
|
+
res: wp.vec2i
|
|
13
|
+
cell_size: wp.vec2
|
|
14
|
+
origin: wp.vec2
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Grid2D(Geometry):
|
|
18
|
+
"""Two-dimensional regular grid geometry"""
|
|
19
|
+
|
|
20
|
+
dimension = 2
|
|
21
|
+
|
|
22
|
+
Permutation = wp.types.matrix(shape=(2, 2), dtype=int)
|
|
23
|
+
ROTATION = wp.constant(Permutation(0, 1, 1, 0))
|
|
24
|
+
|
|
25
|
+
def __init__(self, res: wp.vec2i, bounds_lo: wp.vec2 = wp.vec2(0.0), bounds_hi: wp.vec2 = wp.vec2(1.0)):
|
|
26
|
+
"""Constructs a dense 2D grid
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
res: Resolution of the grid along each dimension
|
|
30
|
+
bounds_lo: Position of the lower bound of the axis-aligned grid
|
|
31
|
+
bounds_up: Position of the upper bound of the axis-aligned grid
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
self.bounds_lo = bounds_lo
|
|
35
|
+
self.bounds_hi = bounds_hi
|
|
36
|
+
|
|
37
|
+
self._res = res
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def extents(self) -> wp.vec3:
|
|
41
|
+
# Avoid using native sub due to higher over of calling builtins from Python
|
|
42
|
+
return wp.vec2(
|
|
43
|
+
self.bounds_hi[0] - self.bounds_lo[0],
|
|
44
|
+
self.bounds_hi[1] - self.bounds_lo[1],
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def cell_size(self) -> wp.vec2:
|
|
49
|
+
ex = self.extents
|
|
50
|
+
return wp.vec2(
|
|
51
|
+
ex[0] / self.res[0],
|
|
52
|
+
ex[1] / self.res[1],
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def cell_count(self):
|
|
56
|
+
return self.res[0] * self.res[1]
|
|
57
|
+
|
|
58
|
+
def vertex_count(self):
|
|
59
|
+
return (self.res[0] + 1) * (self.res[1] + 1)
|
|
60
|
+
|
|
61
|
+
def side_count(self):
|
|
62
|
+
return 2 * self.cell_count() + self.res[0] + self.res[1]
|
|
63
|
+
|
|
64
|
+
def boundary_side_count(self):
|
|
65
|
+
return 2 * (self.res[0] + self.res[1])
|
|
66
|
+
|
|
67
|
+
def reference_cell(self) -> Square:
|
|
68
|
+
return Square()
|
|
69
|
+
|
|
70
|
+
def reference_side(self) -> LinearEdge:
|
|
71
|
+
return LinearEdge()
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def res(self):
|
|
75
|
+
return self._res
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def origin(self):
|
|
79
|
+
return self.bounds_lo
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def strides(self):
|
|
83
|
+
return wp.vec2i(self.res[1], 1)
|
|
84
|
+
|
|
85
|
+
# Utility device functions
|
|
86
|
+
CellArg = Grid2DCellArg
|
|
87
|
+
Cell = wp.vec2i
|
|
88
|
+
|
|
89
|
+
@wp.func
|
|
90
|
+
def _to_2d_index(x_stride: int, index: int):
|
|
91
|
+
x = index // x_stride
|
|
92
|
+
y = index - x_stride * x
|
|
93
|
+
return wp.vec2i(x, y)
|
|
94
|
+
|
|
95
|
+
@wp.func
|
|
96
|
+
def _from_2d_index(x_stride: int, index: wp.vec2i):
|
|
97
|
+
return x_stride * index[0] + index[1]
|
|
98
|
+
|
|
99
|
+
@wp.func
|
|
100
|
+
def cell_index(res: wp.vec2i, cell: Cell):
|
|
101
|
+
return Grid2D._from_2d_index(res[1], cell)
|
|
102
|
+
|
|
103
|
+
@wp.func
|
|
104
|
+
def get_cell(res: wp.vec2i, cell_index: ElementIndex):
|
|
105
|
+
return Grid2D._to_2d_index(res[1], cell_index)
|
|
106
|
+
|
|
107
|
+
@wp.struct
|
|
108
|
+
class Side:
|
|
109
|
+
axis: int # normal; 0: horizontal, 1: vertical
|
|
110
|
+
origin: wp.vec2i # index of vertex at corner (0,0)
|
|
111
|
+
|
|
112
|
+
@wp.struct
|
|
113
|
+
class SideArg:
|
|
114
|
+
cell_count: int
|
|
115
|
+
axis_offsets: wp.vec2i
|
|
116
|
+
cell_arg: Grid2DCellArg
|
|
117
|
+
|
|
118
|
+
SideIndexArg = SideArg
|
|
119
|
+
|
|
120
|
+
@wp.func
|
|
121
|
+
def _rotate(axis: int, vec: wp.vec2i):
|
|
122
|
+
return wp.vec2i(
|
|
123
|
+
vec[Grid2D.ROTATION[axis, 0]],
|
|
124
|
+
vec[Grid2D.ROTATION[axis, 1]],
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
@wp.func
|
|
128
|
+
def _rotate(axis: int, vec: wp.vec2):
|
|
129
|
+
return wp.vec2(
|
|
130
|
+
vec[Grid2D.ROTATION[axis, 0]],
|
|
131
|
+
vec[Grid2D.ROTATION[axis, 1]],
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
@wp.func
|
|
135
|
+
def side_index(arg: SideArg, side: Side):
|
|
136
|
+
alt_axis = Grid2D.ROTATION[side.axis, 0]
|
|
137
|
+
if side.origin[0] == arg.cell_arg.res[alt_axis]:
|
|
138
|
+
# Upper-boundary side
|
|
139
|
+
longitude = side.origin[1]
|
|
140
|
+
return 2 * arg.cell_count + arg.axis_offsets[side.axis] + longitude
|
|
141
|
+
|
|
142
|
+
cell_index = Grid2D.cell_index(arg.cell_arg.res, Grid2D._rotate(side.axis, side.origin))
|
|
143
|
+
return side.axis * arg.cell_count + cell_index
|
|
144
|
+
|
|
145
|
+
@wp.func
|
|
146
|
+
def get_side(arg: SideArg, side_index: ElementIndex):
|
|
147
|
+
if side_index < 2 * arg.cell_count:
|
|
148
|
+
axis = side_index // arg.cell_count
|
|
149
|
+
cell_index = side_index - axis * arg.cell_count
|
|
150
|
+
origin = Grid2D._rotate(axis, Grid2D.get_cell(arg.cell_arg.res, cell_index))
|
|
151
|
+
return Grid2D.Side(axis, origin)
|
|
152
|
+
|
|
153
|
+
axis_side_index = side_index - 2 * arg.cell_count
|
|
154
|
+
if axis_side_index < arg.axis_offsets[1]:
|
|
155
|
+
axis = 0
|
|
156
|
+
else:
|
|
157
|
+
axis = 1
|
|
158
|
+
|
|
159
|
+
altitude = arg.cell_arg.res[Grid2D.ROTATION[axis, 0]]
|
|
160
|
+
longitude = axis_side_index - arg.axis_offsets[axis]
|
|
161
|
+
|
|
162
|
+
origin_loc = wp.vec2i(altitude, longitude)
|
|
163
|
+
return Grid2D.Side(axis, origin_loc)
|
|
164
|
+
|
|
165
|
+
# Geometry device interface
|
|
166
|
+
|
|
167
|
+
@cached_arg_value
|
|
168
|
+
def cell_arg_value(self, device) -> CellArg:
|
|
169
|
+
args = self.CellArg()
|
|
170
|
+
args.res = self.res
|
|
171
|
+
args.cell_size = self.cell_size
|
|
172
|
+
args.origin = self.bounds_lo
|
|
173
|
+
return args
|
|
174
|
+
|
|
175
|
+
@wp.func
|
|
176
|
+
def cell_position(args: CellArg, s: Sample):
|
|
177
|
+
cell = Grid2D.get_cell(args.res, s.element_index)
|
|
178
|
+
return (
|
|
179
|
+
wp.vec2(
|
|
180
|
+
(float(cell[0]) + s.element_coords[0]) * args.cell_size[0],
|
|
181
|
+
(float(cell[1]) + s.element_coords[1]) * args.cell_size[1],
|
|
182
|
+
)
|
|
183
|
+
+ args.origin
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
@wp.func
|
|
187
|
+
def cell_deformation_gradient(args: CellArg, s: Sample):
|
|
188
|
+
return wp.diag(args.cell_size)
|
|
189
|
+
|
|
190
|
+
@wp.func
|
|
191
|
+
def cell_inverse_deformation_gradient(args: CellArg, s: Sample):
|
|
192
|
+
return wp.diag(wp.cw_div(wp.vec2(1.0), args.cell_size))
|
|
193
|
+
|
|
194
|
+
@wp.func
|
|
195
|
+
def cell_lookup(args: CellArg, pos: wp.vec2):
|
|
196
|
+
loc_pos = wp.cw_div(pos - args.origin, args.cell_size)
|
|
197
|
+
x = wp.clamp(loc_pos[0], 0.0, float(args.res[0]))
|
|
198
|
+
y = wp.clamp(loc_pos[1], 0.0, float(args.res[1]))
|
|
199
|
+
|
|
200
|
+
x_cell = wp.min(wp.floor(x), float(args.res[0]) - 1.0)
|
|
201
|
+
y_cell = wp.min(wp.floor(y), float(args.res[1]) - 1.0)
|
|
202
|
+
|
|
203
|
+
coords = Coords(x - x_cell, y - y_cell, 0.0)
|
|
204
|
+
cell_index = Grid2D.cell_index(args.res, Grid2D.Cell(int(x_cell), int(y_cell)))
|
|
205
|
+
|
|
206
|
+
return make_free_sample(cell_index, coords)
|
|
207
|
+
|
|
208
|
+
@wp.func
|
|
209
|
+
def cell_lookup(args: CellArg, pos: wp.vec2, guess: Sample):
|
|
210
|
+
return Grid2D.cell_lookup(args, pos)
|
|
211
|
+
|
|
212
|
+
@wp.func
|
|
213
|
+
def cell_measure(args: CellArg, s: Sample):
|
|
214
|
+
return args.cell_size[0] * args.cell_size[1]
|
|
215
|
+
|
|
216
|
+
@wp.func
|
|
217
|
+
def cell_normal(args: CellArg, s: Sample):
|
|
218
|
+
return wp.vec2(0.0)
|
|
219
|
+
|
|
220
|
+
@cached_arg_value
|
|
221
|
+
def side_arg_value(self, device) -> SideArg:
|
|
222
|
+
args = self.SideArg()
|
|
223
|
+
|
|
224
|
+
args.axis_offsets = wp.vec2i(
|
|
225
|
+
0,
|
|
226
|
+
self.res[0],
|
|
227
|
+
)
|
|
228
|
+
args.cell_count = self.cell_count()
|
|
229
|
+
args.cell_arg = self.cell_arg_value(device)
|
|
230
|
+
return args
|
|
231
|
+
|
|
232
|
+
def side_index_arg_value(self, device) -> SideIndexArg:
|
|
233
|
+
return self.side_arg_value(device)
|
|
234
|
+
|
|
235
|
+
@wp.func
|
|
236
|
+
def boundary_side_index(args: SideArg, boundary_side_index: int):
|
|
237
|
+
"""Boundary side to side index"""
|
|
238
|
+
|
|
239
|
+
axis_side_index = boundary_side_index // 2
|
|
240
|
+
border = boundary_side_index - 2 * axis_side_index
|
|
241
|
+
|
|
242
|
+
if axis_side_index < args.axis_offsets[1]:
|
|
243
|
+
axis = 0
|
|
244
|
+
else:
|
|
245
|
+
axis = 1
|
|
246
|
+
|
|
247
|
+
longitude = axis_side_index - args.axis_offsets[axis]
|
|
248
|
+
altitude = border * args.cell_arg.res[axis]
|
|
249
|
+
|
|
250
|
+
side = Grid2D.Side(axis, wp.vec2i(altitude, longitude))
|
|
251
|
+
return Grid2D.side_index(args, side)
|
|
252
|
+
|
|
253
|
+
@wp.func
|
|
254
|
+
def side_position(args: SideArg, s: Sample):
|
|
255
|
+
side = Grid2D.get_side(args, s.element_index)
|
|
256
|
+
|
|
257
|
+
coord = wp.select((side.origin[0] == 0) == (side.axis == 0), 1.0 - s.element_coords[0], s.element_coords[0])
|
|
258
|
+
|
|
259
|
+
local_pos = wp.vec2(
|
|
260
|
+
float(side.origin[0]),
|
|
261
|
+
float(side.origin[1]) + coord,
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
pos = args.cell_arg.origin + wp.cw_mul(Grid2D._rotate(side.axis, local_pos), args.cell_arg.cell_size)
|
|
265
|
+
|
|
266
|
+
return pos
|
|
267
|
+
|
|
268
|
+
@wp.func
|
|
269
|
+
def side_deformation_gradient(args: SideArg, s: Sample):
|
|
270
|
+
side = Grid2D.get_side(args, s.element_index)
|
|
271
|
+
|
|
272
|
+
sign = wp.select((side.origin[0] == 0) == (side.axis == 0), -1.0, 1.0)
|
|
273
|
+
|
|
274
|
+
return wp.cw_mul(Grid2D._rotate(side.axis, wp.vec2(0.0, sign)), args.cell_arg.cell_size)
|
|
275
|
+
|
|
276
|
+
@wp.func
|
|
277
|
+
def side_inner_inverse_deformation_gradient(args: SideArg, s: Sample):
|
|
278
|
+
return Grid2D.cell_inverse_deformation_gradient(args.cell_arg, s)
|
|
279
|
+
|
|
280
|
+
@wp.func
|
|
281
|
+
def side_outer_inverse_deformation_gradient(args: SideArg, s: Sample):
|
|
282
|
+
return Grid2D.cell_inverse_deformation_gradient(args.cell_arg, s)
|
|
283
|
+
|
|
284
|
+
@wp.func
|
|
285
|
+
def side_measure(args: SideArg, s: Sample):
|
|
286
|
+
side = Grid2D.get_side(args, s.element_index)
|
|
287
|
+
long_axis = Grid2D.ROTATION[side.axis, 1]
|
|
288
|
+
return args.cell_arg.cell_size[long_axis]
|
|
289
|
+
|
|
290
|
+
@wp.func
|
|
291
|
+
def side_measure_ratio(args: SideArg, s: Sample):
|
|
292
|
+
side = Grid2D.get_side(args, s.element_index)
|
|
293
|
+
alt_axis = Grid2D.ROTATION[side.axis, 0]
|
|
294
|
+
return 1.0 / args.cell_arg.cell_size[alt_axis]
|
|
295
|
+
|
|
296
|
+
@wp.func
|
|
297
|
+
def side_normal(args: SideArg, s: Sample):
|
|
298
|
+
side = Grid2D.get_side(args, s.element_index)
|
|
299
|
+
|
|
300
|
+
sign = wp.select(side.origin[0] == 0, 1.0, -1.0)
|
|
301
|
+
|
|
302
|
+
local_n = wp.vec2(sign, 0.0)
|
|
303
|
+
return Grid2D._rotate(side.axis, local_n)
|
|
304
|
+
|
|
305
|
+
@wp.func
|
|
306
|
+
def side_inner_cell_index(arg: SideArg, side_index: ElementIndex):
|
|
307
|
+
side = Grid2D.get_side(arg, side_index)
|
|
308
|
+
|
|
309
|
+
inner_alt = wp.select(side.origin[0] == 0, side.origin[0] - 1, 0)
|
|
310
|
+
|
|
311
|
+
inner_origin = wp.vec2i(inner_alt, side.origin[1])
|
|
312
|
+
|
|
313
|
+
cell = Grid2D._rotate(side.axis, inner_origin)
|
|
314
|
+
return Grid2D.cell_index(arg.cell_arg.res, cell)
|
|
315
|
+
|
|
316
|
+
@wp.func
|
|
317
|
+
def side_outer_cell_index(arg: SideArg, side_index: ElementIndex):
|
|
318
|
+
side = Grid2D.get_side(arg, side_index)
|
|
319
|
+
|
|
320
|
+
alt_axis = Grid2D.ROTATION[side.axis, 0]
|
|
321
|
+
outer_alt = wp.select(
|
|
322
|
+
side.origin[0] == arg.cell_arg.res[alt_axis], side.origin[0], arg.cell_arg.res[alt_axis] - 1
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
outer_origin = wp.vec2i(outer_alt, side.origin[1])
|
|
326
|
+
|
|
327
|
+
cell = Grid2D._rotate(side.axis, outer_origin)
|
|
328
|
+
return Grid2D.cell_index(arg.cell_arg.res, cell)
|
|
329
|
+
|
|
330
|
+
@wp.func
|
|
331
|
+
def side_inner_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
332
|
+
side = Grid2D.get_side(args, side_index)
|
|
333
|
+
|
|
334
|
+
inner_alt = wp.select(side.origin[0] == 0, 1.0, 0.0)
|
|
335
|
+
|
|
336
|
+
side_coord = wp.select((side.origin[0] == 0) == (side.axis == 0), 1.0 - side_coords[0], side_coords[0])
|
|
337
|
+
|
|
338
|
+
coords = Grid2D._rotate(side.axis, wp.vec2(inner_alt, side_coord))
|
|
339
|
+
return Coords(coords[0], coords[1], 0.0)
|
|
340
|
+
|
|
341
|
+
@wp.func
|
|
342
|
+
def side_outer_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
343
|
+
side = Grid2D.get_side(args, side_index)
|
|
344
|
+
|
|
345
|
+
alt_axis = Grid2D.ROTATION[side.axis, 0]
|
|
346
|
+
outer_alt = wp.select(side.origin[0] == args.cell_arg.res[alt_axis], 0.0, 1.0)
|
|
347
|
+
|
|
348
|
+
side_coord = wp.select((side.origin[0] == 0) == (side.axis == 0), 1.0 - side_coords[0], side_coords[0])
|
|
349
|
+
|
|
350
|
+
coords = Grid2D._rotate(side.axis, wp.vec2(outer_alt, side_coord))
|
|
351
|
+
return Coords(coords[0], coords[1], 0.0)
|
|
352
|
+
|
|
353
|
+
@wp.func
|
|
354
|
+
def side_from_cell_coords(
|
|
355
|
+
args: SideArg,
|
|
356
|
+
side_index: ElementIndex,
|
|
357
|
+
element_index: ElementIndex,
|
|
358
|
+
element_coords: Coords,
|
|
359
|
+
):
|
|
360
|
+
side = Grid2D.get_side(args, side_index)
|
|
361
|
+
cell = Grid2D.get_cell(args.cell_arg.res, element_index)
|
|
362
|
+
|
|
363
|
+
if float(side.origin[0] - cell[side.axis]) == element_coords[side.axis]:
|
|
364
|
+
long_axis = Grid2D.ROTATION[side.axis, 1]
|
|
365
|
+
axis_coord = element_coords[long_axis]
|
|
366
|
+
side_coord = wp.select((side.origin[0] == 0) == (side.axis == 0), 1.0 - axis_coord, axis_coord)
|
|
367
|
+
return Coords(side_coord, 0.0, 0.0)
|
|
368
|
+
|
|
369
|
+
return Coords(OUTSIDE)
|
|
370
|
+
|
|
371
|
+
@wp.func
|
|
372
|
+
def side_to_cell_arg(side_arg: SideArg):
|
|
373
|
+
return side_arg.cell_arg
|