# M52. Arrays as data on a shape **Package:** A4, its eleventh part: on a region of the plane, what a problem is given may be an array on a grid over the rectangle that holds the region, as it may be on every other domain. The solution of one problem can then be what the next is given. ## What was built - **`shaped_data::Fields`**: the data fields of a problem on a shape, with their values on one uniform grid, read at any point. Where the grid holds numbers all around the point, by the polynomial of degree five in each coordinate through six by six points. Where some of them hold no number, by a polynomial of total degree five that is fitted to the numbers in a window of eight by eight points, or of twelve by twelve, by weighted least squares, and of degree three if the numbers are too few. What was read is kept, since the planner asks for the same points again and again. - **The fields are read wherever a shape evaluates something given**: the source, the coefficients of the operator, a density, what is given on each piece of the boundary, the starting value and the nonlinear term of Newton's method, the initial state, the terms that are stepped, and the probe that chooses the steps for a source that depends on time. A formula may mix arrays with the coordinates and the time, such as $e^{-t}\,g(x, y)$ for an array $g$. - **`plan_with(problem, data)`** in the core: on a shape the planner reads the arrays to see how fine the elements must be, so it takes their values. `plan(problem)` is the same with no values, and says so for a problem on a shape that declares data. - **In Python**: `pm.plan(problem)` hands the arrays of the problem on. `Region.axes(shape)` gives the points of the uniform grid over the rectangle that holds the region, and `GridData(values)` without bounds lies on that grid. With bounds it lies on any uniform grid that covers the region. ## What it reaches Poisson's equation on the unit disk for $u = \cos 2x\,e^{y/2}$, with the source and the value on the rim as arrays on a grid over the square around the disk: | Points along a side | Error, with numbers beyond the rim | Error, with none | |---|---|---| | 33 | $2\cdot10^{-8}$ | $3\cdot10^{-6}$ | | 65 | $4\cdot10^{-10}$ | $4\cdot10^{-8}$ | | 129 | $7\cdot10^{-12}$ | $7\cdot10^{-10}$ | | 257 | $1\cdot10^{-13}$ | $9\cdot10^{-12}$ | Both columns fall with the sixth power of the spacing. The tests take problems that earlier milestones solve from formulas, and give them as arrays on 129 points: a medium, a potential, a source, a value on the rim and a mix of value and slope on the edge of a hole ($10^{-9}$, and the sixth order from 33 to 129 points is asserted); a nonlinear term whose strength is an array, with the starting value from one; heat in a body whose capacity and conduction are arrays, with the source, the boundary values and the start from arrays ($10^{-8}$); a reaction that is stepped, whose strength is an array. A solution on a disk with a hole, handed to the next problem as its source by `pm.GridData(first[u])`, leaves $2\cdot10^{-13}$ in the second solution. ## Decisions ### D52.1. An array is read at the points of the elements, locally *Developer, 2026-11-20.* The elements need what is given at their own points, which belong to no grid. Three ways were open: to read the array there by a local polynomial, to expand it in a global basis over the rectangle (a Chebyshev or a Fourier sum) and evaluate that, or to give the data on the points of the elements themselves. The last would force the user to know the mesh before the planner has chosen it. The global expansion is spectral, but an array that is known in the region alone, with nothing outside, has no smooth continuation to expand, and that is the case that matters most: a solution as the data of the next problem. So the array is read locally, by polynomials of degree five. The error of the sixth order is far below what an array from a measurement or from a grid of 129 points holds otherwise. Spectral reading where the grid allows it stays in K3. ### D52.2. No number means not known *Developer, 2026-11-20.* A point of the grid that holds `nan` is left out, and its neighbours are read from the numbers that are there. That is what a solution on a region looks like, and it is the honest way to give a quantity that is known in the region alone. The alternative, to ask for an array that is filled everywhere, would make the user invent a continuation, and a zero outside the boundary is the continuation that comes to mind and the one that costs the accuracy at the boundary. A point of the region with no number within a step and a half is refused, with the point named: the array does not cover the region. ### D52.3. The grid of data without bounds is the grid of a solution *Developer, 2026-11-20.* `GridData(values)` on a region lies on the uniform grid over the rectangle that holds the region, with the shape of the array. A solution on the region is given on that grid, so `pm.GridData(solution[u])` is right without a word about bounds, whatever shape the grid of the plan has. `Region.axes(shape)` returns the points, as `Box.axes` and `Disk.axes` do for their domains. ### D52.4. The planner takes the values *Developer, 2026-11-20.* Elsewhere a plan needs the grids of the data alone, because the solution lives on the grid of the data. On a shape the planner chooses elements by how fast the Legendre coefficients of what is given fall, and must read the arrays for that. The core gets `plan_with`, and `plan` stays as it is for every caller that has no data. In Python nothing changes for the user: `pm.plan(problem)` knows the arrays of the problem. ### D52.5. One uniform grid for all arrays of a problem *Developer, 2026-11-20.* All data fields of a problem on a shape lie on one grid, which is uniform and has at least six points along each axis. Arrays on different grids are a limit on every domain (K3), and it is kept here so that the lifting of it is one piece of work. ## What is left - Reading an array spectrally where its grid allows, derivatives of an array, and arrays on different grids in one problem (K3). - Systems on a shape: the next part of A4.