Repository navigation
A degree-2 mesh builds with a rank holding no cells, and its cells have true sizes - #983
Conversation
…ve their true size (#908) What was wrong. Mesh._get_cell_radii took each cell's volume from DMPlexComputeGeometryFVM, which needs affine coordinates, and the error code was ignored. On a coordinate field of degree 2 or more the routine read the edge midpoints as corners and then stopped at its first face with "Edge has 6 coordinates != 4". A rank with no cells has no faces and carried on into a collective its peers had left. At np 3 with cells [8, 8, 0], the ranks died in the next collective. In serial the mesh built, printed the error, and reported every cell length at half its true value. The fix. Above degree 1 the volume is now the integral of the coordinate map's Jacobian on the mesh's own quadrature rule, from DMFieldCreateFEGeom, the geometry the assembler integrates with. It needs no communication, handles curved cells and manifolds, and matches degree 1 to 1e-15 on triangles, quads, tetrahedra, hexahedra, an annulus and a spherical manifold. Degree 1 stays on the FVM routine and is unchanged. Error codes are now checked on every rank. The FVM routine also refuses degree above 1 before the call, because the code check alone hangs: the empty rank never leaves the routine to reach it (seen at np 2 and np 3). Behaviour change. On every straight-sided mesh of degree 2 or more, in serial too, the cell radii, get_min_radius, get_max_radius, get_mean_radius and cell_size() double. The new values are the documented volume**(1/dim). No test or source file builds such a mesh and pins the old value; test_1107 builds one and is unaffected. Tests. tests/parallel/test_0782_degree2_mesh_empty_rank.py has power at every np >= 2: before, np 2, 3 and the np 4 region extract abort with exit 142 and "Fatal error in internal_Allreduce_c: Message truncated"; after, 4 passed at np 2, 3, 4, 8. tests/test_0782_degree2_cell_size.py, serial: before, 8 failed, 2 passed; after, 10 passed. Neighbours unchanged at np 2 and 4: test_0774, 0779, 0781, 0855, 1079, 1080, 1107. Serial adapt tests: 66 passed, 6 skipped (no adapter in conda-forge PETSc). Underworld development team with AI support from Claude Code
…rrected (#908) What was wrong. _check_error_code_collectively said it ran on a communicator apart from PETSc's, but both call sites passed mesh.dm.comm.tompi4py(), which is PETSc's duplicate. Its test passed uw.mpi.comm, so it could not see this. The fix. The function takes no communicator and always uses uw.mpi.verdict_comm, so the test now exercises the same exchange as the call sites. Correction to 16689d1a. Its message says cell radii "double" on every straight-sided mesh of degree 2 or more. The factor from old to new, as measured in review, is: degree 2: triangles, quadrilaterals, tetrahedra 2; hexahedra 3.63. degree 3: triangles 2.59; quadrilaterals about 3e6; tetrahedra 3; hexahedra 4.06. The docstring of tests/test_0782_degree2_cell_size.py now carries these. Tests. test_0782 parallel: 4 passed at np 2, 3, 4, 8. Serial test_0782: 10 passed. Underworld development team with AI support from Claude Code
Adversarial review record for this PRTwo independent passes on the branch these commits came from; #909's remesh work has moved to its own PR, so only this part applies here. Verdict for this PR's code: fixed, no open must-fix. One must-fix applied to it: Attacks that failed
Findings left, not merge conditions
Tests can failSerial Issues#908: fixed by this PR. #872, #831: still live, not touched. Could not testMeshes above about 33k cells; np above 8; truly curved degree-3 cells; the full suite. Underworld development team with AI support from Claude Code |
|
Adversarial review of #983 at a00566a Second, independent pass. We judged the code before reading the author's record and list here only what that record does not already say. Built in a worktree, macOS, conda-forge PETSc 3.25.3, serial only. Development behaviour comes from an env that is eddab70 plus an unrelated Must fixNone. Should fix
Notes
Issue verdicts
Not checked, and what the Linux server should run
Underworld development team with AI support from Claude Code |
…s at a time (#908) The degree-2 cell size built geometry for every local cell at once, on the solver's quadrature rule, on every coordinate rebuild. A degree-2 hex mesh of 27k cells at qdegree 6 peaked 1.55 GB above its base; 195k cells at qdegree 3, 2.09 GB. It also tied a size to qdegree: at qdegree 1 a curved tetrahedral cube was out by 9.6e-8. The rule now follows the coordinate degree, enough to integrate det J exactly, and the cells go through in bounded blocks. Peak above base is now 3 MB or less in those cases, and time falls: 8.7 s to 0.64 s, and 11.4 s to 4.4 s. From the integration session's review of #983: - the failure check reuses fault_contact._collective_raise, so it names the first failing rank rather than listing every rank; - a rank with no cells now fetches the coordinate field like any other; - test_0782 compares per cell against closed forms, in place of a sum and of an Integral on the same geometry route; - the fixtures' unused dm_class goes; - docstrings no longer claim the check prevents a hang, and the refusal names the public get_min_radius. Underworld development team with AI support from Claude Code
Response to the second review, at d3f7647All four should-fixes applied.
Peak is
Also done from the notes: the docstrings (4, 6), dropping the Not done: note 7. The server runs you asked for, at d3f7647 unless stated
Underworld development team with AI support from Claude Code |
No #909 or #965 hunk in this PRThe combined branch is local to the Linux server, so the commands below need that clone. Run in the worktree of Results:
The check runs on names and files, so it would miss a #909 change under another name; the diff is 453 lines, read by two reviews. Underworld development team with AI support from Claude Code |
|
Adversarial review of #983 at d3f7647 (round 2) This pass covers only d3f7647, the one commit since a00566a. We rebuilt the review worktree at d3f7647; Round-1 should-fixes
The round-1 notes are also addressed. No docstring has doubled backslashes; the FVM docstring and the docstring of the check are corrected; the FEM function says COLLECTIVE; the Must fixNone. Should fix
Notes
Issue verdicts
Not checked, and what the Linux server should run
Underworld development team with AI support from Claude Code |
…908) The hex rows used a map whose det J has degree 1 in each variable, which two points a side already integrate. x' = x + a y^2 z^2 and cyclic has degree 4: forcing two points gives 0.881301 against the exact 0.88125, and all three rows fail on that mutant. From the second review of #983. The refusal also names Mesh.cell_size. Underworld development team with AI support from Claude Code
|
Round 2's should-fix is applied at 7397bd1. The hex rows now use x' = x + a y^2 z^2 and cyclic; sympy gives det J degree 4 per variable (not the rule's worst case of 5) and volume 1 - 3a^2/5 + a^3/4, 0.88125 at a = 1/2. With the rule forced to two points the three hex rows fail at 0.881301; 17 passed on the real code; parallel Left as is: a folded cell's error goes unflagged (the known Underworld development team with AI support from Claude Code |
…worldcode#978) The degree argument of Mesh and of the uw.meshing constructors set the degree of the coordinate field. Particle location, cell sizes, boundary normals, mesh motion and the multigrid hierarchy all read the coordinates as straight-sided cells, and a degree-2 mesh failed in each. It did not curve a boundary either: the edge nodes sat on the chords. - Mesh._require_straight_sided_cells raises ValueError unless degree is the integer 1. Mesh.__init__ calls it first, and each of the 20 uw.meshing constructors calls it before generating anything, so every rank refuses together and rank 0 never starts gmsh. - mesh.degree is a read-only property returning 1. - Removed what existed only for degree-2 coordinates: the quadrature cell sizer petsc_fem_get_local_cell_sizes and its PETSc declarations (underworldcode#983), the degree guard in _compute_geometry_fvm, and the _finest_level_takes_moved_coordinates guard in _deform_mesh (underworldcode#1044). - Docstrings of all constructors and docs/developer/subsystems/meshing.md say that the mesh degree is 1 and the variable carries the order. - Tests: test_0782 (serial and parallel) now hold the refusal for every constructor found by signature, the strict check, the read-only property, and the degree-1 cell sizes that the degree-2 tests carried (manifold facets, empty rank, extracted region). The estimate_dt accuracy step keeps its closed-form baseline on a degree-1 mesh. Underworld development team with AI support from Claude Code
A degree-2 mesh now builds with a rank holding no cells, and its cell sizes are the true ones. This changes cell sizes on meshes of degree 2 or more, in serial too; see below.
What was wrong
petsc_fvm_get_local_cell_sizesandpetsc_fvm_get_min_radiuscallDMPlexComputeGeometryFVMand ignored its error code. On a degree-2 coordinate field it fails with "Edge has 6 coordinates != 4", on every rank with cells and not on a rank without, so the ranks then disagreed at the next collective: MPI "Message truncated", then a hang. The numbers it returned were also wrong: it read edge midpoints as corners.The fix
DMFieldCreateFEGeom, on a rule set by the coordinate degree, enough to integrate det J exactly, not byqdegree. Cells go through in blocks of at most 200,000 quadrature points, so memory stays bounded: a 195k-cell degree-2 hex mesh at qdegree 3 peaked 2.09 GB above base on the first version of this PR, and peaks under 3 MB now. Degree 1 stays on the FVM route, unchanged.What changes for anyone running a mesh of degree 2 or more
Cell radii,
get_min/max/mean_radiusandcell_size()change, in serial too. They now equal the documentedvolume**(1/dim), and match degree 1 to 3.0e-15 on triangles, quads, tets, hexes, an annulus, a manifold and a shell. Old to new:Those hex factors are for straight hexes. On warped hexes (
CubedSphere,RegionalSphericalBox) degree 2 is x3.74 to x3.80, so h^2 callers move x14.0 to x14.4, and degree 2 differs from degree 1 per cell by up to 6.06e-3 while totals agree to 1e-10: FVM's volume of a hex with non-planar faces is not the trilinear integral.Degree 1 is unaffected. No production or campaign path builds a mesh of degree 2 or more, from a scan of
src,tests,docs,scripts,campaignsand drivers: the literal builders are this PR's tests,test_1107, and two files indocs/examples/submesh_investigation/, which pin no radius.Every caller of these numbers, on a degree-2 straight-sided mesh. Factors are for triangles, quads and tets; on straight hexes x2 is x3.63, and x4 is x13.2. "Measured" is old then new on a triangle mesh.
Swarm.estimate_dt,swarm.py:6058_advective_diffusive_dt,solvers.py:399, resolution basisdirection_aware=TrueAdvDiffusion.estimate_dt, accuracy basisSNES_Stokes.estimate_dt,solvers.py:2889SNES_Stokes_SaddlePt.estimate_dt,petsc_generic_snes_solvers.pyx:12577SNES_TransientDarcy,solvers.py:1415SNES_Diffusion,solvers.py:5423SNES_NavierStokes,solvers.py:6013solver_template.py:284free_surface.py:1453,:1468EulerianSUPG.tau,ddt.py:2322petsc_generic_snes_solvers.pyx:7147,:7151,:9084,:9088ddt.py:4472ddt.py:5265ddt.py:5703,smoothing/api.py:716,faults.py:472,:726,analytic/_base.py:393,transport.py:118,:181discretisation_mesh.py:3671discretisation_mesh.py:6383Mesh.get_min_radius_old,discretisation_mesh.py:7112_mesh_h0(surfaces.py:3352),adaptivity.pyh_min and h_max,smoothing/metrics.pycomputeCellGeometryFVMcallers, includinglevel_set.py:173_cell_radii(#978)Essential-BC Stokes at degree 2 against degree 1: 1.9e-16. SUPG after 5 steps: 2.6439e-2 before, 2.6421e-2 now, equal to degree 1.
Tests
tests/test_0782_degree2_cell_size.py, serial: 15 failed, 2 passed on eddab70; 17 passed here. Sizes are compared per cell with closed forms; a curved cell's size at qdegree 1, 2 and 5 against an exact volume (out by 9.6e-8 at qdegree 1 on this PR's first version); and block splitting, where a slip at a block boundary fails.tests/parallel/test_0782_degree2_mesh_empty_rank.py: exit 142 at np 2, 3, 4 on eddab70, withEdge has 6 coordinates != 4then "Message truncated"; 4 passed at np 2, 3, 4, 8 here. It has power at CI's np 2, and asserts exactly one empty rank.Left open
#909 and #965 follow in a separate PR. They were on one branch, and carving them apart lets this land while the remesh transfer goes through further review. #978: other degree-2 routes. A review could not exercise a failing
DMFieldCreateFEGeom(the code check mutant survives), nor a negative Jacobian (absmutant survives): a midside node pulled through its cell reports a plain size with no flag.Closes #908
Underworld development team with AI support from Claude Code