warp-lang 1.0.0b2__py3-none-manylinux2014_x86_64.whl → 1.0.0b6__py3-none-manylinux2014_x86_64.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.
- 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.so +0 -0
- warp/bin/warp.so +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/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 -378
- /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
|
@@ -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
|
warp/fem/geometry/element.py
CHANGED
|
@@ -5,6 +5,10 @@ from warp.fem.polynomial import Polynomial, quadrature_1d
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class Element:
|
|
8
|
+
def measure() -> float:
|
|
9
|
+
"""Measure (area, volume, ...) of the reference element"""
|
|
10
|
+
raise NotImplementedError
|
|
11
|
+
|
|
8
12
|
@staticmethod
|
|
9
13
|
def instantiate_quadrature(order: int, family: Polynomial) -> Tuple[List[Coords], List[float]]:
|
|
10
14
|
"""Returns a quadrature of a given order for a prototypical element"""
|
|
@@ -25,6 +29,10 @@ def _point_count_from_order(order: int, family: Polynomial):
|
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
class Cube(Element):
|
|
32
|
+
@staticmethod
|
|
33
|
+
def measure() -> float:
|
|
34
|
+
return 1.0
|
|
35
|
+
|
|
28
36
|
@staticmethod
|
|
29
37
|
def instantiate_quadrature(order: int, family: Polynomial):
|
|
30
38
|
if family is None:
|
|
@@ -40,6 +48,10 @@ class Cube(Element):
|
|
|
40
48
|
|
|
41
49
|
|
|
42
50
|
class Square(Element):
|
|
51
|
+
@staticmethod
|
|
52
|
+
def measure() -> float:
|
|
53
|
+
return 1.0
|
|
54
|
+
|
|
43
55
|
@staticmethod
|
|
44
56
|
def instantiate_quadrature(order: int, family: Polynomial):
|
|
45
57
|
if family is None:
|
|
@@ -55,6 +67,10 @@ class Square(Element):
|
|
|
55
67
|
|
|
56
68
|
|
|
57
69
|
class LinearEdge(Element):
|
|
70
|
+
@staticmethod
|
|
71
|
+
def measure() -> float:
|
|
72
|
+
return 1.0
|
|
73
|
+
|
|
58
74
|
@staticmethod
|
|
59
75
|
def instantiate_quadrature(order: int, family: Polynomial):
|
|
60
76
|
if family is None:
|
|
@@ -68,6 +84,10 @@ class LinearEdge(Element):
|
|
|
68
84
|
|
|
69
85
|
|
|
70
86
|
class Triangle(Element):
|
|
87
|
+
@staticmethod
|
|
88
|
+
def measure() -> float:
|
|
89
|
+
return 0.5
|
|
90
|
+
|
|
71
91
|
@staticmethod
|
|
72
92
|
def instantiate_quadrature(order: int, family: Polynomial):
|
|
73
93
|
if family is not None:
|
|
@@ -406,6 +426,10 @@ class Triangle(Element):
|
|
|
406
426
|
|
|
407
427
|
|
|
408
428
|
class Tetrahedron(Element):
|
|
429
|
+
@staticmethod
|
|
430
|
+
def measure() -> float:
|
|
431
|
+
return 1.0 / 6.0
|
|
432
|
+
|
|
409
433
|
@staticmethod
|
|
410
434
|
def instantiate_quadrature(order: int, family: Polynomial):
|
|
411
435
|
if family is not None:
|
|
@@ -436,7 +460,6 @@ class Tetrahedron(Element):
|
|
|
436
460
|
|
|
437
461
|
# TODO: add Witherden and Vincent 2015,
|
|
438
462
|
|
|
439
|
-
|
|
440
463
|
if order <= 1:
|
|
441
464
|
weights = [1.0]
|
|
442
465
|
coords = [Coords(1.0 / 4.0, 1.0 / 4.0, 1.0 / 4.0)]
|
warp/fem/geometry/geometry.py
CHANGED
|
@@ -3,6 +3,8 @@ from typing import Any
|
|
|
3
3
|
import warp as wp
|
|
4
4
|
|
|
5
5
|
from warp.fem.types import Sample, ElementIndex, Coords
|
|
6
|
+
from warp.fem import cache
|
|
7
|
+
|
|
6
8
|
from .element import Element
|
|
7
9
|
|
|
8
10
|
|
|
@@ -16,12 +18,15 @@ class Geometry:
|
|
|
16
18
|
dimension: int = 0
|
|
17
19
|
|
|
18
20
|
def cell_count(self):
|
|
21
|
+
"""Number of cells in the geometry"""
|
|
19
22
|
raise NotImplementedError
|
|
20
23
|
|
|
21
24
|
def side_count(self):
|
|
25
|
+
"""Number of sides in the geometry"""
|
|
22
26
|
raise NotImplementedError
|
|
23
27
|
|
|
24
28
|
def boundary_side_count(self):
|
|
29
|
+
"""Number of boundary sides (sides with a single neighbour cell) in the geometry"""
|
|
25
30
|
raise NotImplementedError
|
|
26
31
|
|
|
27
32
|
def reference_cell(self) -> Element:
|
|
@@ -40,75 +45,142 @@ class Geometry:
|
|
|
40
45
|
return self.name
|
|
41
46
|
|
|
42
47
|
CellArg: wp.codegen.Struct
|
|
43
|
-
"""Structure containing arguments to be passed to device
|
|
48
|
+
"""Structure containing arguments to be passed to device functions evaluating cell-related quantities"""
|
|
44
49
|
|
|
45
50
|
SideArg: wp.codegen.Struct
|
|
46
|
-
"""Structure containing arguments to be passed to device
|
|
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"""
|
|
47
55
|
|
|
56
|
+
@staticmethod
|
|
48
57
|
def cell_arg_value(self, device) -> "Geometry.CellArg":
|
|
49
58
|
"""Value of the arguments to be passed to cell-related device functions"""
|
|
50
59
|
raise NotImplementedError
|
|
51
60
|
|
|
61
|
+
@staticmethod
|
|
52
62
|
def cell_position(args: "Geometry.CellArg", s: "Sample"):
|
|
53
|
-
"""Device function returning the
|
|
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"""
|
|
54
69
|
raise NotImplementedError
|
|
55
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
|
|
56
79
|
def cell_lookup(args: "Geometry.CellArg", pos: Any):
|
|
57
80
|
"""Device function returning the cell sample point corresponding to a world position"""
|
|
58
81
|
raise NotImplementedError
|
|
59
82
|
|
|
83
|
+
@staticmethod
|
|
60
84
|
def cell_lookup(args: "Geometry.CellArg", pos: Any, guess: "Sample"):
|
|
61
85
|
"""Device function returning the cell sample point corresponding to a world position. Can use guess for faster lookup"""
|
|
62
86
|
raise NotImplementedError
|
|
63
87
|
|
|
64
|
-
|
|
65
|
-
"""Device function returning the measure determinant (e.g. volume, area) at a given point"""
|
|
66
|
-
raise NotImplementedError
|
|
67
|
-
|
|
88
|
+
@staticmethod
|
|
68
89
|
def cell_measure(args: "Geometry.CellArg", s: "Sample"):
|
|
69
90
|
"""Device function returning the measure determinant (e.g. volume, area) at a given point"""
|
|
70
91
|
raise NotImplementedError
|
|
71
92
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
@wp.func
|
|
94
|
+
def cell_measure_ratio(args: Any, s: Sample):
|
|
95
|
+
return 1.0
|
|
75
96
|
|
|
97
|
+
@staticmethod
|
|
76
98
|
def cell_normal(args: "Geometry.CellArg", s: "Sample"):
|
|
77
|
-
"""Device function returning the element normal at a sample point
|
|
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."""
|
|
78
102
|
raise NotImplementedError
|
|
79
103
|
|
|
104
|
+
@staticmethod
|
|
80
105
|
def side_arg_value(self, device) -> "Geometry.SideArg":
|
|
81
106
|
"""Value of the arguments to be passed to side-related device functions"""
|
|
82
107
|
raise NotImplementedError
|
|
83
108
|
|
|
84
|
-
|
|
109
|
+
@staticmethod
|
|
110
|
+
def boundary_side_index(args: "Geometry.SideIndexArg", boundary_side_index: int):
|
|
85
111
|
"""Device function returning the side index corresponding to a boundary side"""
|
|
86
112
|
raise NotImplementedError
|
|
87
113
|
|
|
114
|
+
@staticmethod
|
|
88
115
|
def side_position(args: "Geometry.SideArg", s: "Sample"):
|
|
89
116
|
"""Device function returning the side position at a sample point"""
|
|
90
117
|
raise NotImplementedError
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
"""
|
|
94
129
|
raise NotImplementedError
|
|
95
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
|
|
96
139
|
def side_measure(args: "Geometry.SideArg", s: "Sample"):
|
|
97
140
|
"""Device function returning the measure determinant (e.g. volume, area) at a given point"""
|
|
98
141
|
raise NotImplementedError
|
|
99
142
|
|
|
143
|
+
@staticmethod
|
|
100
144
|
def side_measure_ratio(args: "Geometry.SideArg", s: "Sample"):
|
|
101
145
|
"""Device function returning the ratio of the measure of a side to that of its neighbour cells"""
|
|
102
146
|
raise NotImplementedError
|
|
103
147
|
|
|
148
|
+
@staticmethod
|
|
104
149
|
def side_normal(args: "Geometry.SideArg", s: "Sample"):
|
|
105
150
|
"""Device function returning the element normal at a sample point"""
|
|
106
151
|
raise NotImplementedError
|
|
107
152
|
|
|
153
|
+
@staticmethod
|
|
108
154
|
def side_inner_cell_index(args: "Geometry.SideArg", side_index: ElementIndex):
|
|
109
155
|
"""Device function returning the inner cell index for a given side"""
|
|
110
156
|
raise NotImplementedError
|
|
111
157
|
|
|
158
|
+
@staticmethod
|
|
112
159
|
def side_outer_cell_index(args: "Geometry.SideArg", side_index: ElementIndex):
|
|
113
160
|
"""Device function returning the outer cell index for a given side"""
|
|
114
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
|