Repository navigation
Polyhedra with no kernel: located by winding number, interpolated by mean value coordinates (#334) - #512
Polyhedra with no kernel: located by winding number, interpolated by mean value coordinates (#334)#512berkgeveci wants to merge 1 commit into
Conversation
…mean value coordinates (Kitware#334) A polyhedron no point inside sees whole (tangled, inside out, a face whose fan folds) was skipped with a warning: a point inside it was found in a neighbour or nowhere, and a particle reaching it stopped. It now holds a point where its face triangles' solid angles wind round it once (either way), and point data there is the mean value coordinates' sum (Ju, Schaefer and Warren, robust form as VTK's interpolator), exact for a linear field. The location's sub-tetrahedron is views.NO_KERNEL_TET, its pc the point less the cell point; the locator's search from the cells, by_id (probe, advection) and probe's evaluation from the cells read it. On AhmedML's volume the 10 such polyhedra hold their centres and points toward each corner, none found in a neighbour, UMean within each cell's range.
| if abs(self.winding_number(c, x)) > 0.5: | ||
| t = NO_KERNEL_TET | ||
| inside = 1 | ||
| else: |
There was a problem hiding this comment.
A cell with no volume still gets -2 from the locator, and this branch makes it hold points within the slack. Mean value coordinates are undefined there. A flat cube (z = 0) beside a cube, u = 2x + 3y + 1: at (0.5, 0.5, 1e-4), probe gives 2.0 on the CPU and -12 on CUDA, against 3.5, with valid 1. Main left these cells out. Leave cells with no volume out again, or take a near point's value from its nearest face triangle's barycentric weights.
| _for_cells(_not_star_shaped, data, True, *self._moved(), bad) | ||
| if int(bad.numpy().sum()): | ||
| self.moved_cell_points = _moved_cell_points(data, bad) | ||
| bad.fill(0) |
There was a problem hiding this comment.
"One with no volume winds round nothing, so holds nothing": true inside, but it holds near points (comment 1).
| solid angles of its face triangles), and point data there is interpolated by | ||
| mean value coordinates, which are exact for a linear field, as VTK's | ||
| `vtkPolyhedron` interpolates. Probes, `CellLocator.find`, `advect` and | ||
| streamlines take it. On AhmedML's volume 12 of 21.5M cells are such (#334). |
There was a problem hiding this comment.
The design doc says 10 of the 12 are read as polyhedra; the changelog says all 12 are handled.
| @@ -327,7 +329,8 @@ def tet_face(self, c, t): | |||
| edge by edge, as ``side_point_id`` walks them.""" | |||
| k = 0 | |||
There was a problem hiding this comment.
What needs the k < last guard? With NO_KERNEL_TET it stops at the last face with j still past its points, so a caller that forgets to check t reads out of range instead of failing. Comment 1 is why it matters: a gradient reader added later would hit it.
|
Winding number plus mean value coordinates is the right pair here, and the readers that see NO_KERNEL_TET all handle it. I ran the new tests on CUDA (GB10) too; they pass. One problem inline with cells of no volume, and two nits. |
Closes #334.
A polyhedron with no kernel (tangled, inside out, or with a face whose own fan folds over), where no point inside sees all of its faces, was skipped with a warning. A point inside it was found in a neighbour or nowhere, and a particle reaching it stopped. On AhmedML's volume 12 of 21.5M cells are like this: wall cells 2–3 mm across at the nose's corners.
What
Inside test (
_PolyhedralLocation.winding_number,locate_by_winding): the solid angles of the cell's face triangles (each face fanned from its face point, as its neighbour fans it, so the cells' surfaces meet) over 4π, by Van Oosterom and Strackee's formula. A point is held where the faces wind round it once, either way, so an inside-out cell holds its points too. A point outside, within the locator's slack of a face triangle, is near, as in other cells. A cell with no volume winds round nothing.Interpolant (
mvc_value): mean value coordinates over the same triangles (Ju, Schaefer and Warren, 2005, in the robust formvtkMeanValueCoordinatesInterpolatoruses, with its angle tolerance), exact for a linear field.The location: its sub-tetrahedron is
views.NO_KERNEL_TET, which is positive and past any fan's, so callers testingt >= 0need no change; itspcis the point less the cell point. Readers:by_id's_PolyhedralMesh(locate_held,tet_value_of), which probe and advection use. The MVC branch is compiled out whereMOVEDis 0, which is most meshes.Advection's shortcut (
_well_inside) does not stop at such a cell, since it may overlap its neighbours.The warning is gone: these cells are handled now. Polygon and polyline views get a
locate_by_windingthat is plainlocate_from, since the locator's kernel is shared with them.Not done: gradients in such cells. Nothing reads a polyhedral location's gradient yet.
Tests
test_polyhedra.py:test_mixed_cells.py: the C-shaped prism beside a hexahedron.UMeanis within the cell's own point range.Results (CPU, M1 Max):
TACK_DEBUG=1: 18 passed;mkdocs build --strictare clean.GPUs not run yet.
This will be merged after the 0.8 release.
🤖 Generated with Claude Code