M32. A comparison of discretizations for general shapes, and the rights settled

Packages: A0, which the owner gave (2026-11-19), and B1, which the owner settled on the same day.

What was built

  • Prototypes of four discretizations, in prototypes/shapes, outside the crate and the package: finite elements of any degree on triangles, spectral elements on quadrilaterals, finite differences on a grid that the boundary cuts, and integral equations on the boundary. Each solves the three test problems that the backlog named, against exact solutions: Poisson’s equation on an L-shape (with a smooth solution, and with the singularity of its corner), Poisson’s equation on a disk with a hole off-centre, and the Helmholtz equation outside an ellipse.

  • One script that runs all of it, prototypes/shapes/run.py. It records every result in results.json and asserts every order of convergence that the comparison claims.

  • A measurement of the sparse library. A small Rust program, prototypes/shapes/sparse, factorizes three systems of the finite element prototype with faer.

  • The page Discretizations for general shapes: the measurements, what each candidate would bring into the repository, how each fits the pipeline, and a recommendation for the owner. Its figures are drawn by prototypes/shapes/figures.py.

  • No change to the library.

What was found

The page has the numbers. In short:

  • Finite differences of second order on an embedded boundary do not reach \(10^{-6}\) with 200 000 unknowns. Finite elements of degree 4 reach \(10^{-10}\) on a smooth problem with 85 000.

  • Spectral elements reach \(10^{-10}\) with 2 200 unknowns on the disk with a hole, and with 6 100 for the wave outside the ellipse.

  • The mesh for spectral elements can be made by a program: each triangle of a triangulation is cut into three quadrilaterals, and the exponential convergence survives, at about twice the unknowns of a cut by hand. This was the open question of that candidate.

  • A corner that points inwards limits every method on a uniform mesh to the order 4/3. A mesh graded to the corner restores fast convergence.

  • Integral equations need the fewest unknowns by far (81 for twelve digits on the disk with a hole) and treat the outside of a body exactly. They apply only to equations whose Green’s function is known.

  • All modes of the disk with a hole come out of one dense eigenproblem with 2 200 unknowns, in half a second, right to \(3 \cdot 10^{-10}\). A shape in the plane could therefore offer what a box offers (collocation::Modes), and with it the exact propagation in time.

  • faer, which pdemagic depends on already, factorizes the sparse systems of 85 000 unknowns in 0.3 seconds, and the complex one with a dense block in 1.9. Its sparse solvers need no further crate.

Decisions

D32.1. The rights are settled

Owner, 2026-11-19.

Decision D58 asked the owner to clarify three points before anything is published. The owner has:

  1. The employer has no rights in the project. pdemagic is the owner’s private project.

  2. Code written with the help of an AI model is no obstacle, in the owner’s judgement.

  3. There are no contributors but the owner, who is the only developer. An agreement by which contributors grant the right to license their work commercially is needed only once somebody else contributes. It is written when the repository is opened for contributions (package B4).

With this, package B1 is done and nothing of decision D58 blocks a release any longer. When and what to release stays the owner’s choice.

D32.2. Prototypes are kept, apart from the library

Developer, 2026-11-19, accepted by the owner on the same day.

Code that answers a question about the project, and is no part of pdemagic, lives in prototypes/, with the page that reports the answer in docs/dev.

  • Kept, and not thrown away, so that a claim of the page can be checked and a measurement repeated. The comparison asserts its orders of convergence in the script that produces them (decision D6 in spirit: convergence is the proof).

  • Apart. A prototype is not installed with the package, not built with the crate, and not counted by the coverage of either. It is no member of the Cargo workspace. The linter reads the Python files, like all of the repository.

  • Its own dependencies. A script names what it needs at its top, and uv run fetches that into an environment of its own. scipy is used this way. It is no dependency of pdemagic, and the lock file is unchanged.

  • Not in CI. A prototype is run by whoever wants to check it.

D32.3. A fourth candidate, and one measure for all

Developer, 2026-11-19.

  • The backlog named three candidates: finite elements, spectral elements, embedded boundaries. Integral equations on the boundary were added. pdemagic uses them for bodies (decision D40), the owner chose them for the outside of a body (decision D39), and one of the three test problems is an exterior problem.

  • The error is the largest one at the points of a method that are at least 0.1 away from the boundary, relative to the largest value of the solution. The margin is there for the integral equations, whose values close to the boundary need a quadrature that the prototype does not have. It costs the other methods nothing: their error at the boundary is no larger than inside.

  • The exact condition for outgoing waves was given to finite and spectral elements on a circle around the ellipse. That is the stand-in for a coupling to an integral equation, which decision D39 asks for, and not an absorbing layer. The embedded boundary got an absorbing layer, since a Cartesian grid has no circle.

D32.4. What was proposed to the owner

Developer, 2026-11-19. A proposal, which the owner took as decision D32.6.

Spectral elements on quadrilaterals that are made from a triangulation, with the degree as an entry of the plan. faer for sparse factorizations, with no new dependency. spade for the triangulation, as a new dependency, to be confirmed by the first milestone that uses it. Integral equations for the outside of a shape, later. The reasons, and what speaks against them, are on the page.

D32.5. A pull request is watched, and merged when CI is green

Owner, 2026-11-19.

A session always watches the checks of CI on its pull request. When they are green, it merges the pull request at once, without waiting for the owner. This replaces “only on the owner’s word” in the rules of milestone 30, and the review before the merge that decision D11 describes.

What stays as it was:

  • A session merges its own pull request, and no other.

  • The pull request is ready, holds main, and has passed the full check before it is marked as ready.

  • Pull requests are merged with a merge commit, one at a time.

  • A merge decides nothing. What a milestone records as a proposal to the owner stays a proposal after the merge, and a package that needs the owner’s word still needs it.

The rule is written into the session conventions and the workflow, since a later session knows only what the repository says.

D32.6. General shapes: spectral elements, faer, spade

Owner, 2026-11-19, on the proposal D32.4.

  • General shapes are discretized by spectral elements on quadrilaterals, which a program makes from a triangulation. The degree is an entry of the plan.

  • Sparse factorizations come from faer, through its feature sparse-linalg. That adds no dependency.

  • The triangulation comes from the crate spade, a new dependency. The first milestone that uses it confirms that its meshes serve, and adds its row to the table of dependencies.

  • The outside of a shape is treated by an integral equation on the boundary, later, with A5. There is no truncated outside with an approximate condition, as decision D39 says for bodies.

This answers the question that blocked A4 and A5. A4 itself still starts on the owner’s word, like every part of the campaign (decision D62).

Left for later

  • Conditions on the derivative were not measured for any candidate.

  • Three dimensions were not measured. Hexahedra from tetrahedra, and an iterative solver in place of a direct one, are questions for A5.

  • spade was not used. The prototypes triangulate with scipy, in the simplest way that gives fair triangles.

  • A corner that points inwards was graded by hand, on the L-shape. A mesher that finds such corners and grades towards them is part of A4.

  • Finite elements above degree 6. The basis of the prototype loses digits there.

  • Integral equations as a method of their own, for stationary equations with constant coefficients on smooth shapes, are on the page of ideas. They need a way to continue a source beyond the domain, and values close to the boundary.

  • Whether faer’s sparse routines leave the vector registers in use, as its dense ones do (decision D68), was not looked at.