M33. Shapes in the plane: a first solve¶
Package: A4, its first part. The owner gave the package (2026-11-19), after taking the proposal of milestone 32 for its discretization (decision D32.6).
What was built¶
Shapes in the problem description. A domain can be bounded by closed curves, each made of named pieces: straight lines and arcs of ellipses. A condition holds on a piece, and may contain the derivative along the outward normal.
A mesh.
mesh.rscuts a shape into triangles with the crate spade, and each triangle into three quadrilaterals. Sides on a curved piece follow it exactly.Spectral elements.
methods/elements.rs: polynomials at Gauss–Lobatto points on each quadrilateral, the weak form of \(a\,\nabla^2 u + c\,u = f\), conditions on values, slopes and mixes, the elimination of the points inside each element, and a sparse LU factorization from faer for the rest.A path through the pipeline.
shaped.rs: classification, a planner that solves on one mesh and degree after the other, and the solve, which hands the solution back on a uniform grid.The Python frontend.
pm.Region(x, y, *curves)withpm.curves.Polygon,Circle,Ellipse, andCurvefromLineandArc.boundary=takes one equation, or a mapping from curves, pieces or names.pm.normal_derivative(u). A plot is cut along the boundary.Documentation: a page of the guide, a method page, an entry in the gallery, and the overviews.
Verified against exact solutions, from the problem to the solution: a membrane on a disk, to \(10^{-12}\). The disk with a hole of milestone 32, with the error falling by more than a factor of 50 from each of the degrees 4, 6, 8 and 10 to the next, and with the slope along the normal given on the hole. A mix of value and slope on half a disk. A solution that is fixed up to a constant on an ellipse, with what the source lacks reported. Complex coefficients on a triangle. A thin ring. The L-shape, with a smooth solution to \(10^{-9}\) and with the singularity of its corner.
What was found¶
The meshes of spade serve. Decision D32.6 asked the first milestone that uses the crate to confirm it. With the boundary kept as it is given and an angle bound of 25 degrees, the quadrilaterals cut from its triangles give the convergence that the prototype of milestone 32 had.
The boundary must not be split. A triangulation that refines itself splits edges on the boundary at their middle, which is not on the curve. The points on the boundary are therefore set here and kept, and only the inside is refined.
Two edges of a triangle on one smooth curve would give a quadrilateral with a corner of 180 degrees, which the check for folded elements would catch. It did not occur in any test.
The sparse factorization alone was slow. Each element couples all of its points, which makes the matrix dense in blocks: 2.2 s for 11 310 points. With the points inside each element eliminated first, 0.4 s.
The factors of what is left are nearly full. For 27 000 points on the sides of elements the solve took 6.4 gigabytes. A plan is refused above 16 000 such points, and the planner stays below 6 000. A smooth problem needs a few thousand.
A corner that points inwards ends the search of the planner early, as on a box, and leaves three or four digits.
Decisions¶
D33.1. The order of work after milestone 32¶
Owner, 2026-11-19.
A4, shapes in the plane, is taken: the whole package.
After it, the small packages around a solve: K6, K7 and K1.
Then eigenproblems: F1, then F2. F1 is no longer on hold.
A release comes later. The owner will say when.
D33.2. A shape is what closed curves bound¶
Developer, 2026-11-19.
How a domain of any shape is written in the problem description, which decisions D63 and D77 had left open for curves.
A domain has curves.
Domain.curvesholds closed curves. A domain with curves has two Cartesian axes, whose extents say nothing. A point belongs to the shape if it lies inside an odd number of the curves, so a curve inside another is a hole, and the sense in which a curve runs carries no meaning. A frontend then has no convention to keep.A curve is made of pieces with names, and a condition names its piece. Names, and not numbers, because a plan and a message can then say where something holds.
A piece is a line or an arc of an ellipse whose axes lie along the coordinates. That covers polygons, circles, ellipses and what is put together from them. A piece given by formulas is left for later (package A22): the mesh needs the points of a piece only, so it will need no new machinery.
Whether curves cross is found by the mesh, not by the validation of the problem: the triangulation knows, and a test on the formulas would be a second geometry kernel.
Checked against the hardest targets (decision D9): a shape in space will be bounded by surfaces in the same way, with the shapes that bodies have.
D33.3. The normal is a coordinate that a condition declares¶
Developer, 2026-11-19.
A condition on a piece of a curve is an equation, as on a face (decision
D63). It names a coordinate of its own, normal, and a derivative with
respect to that name is the derivative along the normal that points out
of the domain.
Why not a new operator in the expression type. The expression type is read in a dozen places, and each would have had to learn an operator that means something on a boundary only. A derivative along a named coordinate is what a condition on a face has already, and the reading of conditions carries over.
Outward, where a face of a box takes the derivative along the coordinate (decision D63). A curve has no coordinate to fall back on, and the outward normal is what the weak form of the method contains.
What is read so far:
a·u + b·∂u/∂n = gwith constantsaandb.In Python the normal derivative is
pm.normal_derivative(u), and the frontend chooses a name for the normal that nothing else has.
D33.4. The solution of a shape is given on a uniform grid¶
Developer, 2026-11-19. The owner was told before the work began.
The points of the elements lie where the mesh puts them. The solution is
sampled at the points of a uniform grid over the rectangle that holds the
shape, and is no number (nan) at the points outside.
Why. A plan has a grid, a solution is arrays on it, and every frontend and every plot rests on that (decisions D19 and D47). The sampling is exact for the computed solution: each grid point is located in its element, and the polynomial is evaluated there. The grid is a choice about the output, like the recorded times.
What it costs. The values at the points of the elements and on the boundary are not part of the result. They come with the values of a solution anywhere (package K6). Arrays as data are not taken on a shape, since they would be given on a grid that the method does not use.
The plan holds the grid of the output, and the method holds what decides the accuracy:
degreeandspacing.
D33.5. The mesh: points on the boundary are kept, triangles become quadrilaterals¶
Developer, 2026-11-19.
Each piece is cut into parts of about the spacing, and into enough that none turns through more than 45 degrees. These points and the edges between them are kept as they are.
spade triangulates and refines the inside, to triangles of at most three quarters of the spacing squared and angles of at least 25 degrees.
Each triangle becomes three quadrilaterals. A side on a curved piece follows it, and the bend is blended into the quadrilateral (Gordon and Hall).
An element that folds is an error of the plan, found when the elements are set up: the mesh is too coarse where two parts of the boundary come close. The planner goes on to a finer mesh.
D33.6. Spectral elements, solved directly¶
Developer, 2026-11-19.
Gauss–Lobatto points, and their quadrature for every integral. The matrix of the term without derivatives is then diagonal.
Conditions on slopes enter the weak form, and nothing is differentiated on the boundary. Conditions on values fix the points of their pieces.
Complex numbers throughout, as on boxes (decision D64). A real path is a matter for the speed campaign.
The points inside each element are eliminated first, element by element. The system for the points that elements share is factorized by the sparse LU factorization of faer.
The equation is divided by the size of its leading coefficient, so that the entries of the matrix do not depend on the units of the problem. A solution more than \(10^{11}\) times larger than what it was given means that the matrix is singular to rounding: the shape resonates, and the problem is refused, as on a box.
A constant that is left open is treated as on a box (decision D64): zero mean, and what the source lacks is reported.
The vector registers are cleared after the calls into faer (decision D68). Whether its sparse routines need it was not measured: the call costs nanoseconds.
D33.7. The planner raises the degree before it refines the mesh¶
Developer, 2026-11-19.
The first mesh has a spacing of a quarter of the size of the shape. The degrees 4 to 16 are tried in steps of 2, and the first at which the Legendre coefficients of the solution and of the source have fallen to \(10^{-10}\) in every element is taken. Then the spacing is halved, at most twice.
Why the degree first. The comparison of milestone 32 measured it: two more degrees gain three digits, and four times the elements gain two.
The search ends early when a degree of 8 or more gains less than a factor of 3 over the one before: the mark of a singularity, as in decision D64.
Budgets. The planner solves with at most 6 000 points on the sides of elements, and a plan may ask for 16 000.
D33.8. The Python frontend: Region, and curves in a module of their own¶
Developer, 2026-11-19.
The domain is
pm.Region, notpm.Shape:pm.shapes.Shapeis the surface of a body.Curves are objects of
pm.curves. A condition is given for a curve, for a piece of one, or for a name, and one equation alone holds everywhere, as on a box.A plot is cut along the boundary. The field is carried two grid points beyond the region first, so that the picture has values up to the curve. This is the third exception to “what is drawn is what was computed” (decision D51).
Left for later¶
The rest of A4: time, a mesh graded to corners, more equations, arrays as data. The backlog lists them.
Curves given by formulas, and ellipses that are turned: package A22.
Speed and memory: package C16. All cores for the elimination inside elements, and a factorization whose factors are not full.
The values at the points of the elements and on the boundary: with package K6.
A point inside an element at which its own matrix is singular. The elimination inside an element fails if \(c/a\) is an eigenvalue of that element alone with zero on its rim. The problem is then refused as if the shape resonated, although it need not. This takes an exact coincidence and was not met.