Skip to content

Commit

Permalink
Merge branch 'fix/explicit_quadrature_indexing_regression' into 'main'
Browse files Browse the repository at this point in the history
Fix quadrature point indexing in `wp.fem.ExplicitQuadrature`

See merge request omniverse/warp!707
  • Loading branch information
gdaviet committed Aug 29, 2024
2 parents a6a5ca0 + fe65dc3 commit da9d002
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Fix handling of integer indices in the `input_output_mask` argument to `autograd.jacobian` and `autograd.jacobian_fd` ([GH-289](https://github.com/NVIDIA/warp/issues/289)).
- Fix `ModelBuilder.collapse_fixed_joints()` to correctly update the body centers of mass and the `ModelBuilder.articulation_start` array.
- Fix precedence of closure constants over global constants
- Fix quadrature point indexing in `wp.fem.ExplicitQuadrature` (regression from 1.3.0)

## [1.3.1] - 2024-07-27

Expand Down
1 change: 1 addition & 0 deletions warp/fem/quadrature/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def max_points_per_element(self):
@cache.cached_arg_value
def arg_value(self, device):
arg = self.Arg()
arg.points_per_cell = self._points_per_cell
arg.points = self._points.to(device)
arg.weights = self._weights.to(device)

Expand Down
10 changes: 10 additions & 0 deletions warp/tests/test_fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,8 @@ def test_particle_quadratures(test, device):
geo = fem.Grid2D(res=wp.vec2i(2))

domain = fem.Cells(geo)

# Explicit quadrature
points, weights = domain.reference_element().instantiate_quadrature(order=4, family=fem.Polynomial.GAUSS_LEGENDRE)
points_per_cell = len(points)

Expand All @@ -1329,9 +1331,16 @@ def test_particle_quadratures(test, device):
test.assertEqual(explicit_quadrature.max_points_per_element(), points_per_cell)
test.assertEqual(explicit_quadrature.total_point_count(), points_per_cell * geo.cell_count())

# test integration accuracy
val = fem.integrate(_bicubic, quadrature=explicit_quadrature)
test.assertAlmostEqual(val, 1.0 / 16, places=5)

# test indexing validity
arr = wp.empty(explicit_quadrature.total_point_count(), dtype=float)
fem.interpolate(_piecewise_constant, dest=arr, quadrature=explicit_quadrature)
assert_np_equal(arr.numpy(), np.arange(geo.cell_count()).repeat(points_per_cell))

# PIC quadrature
element_indices = wp.array([3, 3, 2], dtype=int, device=device)
element_coords = wp.array(
[
Expand All @@ -1349,6 +1358,7 @@ def test_particle_quadratures(test, device):
test.assertEqual(pic_quadrature.total_point_count(), 3)
test.assertEqual(pic_quadrature.active_cell_count(), 2)

# Test integration accuracy
val = fem.integrate(_piecewise_constant, quadrature=pic_quadrature)
test.assertAlmostEqual(val, 1.25, places=5)

Expand Down

0 comments on commit da9d002

Please sign in to comment.