Skip to content

mesh.cell_size() is partition-dependent: the per-cell radius comes from a kd-tree over the rank's centroids, so cells at partition boundaries get a different size on each rank count #687

Closed

Description

@lmoresi

Mesh.cell_size() returns a P0 field filled from self._radii, which _get_mesh_sizes computes as the RMS distance from each cell's vertices to the NEAREST centroid found by a kd-tree over the centroids this rank holds. Near a partition boundary the nearest centroid is a different cell than in serial (the neighbour set is truncated), so the field, and everything scaled by it (the SUPG tau of the Eulerian solvers, the Nitsche penalty gamma mu / h), depends on the partition.

Measured on the Kovasznay-flow test of the SUPG Navier-Stokes solver (feature/navier-stokes-supg, res 8, three steps from the exact solution, solver tolerance 1e-11 so the linear solve is not the cause):

tau built on np 1 error np 2 error difference
a constant h (get_min_radius) 0.0023408316563576 0.0023408316563546 1e-15
mesh.cell_size() 0.0024855792696189 0.0024843274043763 5e-4

The plain Stokes solve and the tau = 0 (Galerkin) step on the same mesh are partition-independent to 1e-12, so the cell-size field is the only rank-dependent input. The scalar SUPG parallel test (test_1077) did not catch it because at its Courant number tau is dominated by the transient term and h barely enters.

The fix is a purely local definition of the size, each cell's vertices against its own centroid, which is identical on any partition and equal to the present value on a regular mesh; on an irregular mesh it is the same quantity without the neighbour's centroid occasionally standing in. Implemented alongside the Navier-Stokes SUPG solver, where it was found.

Underworld development team with AI support from Claude Code

Activity

  1. lmoresi commented on Sep 5, 2026

    @lmoresi
    MemberAuthor

    Duplicate of #569 (15 August), which is still open and carries the consequence this one does not: add_nitsche_bc(local_h=True) is the default, so Nitsche answers moved 6.6e-03 between rank counts.

    Same defect, and #692 fixes it — measured across rank counts on that branch: the new own-cell field is bit-identical at np=1/2/4 (max abs diff 0.000e+00), while the legacy kd-tree field moves by 3.3e-03 (np2) and 4.1e-03 (np4).

    Suggest closing this one in favour of #569, or closing both from #692.

  2. lmoresi commented on Sep 6, 2026

    @lmoresi
    MemberAuthor

    See the consolidated proposal on #694 — this, #569, the get_*_radius() contract and the naming are all one tidy-up rather than four.

    Short version: three definitions of "cell radius" are in play (kd-tree neighbour spacing, #692's own-centroid RMS, and PETSc's volume**(1/dim)), the docstrings describe the PETSc one while the code uses the kd-tree one, and the PETSc routine — abandoned years ago as broken — now returns one finite value per cell and is bit-identical across rank counts.

  3. lmoresi commented on Sep 9, 2026

    @lmoresi
    MemberAuthor

    Fixed by #692 and merged to development via #688 (1d5e8c1): mesh.cell_size() is now cell-local and partition independent.

    Guarded by tests/parallel/test_1077 (the field, cell by cell against its own serial answer) and test_1078 (the three radius accessors).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions