warp-lang 1.0.0b2__py3-none-win_amd64.whl → 1.0.0b6__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.
- docs/conf.py +17 -5
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/env/env_usd.py +4 -1
- examples/env/environment.py +8 -9
- examples/example_dem.py +34 -33
- examples/example_diffray.py +364 -337
- examples/example_fluid.py +32 -23
- examples/example_jacobian_ik.py +97 -93
- examples/example_marching_cubes.py +6 -16
- examples/example_mesh.py +6 -16
- examples/example_mesh_intersect.py +16 -14
- examples/example_nvdb.py +14 -16
- examples/example_raycast.py +14 -13
- examples/example_raymarch.py +16 -23
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +82 -78
- examples/example_sim_cloth.py +45 -48
- examples/example_sim_fk_grad.py +51 -44
- examples/example_sim_fk_grad_torch.py +47 -40
- examples/example_sim_grad_bounce.py +108 -133
- examples/example_sim_grad_cloth.py +99 -113
- examples/example_sim_granular.py +5 -6
- examples/{example_sim_sdf_shape.py → example_sim_granular_collision_sdf.py} +37 -26
- examples/example_sim_neo_hookean.py +51 -55
- examples/example_sim_particle_chain.py +4 -4
- examples/example_sim_quadruped.py +126 -81
- examples/example_sim_rigid_chain.py +54 -61
- examples/example_sim_rigid_contact.py +66 -70
- examples/example_sim_rigid_fem.py +3 -3
- examples/example_sim_rigid_force.py +1 -1
- examples/example_sim_rigid_gyroscopic.py +3 -4
- examples/example_sim_rigid_kinematics.py +28 -39
- examples/example_sim_trajopt.py +112 -110
- examples/example_sph.py +9 -8
- examples/example_wave.py +7 -7
- examples/fem/bsr_utils.py +30 -17
- examples/fem/example_apic_fluid.py +85 -69
- examples/fem/example_convection_diffusion.py +97 -93
- examples/fem/example_convection_diffusion_dg.py +142 -149
- examples/fem/example_convection_diffusion_dg0.py +141 -136
- examples/fem/example_deformed_geometry.py +146 -0
- examples/fem/example_diffusion.py +115 -84
- examples/fem/example_diffusion_3d.py +116 -86
- examples/fem/example_diffusion_mgpu.py +102 -79
- examples/fem/example_mixed_elasticity.py +139 -100
- examples/fem/example_navier_stokes.py +175 -162
- examples/fem/example_stokes.py +143 -111
- examples/fem/example_stokes_transfer.py +186 -157
- examples/fem/mesh_utils.py +59 -97
- examples/fem/plot_utils.py +138 -17
- tools/ci/publishing/build_nodes_info.py +54 -0
- warp/__init__.py +4 -3
- 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 +836 -492
- warp/codegen.py +864 -553
- warp/config.py +3 -1
- warp/context.py +389 -172
- warp/fem/__init__.py +24 -6
- warp/fem/cache.py +318 -25
- warp/fem/dirichlet.py +7 -3
- warp/fem/domain.py +14 -0
- warp/fem/field/__init__.py +30 -38
- warp/fem/field/field.py +149 -0
- warp/fem/field/nodal_field.py +244 -138
- warp/fem/field/restriction.py +8 -6
- warp/fem/field/test.py +127 -59
- warp/fem/field/trial.py +117 -60
- warp/fem/geometry/__init__.py +5 -1
- warp/fem/geometry/deformed_geometry.py +271 -0
- warp/fem/geometry/element.py +24 -1
- warp/fem/geometry/geometry.py +86 -14
- warp/fem/geometry/grid_2d.py +112 -54
- warp/fem/geometry/grid_3d.py +134 -65
- warp/fem/geometry/hexmesh.py +953 -0
- warp/fem/geometry/partition.py +85 -33
- warp/fem/geometry/quadmesh_2d.py +532 -0
- warp/fem/geometry/tetmesh.py +451 -115
- warp/fem/geometry/trimesh_2d.py +197 -92
- warp/fem/integrate.py +534 -268
- warp/fem/operator.py +58 -31
- warp/fem/polynomial.py +11 -0
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +150 -58
- warp/fem/quadrature/quadrature.py +209 -57
- warp/fem/space/__init__.py +230 -53
- warp/fem/space/basis_space.py +489 -0
- warp/fem/space/collocated_function_space.py +105 -0
- warp/fem/space/dof_mapper.py +49 -2
- warp/fem/space/function_space.py +90 -39
- warp/fem/space/grid_2d_function_space.py +149 -496
- warp/fem/space/grid_3d_function_space.py +173 -538
- warp/fem/space/hexmesh_function_space.py +352 -0
- warp/fem/space/partition.py +129 -76
- warp/fem/space/quadmesh_2d_function_space.py +369 -0
- warp/fem/space/restriction.py +46 -34
- 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 +132 -1039
- warp/fem/space/topology.py +295 -0
- warp/fem/space/trimesh_2d_function_space.py +104 -742
- warp/fem/types.py +13 -11
- warp/fem/utils.py +335 -60
- warp/native/array.h +120 -34
- warp/native/builtin.h +101 -72
- warp/native/bvh.cpp +73 -325
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +22 -40
- warp/native/clang/clang.cpp +1 -0
- warp/native/crt.h +2 -0
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1522 -1243
- warp/native/intersect.h +19 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +76 -17
- warp/native/mesh.cpp +33 -108
- warp/native/mesh.cu +114 -18
- warp/native/mesh.h +395 -40
- warp/native/noise.h +272 -329
- warp/native/quat.h +51 -8
- warp/native/rand.h +44 -34
- warp/native/reduce.cpp +1 -1
- warp/native/sparse.cpp +4 -4
- warp/native/sparse.cu +163 -155
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +18 -14
- warp/native/vec.h +103 -21
- warp/native/warp.cpp +2 -1
- warp/native/warp.cu +28 -3
- warp/native/warp.h +4 -3
- warp/render/render_opengl.py +261 -109
- warp/sim/__init__.py +1 -2
- warp/sim/articulation.py +385 -185
- warp/sim/import_mjcf.py +59 -48
- warp/sim/import_urdf.py +15 -15
- warp/sim/import_usd.py +174 -102
- warp/sim/inertia.py +17 -18
- warp/sim/integrator_xpbd.py +4 -3
- warp/sim/model.py +330 -250
- warp/sim/render.py +1 -1
- warp/sparse.py +625 -152
- warp/stubs.py +341 -309
- warp/tape.py +9 -6
- 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 +94 -74
- warp/tests/test_array.py +82 -101
- warp/tests/test_array_reduce.py +57 -23
- warp/tests/test_atomic.py +64 -28
- warp/tests/test_bool.py +22 -12
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +18 -18
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +165 -134
- 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 +237 -0
- warp/tests/test_fabricarray.py +22 -24
- warp/tests/test_fast_math.py +15 -11
- warp/tests/test_fem.py +1034 -124
- warp/tests/test_fp16.py +23 -16
- warp/tests/test_func.py +187 -86
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +123 -181
- warp/tests/test_grad_customs.py +176 -0
- warp/tests/test_hash_grid.py +35 -34
- warp/tests/test_import.py +10 -23
- warp/tests/test_indexedarray.py +24 -25
- 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_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 +304 -69
- warp/tests/test_matmul_lite.py +410 -0
- warp/tests/test_mesh.py +60 -22
- warp/tests/test_mesh_query_aabb.py +21 -25
- warp/tests/test_mesh_query_point.py +111 -22
- warp/tests/test_mesh_query_ray.py +12 -24
- 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 +90 -86
- warp/tests/test_transient_module.py +10 -12
- warp/tests/test_types.py +363 -0
- warp/tests/test_utils.py +451 -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 +418 -376
- warp/tests/test_volume_write.py +124 -134
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/unittest_utils.py +342 -0
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
- warp/thirdparty/appdirs.py +36 -45
- warp/thirdparty/unittest_parallel.py +589 -0
- warp/types.py +622 -211
- warp/utils.py +54 -393
- warp_lang-1.0.0b6.dist-info/METADATA +238 -0
- warp_lang-1.0.0b6.dist-info/RECORD +409 -0
- {warp_lang-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- examples/example_cache_management.py +0 -40
- examples/example_multigpu.py +0 -54
- examples/example_struct.py +0 -65
- examples/fem/example_stokes_transfer_3d.py +0 -210
- warp/bin/warp-clang.so +0 -0
- warp/bin/warp.so +0 -0
- warp/fem/field/discrete_field.py +0 -80
- warp/fem/space/nodal_function_space.py +0 -233
- warp/tests/test_all.py +0 -223
- 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-1.0.0b2.dist-info/METADATA +0 -26
- warp_lang-1.0.0b2.dist-info/RECORD +0 -380
- /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-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/fem/geometry/grid_3d.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
from typing import Any
|
|
1
2
|
import warp as wp
|
|
2
3
|
|
|
3
|
-
from warp.fem.types import ElementIndex, Coords, Sample,
|
|
4
|
-
from warp.fem.
|
|
4
|
+
from warp.fem.types import ElementIndex, Coords, Sample, make_free_sample, OUTSIDE
|
|
5
|
+
from warp.fem.cache import cached_arg_value
|
|
5
6
|
|
|
6
7
|
from .geometry import Geometry
|
|
7
8
|
from .element import Square, Cube
|
|
@@ -9,19 +10,24 @@ from .element import Square, Cube
|
|
|
9
10
|
|
|
10
11
|
@wp.struct
|
|
11
12
|
class Grid3DCellArg:
|
|
12
|
-
res: vec3i
|
|
13
|
+
res: wp.vec3i
|
|
13
14
|
cell_size: wp.vec3
|
|
14
15
|
origin: wp.vec3
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
_mat32 = wp.mat(shape=(3, 2), dtype=float)
|
|
19
|
+
|
|
20
|
+
|
|
17
21
|
class Grid3D(Geometry):
|
|
18
22
|
"""Three-dimensional regular grid geometry"""
|
|
19
23
|
|
|
24
|
+
dimension = 3
|
|
25
|
+
|
|
20
26
|
Permutation = wp.types.matrix(shape=(3, 3), dtype=int)
|
|
21
27
|
LOC_TO_WORLD = wp.constant(Permutation(0, 1, 2, 1, 2, 0, 2, 0, 1))
|
|
22
28
|
WORLD_TO_LOC = wp.constant(Permutation(0, 1, 2, 2, 0, 1, 1, 2, 0))
|
|
23
29
|
|
|
24
|
-
def __init__(self, res: vec3i, bounds_lo: wp.vec3 = wp.vec3(0.0), bounds_hi: wp.vec3 = wp.vec3(1.0)):
|
|
30
|
+
def __init__(self, res: wp.vec3i, bounds_lo: wp.vec3 = wp.vec3(0.0), bounds_hi: wp.vec3 = wp.vec3(1.0)):
|
|
25
31
|
"""Constructs a dense 3D grid
|
|
26
32
|
|
|
27
33
|
Args:
|
|
@@ -30,7 +36,6 @@ class Grid3D(Geometry):
|
|
|
30
36
|
bounds_up: Position of the upper bound of the axis-aligned grid
|
|
31
37
|
"""
|
|
32
38
|
|
|
33
|
-
self.dimension = 3
|
|
34
39
|
self.bounds_lo = bounds_lo
|
|
35
40
|
self.bounds_hi = bounds_hi
|
|
36
41
|
|
|
@@ -38,7 +43,12 @@ class Grid3D(Geometry):
|
|
|
38
43
|
|
|
39
44
|
@property
|
|
40
45
|
def extents(self) -> wp.vec3:
|
|
41
|
-
|
|
46
|
+
# Avoid using native sub due to higher over of calling builtins from Python
|
|
47
|
+
return wp.vec3(
|
|
48
|
+
self.bounds_hi[0] - self.bounds_lo[0],
|
|
49
|
+
self.bounds_hi[1] - self.bounds_lo[1],
|
|
50
|
+
self.bounds_hi[2] - self.bounds_lo[2],
|
|
51
|
+
)
|
|
42
52
|
|
|
43
53
|
@property
|
|
44
54
|
def cell_size(self) -> wp.vec3:
|
|
@@ -62,6 +72,13 @@ class Grid3D(Geometry):
|
|
|
62
72
|
+ (self.res[0]) * (self.res[1]) * (self.res[2] + 1)
|
|
63
73
|
)
|
|
64
74
|
|
|
75
|
+
def edge_count(self):
|
|
76
|
+
return (
|
|
77
|
+
(self.res[0] + 1) * (self.res[1] + 1) * (self.res[2])
|
|
78
|
+
+ (self.res[0]) * (self.res[1] + 1) * (self.res[2] + 1)
|
|
79
|
+
+ (self.res[0] + 1) * (self.res[1]) * (self.res[2] + 1)
|
|
80
|
+
)
|
|
81
|
+
|
|
65
82
|
def boundary_side_count(self):
|
|
66
83
|
return 2 * (self.res[1]) * (self.res[2]) + (self.res[0]) * 2 * (self.res[2]) + (self.res[0]) * (self.res[1]) * 2
|
|
67
84
|
|
|
@@ -81,66 +98,58 @@ class Grid3D(Geometry):
|
|
|
81
98
|
|
|
82
99
|
@property
|
|
83
100
|
def strides(self):
|
|
84
|
-
return vec3i(self.res[1] * self.res[2], self.res[2], 1)
|
|
101
|
+
return wp.vec3i(self.res[1] * self.res[2], self.res[2], 1)
|
|
85
102
|
|
|
86
103
|
# Utility device functions
|
|
87
104
|
|
|
88
105
|
CellArg = Grid3DCellArg
|
|
89
|
-
Cell = vec3i
|
|
106
|
+
Cell = wp.vec3i
|
|
90
107
|
|
|
91
108
|
@wp.func
|
|
92
|
-
def _to_3d_index(strides: vec2i, index: int):
|
|
109
|
+
def _to_3d_index(strides: wp.vec2i, index: int):
|
|
93
110
|
x = index // strides[0]
|
|
94
111
|
y = (index - strides[0] * x) // strides[1]
|
|
95
112
|
z = index - strides[0] * x - strides[1] * y
|
|
96
|
-
return vec3i(x, y, z)
|
|
113
|
+
return wp.vec3i(x, y, z)
|
|
97
114
|
|
|
98
115
|
@wp.func
|
|
99
|
-
def _from_3d_index(strides: vec2i, index: vec3i):
|
|
116
|
+
def _from_3d_index(strides: wp.vec2i, index: wp.vec3i):
|
|
100
117
|
return strides[0] * index[0] + strides[1] * index[1] + index[2]
|
|
101
118
|
|
|
102
119
|
@wp.func
|
|
103
|
-
def cell_index(res: vec3i, cell: Cell):
|
|
104
|
-
strides = vec2i(res[1] * res[2], res[2])
|
|
120
|
+
def cell_index(res: wp.vec3i, cell: Cell):
|
|
121
|
+
strides = wp.vec2i(res[1] * res[2], res[2])
|
|
105
122
|
return Grid3D._from_3d_index(strides, cell)
|
|
106
123
|
|
|
107
124
|
@wp.func
|
|
108
|
-
def get_cell(res: vec3i, cell_index: ElementIndex):
|
|
109
|
-
strides = vec2i(res[1] * res[2], res[2])
|
|
125
|
+
def get_cell(res: wp.vec3i, cell_index: ElementIndex):
|
|
126
|
+
strides = wp.vec2i(res[1] * res[2], res[2])
|
|
110
127
|
return Grid3D._to_3d_index(strides, cell_index)
|
|
111
128
|
|
|
112
129
|
@wp.struct
|
|
113
130
|
class Side:
|
|
114
131
|
axis: int # normal
|
|
115
|
-
origin: vec3i # index of vertex at corner (0,0,0)
|
|
132
|
+
origin: wp.vec3i # index of vertex at corner (0,0,0)
|
|
116
133
|
|
|
117
134
|
@wp.struct
|
|
118
135
|
class SideArg:
|
|
119
136
|
cell_count: int
|
|
120
|
-
axis_offsets: vec3i
|
|
137
|
+
axis_offsets: wp.vec3i
|
|
121
138
|
cell_arg: Grid3DCellArg
|
|
122
139
|
|
|
123
140
|
SideIndexArg = SideArg
|
|
124
141
|
|
|
125
142
|
@wp.func
|
|
126
|
-
def _world_to_local(axis: int, vec:
|
|
127
|
-
return
|
|
143
|
+
def _world_to_local(axis: int, vec: Any):
|
|
144
|
+
return type(vec)(
|
|
128
145
|
vec[Grid3D.LOC_TO_WORLD[axis, 0]],
|
|
129
146
|
vec[Grid3D.LOC_TO_WORLD[axis, 1]],
|
|
130
147
|
vec[Grid3D.LOC_TO_WORLD[axis, 2]],
|
|
131
148
|
)
|
|
132
149
|
|
|
133
150
|
@wp.func
|
|
134
|
-
def _local_to_world(axis: int, vec:
|
|
135
|
-
return
|
|
136
|
-
vec[Grid3D.WORLD_TO_LOC[axis, 0]],
|
|
137
|
-
vec[Grid3D.WORLD_TO_LOC[axis, 1]],
|
|
138
|
-
vec[Grid3D.WORLD_TO_LOC[axis, 2]],
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
@wp.func
|
|
142
|
-
def _local_to_world(axis: int, vec: wp.vec3):
|
|
143
|
-
return wp.vec3(
|
|
151
|
+
def _local_to_world(axis: int, vec: Any):
|
|
152
|
+
return type(vec)(
|
|
144
153
|
vec[Grid3D.WORLD_TO_LOC[axis, 0]],
|
|
145
154
|
vec[Grid3D.WORLD_TO_LOC[axis, 1]],
|
|
146
155
|
vec[Grid3D.WORLD_TO_LOC[axis, 2]],
|
|
@@ -186,17 +195,18 @@ class Grid3D(Geometry):
|
|
|
186
195
|
longitude = lat_long // latitude_res
|
|
187
196
|
latitude = lat_long - longitude * latitude_res
|
|
188
197
|
|
|
189
|
-
origin_loc = vec3i(altitude, longitude, latitude)
|
|
198
|
+
origin_loc = wp.vec3i(altitude, longitude, latitude)
|
|
190
199
|
|
|
191
200
|
return Grid3D.Side(axis, origin_loc)
|
|
192
201
|
|
|
193
202
|
# Geometry device interface
|
|
194
203
|
|
|
204
|
+
@cached_arg_value
|
|
195
205
|
def cell_arg_value(self, device) -> CellArg:
|
|
196
206
|
args = self.CellArg()
|
|
197
207
|
args.res = self.res
|
|
198
|
-
args.cell_size = self.cell_size
|
|
199
208
|
args.origin = self.bounds_lo
|
|
209
|
+
args.cell_size = self.cell_size
|
|
200
210
|
return args
|
|
201
211
|
|
|
202
212
|
@wp.func
|
|
@@ -211,6 +221,14 @@ class Grid3D(Geometry):
|
|
|
211
221
|
+ args.origin
|
|
212
222
|
)
|
|
213
223
|
|
|
224
|
+
@wp.func
|
|
225
|
+
def cell_deformation_gradient(args: CellArg, s: Sample):
|
|
226
|
+
return wp.diag(args.cell_size)
|
|
227
|
+
|
|
228
|
+
@wp.func
|
|
229
|
+
def cell_inverse_deformation_gradient(args: CellArg, s: Sample):
|
|
230
|
+
return wp.diag(wp.cw_div(wp.vec3(1.0), args.cell_size))
|
|
231
|
+
|
|
214
232
|
@wp.func
|
|
215
233
|
def cell_lookup(args: CellArg, pos: wp.vec3):
|
|
216
234
|
loc_pos = wp.cw_div(pos - args.origin, args.cell_size)
|
|
@@ -225,37 +243,34 @@ class Grid3D(Geometry):
|
|
|
225
243
|
coords = Coords(x - x_cell, y - y_cell, z - z_cell)
|
|
226
244
|
cell_index = Grid3D.cell_index(args.res, Grid3D.Cell(int(x_cell), int(y_cell), int(z_cell)))
|
|
227
245
|
|
|
228
|
-
return
|
|
246
|
+
return make_free_sample(cell_index, coords)
|
|
229
247
|
|
|
230
248
|
@wp.func
|
|
231
249
|
def cell_lookup(args: CellArg, pos: wp.vec3, guess: Sample):
|
|
232
250
|
return Grid3D.cell_lookup(args, pos)
|
|
233
251
|
|
|
234
|
-
@wp.func
|
|
235
|
-
def cell_measure(args: CellArg, cell_index: ElementIndex, coords: Coords):
|
|
236
|
-
return args.cell_size[0] * args.cell_size[1] * args.cell_size[2]
|
|
237
|
-
|
|
238
252
|
@wp.func
|
|
239
253
|
def cell_measure(args: CellArg, s: Sample):
|
|
240
|
-
return
|
|
241
|
-
|
|
242
|
-
@wp.func
|
|
243
|
-
def cell_measure_ratio(args: CellArg, s: Sample):
|
|
244
|
-
return 1.0
|
|
254
|
+
return args.cell_size[0] * args.cell_size[1] * args.cell_size[2]
|
|
245
255
|
|
|
246
256
|
@wp.func
|
|
247
257
|
def cell_normal(args: CellArg, s: Sample):
|
|
248
258
|
return wp.vec3(0.0)
|
|
249
259
|
|
|
260
|
+
@wp.func
|
|
261
|
+
def cell_transform_reference_gradient(args: CellArg, cell_index: ElementIndex, coords: Coords, ref_grad: wp.vec3):
|
|
262
|
+
return wp.cw_div(ref_grad, args.cell_size)
|
|
263
|
+
|
|
264
|
+
@cached_arg_value
|
|
250
265
|
def side_arg_value(self, device) -> SideArg:
|
|
251
266
|
args = self.SideArg()
|
|
252
267
|
|
|
253
|
-
axis_dims = vec3i(
|
|
268
|
+
axis_dims = wp.vec3i(
|
|
254
269
|
self.res[1] * self.res[2],
|
|
255
270
|
self.res[2] * self.res[0],
|
|
256
271
|
self.res[0] * self.res[1],
|
|
257
272
|
)
|
|
258
|
-
args.axis_offsets = vec3i(
|
|
273
|
+
args.axis_offsets = wp.vec3i(
|
|
259
274
|
0,
|
|
260
275
|
axis_dims[0],
|
|
261
276
|
axis_dims[0] + axis_dims[1],
|
|
@@ -289,16 +304,18 @@ class Grid3D(Geometry):
|
|
|
289
304
|
|
|
290
305
|
altitude = border * args.cell_arg.res[axis]
|
|
291
306
|
|
|
292
|
-
side = Grid3D.Side(axis, vec3i(altitude, longitude, latitude))
|
|
307
|
+
side = Grid3D.Side(axis, wp.vec3i(altitude, longitude, latitude))
|
|
293
308
|
return Grid3D.side_index(args, side)
|
|
294
309
|
|
|
295
310
|
@wp.func
|
|
296
311
|
def side_position(args: SideArg, s: Sample):
|
|
297
312
|
side = Grid3D.get_side(args, s.element_index)
|
|
298
313
|
|
|
314
|
+
coord0 = wp.select(side.origin[0] == 0, s.element_coords[0], 1.0 - s.element_coords[0])
|
|
315
|
+
|
|
299
316
|
local_pos = wp.vec3(
|
|
300
317
|
float(side.origin[0]),
|
|
301
|
-
float(side.origin[1]) +
|
|
318
|
+
float(side.origin[1]) + coord0,
|
|
302
319
|
float(side.origin[2]) + s.element_coords[1],
|
|
303
320
|
)
|
|
304
321
|
|
|
@@ -307,15 +324,30 @@ class Grid3D(Geometry):
|
|
|
307
324
|
return pos
|
|
308
325
|
|
|
309
326
|
@wp.func
|
|
310
|
-
def
|
|
311
|
-
side = Grid3D.get_side(args,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
327
|
+
def side_deformation_gradient(args: SideArg, s: Sample):
|
|
328
|
+
side = Grid3D.get_side(args, s.element_index)
|
|
329
|
+
|
|
330
|
+
sign = wp.select(side.origin[0] == 0, 1.0, -1.0)
|
|
331
|
+
|
|
332
|
+
return _mat32(
|
|
333
|
+
wp.cw_mul(Grid3D._local_to_world(side.axis, wp.vec3(0.0, sign, 0.0)), args.cell_arg.cell_size),
|
|
334
|
+
wp.cw_mul(Grid3D._local_to_world(side.axis, wp.vec3(0.0, 0.0, 1.0)), args.cell_arg.cell_size),
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
@wp.func
|
|
338
|
+
def side_inner_inverse_deformation_gradient(args: SideArg, s: Sample):
|
|
339
|
+
return Grid3D.cell_inverse_deformation_gradient(args.cell_arg, s)
|
|
340
|
+
|
|
341
|
+
@wp.func
|
|
342
|
+
def side_outer_inverse_deformation_gradient(args: SideArg, s: Sample):
|
|
343
|
+
return Grid3D.cell_inverse_deformation_gradient(args.cell_arg, s)
|
|
315
344
|
|
|
316
345
|
@wp.func
|
|
317
346
|
def side_measure(args: SideArg, s: Sample):
|
|
318
|
-
|
|
347
|
+
side = Grid3D.get_side(args, s.element_index)
|
|
348
|
+
long_axis = Grid3D.LOC_TO_WORLD[side.axis, 1]
|
|
349
|
+
lat_axis = Grid3D.LOC_TO_WORLD[side.axis, 2]
|
|
350
|
+
return args.cell_arg.cell_size[long_axis] * args.cell_arg.cell_size[lat_axis]
|
|
319
351
|
|
|
320
352
|
@wp.func
|
|
321
353
|
def side_measure_ratio(args: SideArg, s: Sample):
|
|
@@ -327,10 +359,7 @@ class Grid3D(Geometry):
|
|
|
327
359
|
def side_normal(args: SideArg, s: Sample):
|
|
328
360
|
side = Grid3D.get_side(args, s.element_index)
|
|
329
361
|
|
|
330
|
-
|
|
331
|
-
sign = -1.0
|
|
332
|
-
else:
|
|
333
|
-
sign = 1.0
|
|
362
|
+
sign = wp.select(side.origin[0] == 0, 1.0, -1.0)
|
|
334
363
|
|
|
335
364
|
local_n = wp.vec3(sign, 0.0, 0.0)
|
|
336
365
|
return Grid3D._local_to_world(side.axis, local_n)
|
|
@@ -339,12 +368,9 @@ class Grid3D(Geometry):
|
|
|
339
368
|
def side_inner_cell_index(arg: SideArg, side_index: ElementIndex):
|
|
340
369
|
side = Grid3D.get_side(arg, side_index)
|
|
341
370
|
|
|
342
|
-
|
|
343
|
-
inner_alt = 0
|
|
344
|
-
else:
|
|
345
|
-
inner_alt = side.origin[0] - 1
|
|
371
|
+
inner_alt = wp.select(side.origin[0] == 0, side.origin[0] - 1, 0)
|
|
346
372
|
|
|
347
|
-
inner_origin = vec3i(inner_alt, side.origin[1], side.origin[2])
|
|
373
|
+
inner_origin = wp.vec3i(inner_alt, side.origin[1], side.origin[2])
|
|
348
374
|
|
|
349
375
|
cell = Grid3D._local_to_world(side.axis, inner_origin)
|
|
350
376
|
return Grid3D.cell_index(arg.cell_arg.res, cell)
|
|
@@ -355,12 +381,55 @@ class Grid3D(Geometry):
|
|
|
355
381
|
|
|
356
382
|
alt_axis = Grid3D.LOC_TO_WORLD[side.axis, 0]
|
|
357
383
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
outer_alt = side.origin[0]
|
|
384
|
+
outer_alt = wp.select(
|
|
385
|
+
side.origin[0] == arg.cell_arg.res[alt_axis], side.origin[0], arg.cell_arg.res[alt_axis] - 1
|
|
386
|
+
)
|
|
362
387
|
|
|
363
|
-
outer_origin = vec3i(outer_alt, side.origin[1], side.origin[2])
|
|
388
|
+
outer_origin = wp.vec3i(outer_alt, side.origin[1], side.origin[2])
|
|
364
389
|
|
|
365
390
|
cell = Grid3D._local_to_world(side.axis, outer_origin)
|
|
366
391
|
return Grid3D.cell_index(arg.cell_arg.res, cell)
|
|
392
|
+
|
|
393
|
+
@wp.func
|
|
394
|
+
def side_inner_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
395
|
+
side = Grid3D.get_side(args, side_index)
|
|
396
|
+
|
|
397
|
+
inner_alt = wp.select(side.origin[0] == 0, 1.0, 0.0)
|
|
398
|
+
|
|
399
|
+
side_coord0 = wp.select(side.origin[0] == 0, side_coords[0], 1.0 - side_coords[0])
|
|
400
|
+
|
|
401
|
+
return Grid3D._local_to_world(side.axis, wp.vec3(inner_alt, side_coord0, side_coords[1]))
|
|
402
|
+
|
|
403
|
+
@wp.func
|
|
404
|
+
def side_outer_cell_coords(args: SideArg, side_index: ElementIndex, side_coords: Coords):
|
|
405
|
+
side = Grid3D.get_side(args, side_index)
|
|
406
|
+
|
|
407
|
+
alt_axis = Grid3D.LOC_TO_WORLD[side.axis, 0]
|
|
408
|
+
outer_alt = wp.select(side.origin[0] == args.cell_arg.res[alt_axis], 0.0, 1.0)
|
|
409
|
+
|
|
410
|
+
side_coord0 = wp.select(side.origin[0] == 0, side_coords[0], 1.0 - side_coords[0])
|
|
411
|
+
|
|
412
|
+
return Grid3D._local_to_world(side.axis, wp.vec3(outer_alt, side_coord0, side_coords[1]))
|
|
413
|
+
|
|
414
|
+
@wp.func
|
|
415
|
+
def side_from_cell_coords(
|
|
416
|
+
args: SideArg,
|
|
417
|
+
side_index: ElementIndex,
|
|
418
|
+
element_index: ElementIndex,
|
|
419
|
+
element_coords: Coords,
|
|
420
|
+
):
|
|
421
|
+
side = Grid3D.get_side(args, side_index)
|
|
422
|
+
cell = Grid3D.get_cell(args.cell_arg.res, element_index)
|
|
423
|
+
|
|
424
|
+
if float(side.origin[0] - cell[side.axis]) == element_coords[side.axis]:
|
|
425
|
+
long_axis = Grid3D.LOC_TO_WORLD[side.axis, 1]
|
|
426
|
+
lat_axis = Grid3D.LOC_TO_WORLD[side.axis, 2]
|
|
427
|
+
long_coord = element_coords[long_axis]
|
|
428
|
+
long_coord = wp.select(side.origin[0] == 0, long_coord, 1.0 - long_coord)
|
|
429
|
+
return Coords(long_coord, element_coords[lat_axis], 0.0)
|
|
430
|
+
|
|
431
|
+
return Coords(OUTSIDE)
|
|
432
|
+
|
|
433
|
+
@wp.func
|
|
434
|
+
def side_to_cell_arg(side_arg: SideArg):
|
|
435
|
+
return side_arg.cell_arg
|