M40. A mesh that shrinks towards corners

Packages: A4, its sixth part: a mesh that is graded to the corners of a region at which the solution has a singularity. C16, its first half: the elimination inside elements on all cores. The owner gave A4 (decision D33.1).

What was built

  • Corners with a singularity are found. mesh.rs computes, for every joint of two pieces of the boundary, the angle of the region there and from it the exponent of the solution. Where the exponent is below one, the slope of the solution is unbounded: at corners that point into the region, and where a condition changes from a value to a slope on a straight side.

  • Layers. Towards each such corner the points on the boundary come closer, each step half the one before, and the triangulation follows. layers is an entry of the plan, for spectral_elements and element_newton.

  • The planner gives a mesh as many layers as its corners need, and says in a note where they are.

  • All cores. The points inside elements are eliminated on all threads, and the products in it are the library’s.

  • Documentation: the guide to regions, the method page, and every page that spoke of corners or of the memory of a solve.

Verified against exact solutions with a singularity: \(r^{2/3}\sin(2\theta/3)\) on the L-shape, to \(10^{-10}\) with the plan of the planner where the mesh without layers reaches \(10^{-3}\), with every four layers gaining more than a digit. \(\sqrt r\,\sin(\theta/2)\) on a rectangle whose lower side changes from a value to a slope, to \(10^{-8}\). The membrane on the L-shape, whose value at \((-0.5, 0.5)\) settles at 0.131 052 962 031 as the layers grow.

What was found

  • Layers cost little, because they are few elements. 18 layers add 760 elements to the 66 of the L-shape, and bring twelve digits where three were. A uniform mesh with more elements than that gains less than a digit.

  • The factors are not nearly full. Milestone 33 recorded that a solve with 27 000 points on the sides of elements took 6.4 gigabytes, and set a limit of 16 000 such points. Measured again here, the same solve takes 0.9 gigabytes and 2.9 s. Memory grows about with the number of those points: 110 000 take 4.9 gigabytes. Where the earlier figure came from could not be found again. The limit is now 80 000, and the planner solves with up to 30 000.

  • A chord is not a tangent. The first version took the angle at a joint from the triangles there. They follow chords, so the smooth edge of a round hole counted as a corner. The angle now comes from the directions of the two pieces, and the triangles only say on which side the region lies.

  • The planner knows before it solves. Which corners have a singularity follows from the boundary and the conditions alone. The rule of milestone 33 that ends the search of the degree when it gains little stays, and now ends it at what the innermost layer leaves.

Decisions

D40.1. The mesh shrinks towards corners in layers that halve

Developer, 2026-11-19.

Milestone 32 found that a mesh graded to a corner restores the fast convergence, and left the mesh to package A4.

  • Which corners. A joint of two pieces has the exponent \(\lambda = \pi/\omega\) for the angle \(\omega\) of the region there, and \(\pi/(2\omega)\) where one piece gives the value and the other the slope. It gets layers if \(\lambda < 0.95\). That is the theory of the Laplacian at a corner between straight sides. For a medium, for coefficients that differ by direction, and for curved sides it is a first approximation, and is taken as one.

  • How the layers are made. The points on the two pieces at the corner are set at distances that halve, and the triangulation is refined as before, with the boundary kept. Its bound on angles makes the triangles grow away from the short edges by itself. No element is cut by hand.

  • The same number of layers at every corner, since the plan has one number: layers. The planner takes \(\lceil 12/\lambda\rceil\) for the smallest exponent, so that the innermost elements leave \(2^{-12}\) of the singularity whatever its exponent: 18 layers for an L-shape. With 12, an error of \(10^{-10}\) was measured for a known solution, in three seconds. With 14 it was \(10^{-12}\) in six.

  • At most 40 layers. The innermost elements are then \(10^{-12}\) of the first, and their corners differ in the last four digits of their coordinates.

  • The degree is the same in every layer. Elements of a lower degree towards the corner would do, and would save points. That needs elements of different degrees side by side, which this method does not have.

D40.2. layers is an entry of the plan, and zero in plans without it

Developer, 2026-11-19.

spectral_elements and element_newton have the entry layers. A plan that does not name it has none, so that plans written before this milestone mean what they meant. The methods in time have no such entry: their modes hold a few thousand points, and layers add tens of thousands (package C17).

D40.3. The elimination inside elements runs on all threads

Developer, 2026-11-19.

The first half of package C16. Each element is eliminated from its own matrix alone, so the elements are handed to the threads of rayon, and what they leave is put together in the order of the elements. The result does not depend on the number of threads, down to the last bit (decision D69), which the test of threads covers for a case with layers. The products inside are done by faer in place of loops.

D40.4. The limits on the size of a solve follow what was measured

Developer, 2026-11-19.

A plan is refused above 80 000 points on the sides of elements, which take about four gigabytes, and the planner solves with up to 30 000, which take about one. Both replace the figures of milestone 33 (decision D33.6), which rested on a measurement that does not hold for the code as it is.