Iterating, instead of factorising

Exact along one axis

The tuned diffusion makes the answer exact at every node, and in two dimensions it holds at exactly one flow angle. Five degrees off the grid the relative error goes from 1.2·10⁻¹⁴ to 6.9, and by twenty degrees the scheme is worse than the upwinding it was built to improve on.

Worth reading first: The stencil that is not symmetric · A direction the smoother cannot see.

The diffusion that makes the answer exact is the sharpest result on this site. Add ξ = coth(Pe) − 1/Pe worth of artificial diffusion to a central-difference discretisation of a convection–diffusion problem, and the computed solution equals the exact one at every node, to 2.4·10⁻¹⁷, at every Péclet number. Both of the convection field’s earlier schemes turn out to be limits of the same curve.

That essay ended by noting the exactness belongs to the problem rather than to the scheme: on a manufactured smooth solution of the identical operator the tuned scheme is forty-two times worse than adding nothing. This essay is the other boundary, and it is a narrower one.

Everything in that result was one-dimensional.

Error against the angle between the flow and the grid, at Pe = 3.13Three curves against the flow angle on a logarithmic vertical axis. The tuned scheme is exact at zero — 2.4·10⁻¹⁷ — and is 0.00794 five degrees later. Central differencing and upwinding start at 0.517 and 0.136 and fall as the angle grows, because the exact solution's own size in the interior falls with it.05101520253035404510⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²angle between the flow and the grid (degrees)worst nodal errortunedcentralupwindexact, and then nottuned, on the axis2.4·10⁻¹⁷tuned, five degrees off0.0079tuned at 45°0.066upwind at 45°0.0019fifteen orders of magnitude for five degreesand the worst of the three by forty-five
Fig. 1 Three schemes against the angle between the flow and the grid. One of them is exact at zero. Five degrees is the second point on the axis.

The problem, and why it has an exact solution at every angle

−ε∆u + b·∇u = 0 on the unit square, with b a unit vector at an angle θ to the grid.

Any function of the streamwise coordinate s = x·b alone solves it, because the Laplacian of such a function is its second derivative along the flow and the equation collapses to the one-dimensional one. So

u(x, y) = (e^{s/ε} − 1) / (e^{L/ε} − 1), with s = x b₁ + y b₂ and L = b₁ + b₂

is an exact solution at every angle, with the boundary values read off it. The layer sits at the outflow corner and the interior is exponentially small, exactly as in one dimension.

The L in the denominator is the whole of what makes the test problem usable, and the first version of this measurement did not have it. Normalised by e^{1/ε} instead — the one-dimensional constant — the boundary data at the far corner of a 45° flow is e^{41}, every scheme is compared on numbers of order 10¹⁷, and the resulting table says nothing about schemes.

Three schemes at ε = 0.005, cell Péclet number 3.13The computed solution of each scheme against position, with the exact solution drawn as a dashed line. The tuned scheme's values lie on it — the largest nodal difference is 2.4·10⁻¹⁷. Upwinding is smooth and 0.136 away at its worst. Central differencing oscillates and leaves the interval [0, 1] at 16 of the 31 points.00.250.50.75100.51xuexact & tunedupwindcentralone of these is exacttuned, worst nodal error2.4·10⁻¹⁷upwind, worst nodal error0.14central, points outside [0, 1]16exact at every nodeand only at the nodes
Fig. 2 The one-dimensional result this essay tests: the tuned scheme’s solution lying on the exact one at every node, where central differencing oscillates and upwinding smears. Everything below is what happens to this picture when the flow leaves the grid.

Exactness at one angle

At θ = 0 the flow is along a grid line, the problem is one-dimensional, and the two-dimensional assembly reproduces the one-dimensional result exactly:

Pe tuned central upwind
0.63 1.7·10⁻¹⁶ 5.6·10⁻² 1.6·10⁻¹
1.56 3.5·10⁻¹⁷ 2.6·10⁻¹ 2.0·10⁻¹
3.13 2.4·10⁻¹⁷ 5.2·10⁻¹ 1.4·10⁻¹

Worst nodal error on a 15×15 grid. That the tuned column is at the level of rounding at three Péclet numbers, from an assembly that knows nothing about one dimension, is the check that the construction is the one the previous essay measured.

Now rotate the flow by five degrees.

Pe at 0° at 5°
0.63 1.7·10⁻¹⁶ 5.9·10⁻⁴
1.56 3.5·10⁻¹⁷ 3.0·10⁻³
3.13 2.4·10⁻¹⁷ 7.9·10⁻³

Twelve to fifteen orders of magnitude, for five degrees. And the fall is steeper the harder the problem is, which is the direction that matters: the sharper the layer, the more the exactness was worth and the less of it survives.

Nodal exactness is a property of the alignment, not of the scheme. In one dimension there is only one direction and the distinction cannot arise, which is why the result reads as being about ξ.

The cone

That the exactness goes is not by itself a criticism — a scheme can be inexact and still be the best available. The question is where it stops being the best available.

Pe tuned is the most accurate of the three out to
0.63 35°
1.56 25°
3.13 10°

Measured by sweeping the angle in five-degree steps and finding where another scheme takes the lead. The cone narrows as the layer sharpens, and at the sharpest layer drawn it is ten degrees wide.

Past it, the tuned scheme is not merely no longer best. At 45° and Pe = 3.13:

scheme worst nodal error
upwind 1.9·10⁻³
central 5.7·10⁻³
tuned 6.6·10⁻²

Thirty-five times upwinding’s, and twelve times the error of adding nothing at all — on a problem where at 0° the tuned scheme was exact and upwinding was wrong by 0.14.

That is a reversal, not a degradation, and the ratio between the two ends of it is 2·10¹⁷.

Why the interior errors fall with the angle

One column of the table above runs the wrong way at first reading: central differencing’s error falls from 5.2·10⁻¹ at 0° to 5.7·10⁻³ at 45°, as though rotating the flow made the problem easier.

It did not. The exact solution’s own size on the grid falls with the angle, because L grows from 1 to 1.41 and the layer moves further from every interior node: the largest exact value at an interior node is 1.9·10⁻³ at 0° and 1.5·10⁻⁴ at 45°. Relative to the solution, every scheme is worse at 45° — central differencing’s relative error is 268 at 0° and 39 at 45°, which is still an answer thirty-nine times the size of the thing it is approximating.

So the absolute errors are what the comparison between schemes rests on, and the relative ones are what says that none of the three is solving this problem at this resolution. Both are reported for that reason.

−εu″ + u′ = 0 on 31 points, ε = 0.005, cell Péclet 3.125Three solutions of a boundary-layer problem on the same grid. The exact one rises monotonically from 0 to 1 with a layer of width ε at the right-hand end. The central-difference answer alternates at every point and leaves [0, 1] at 16 of the 31 of them, by as much as 0.5152. The upwind answer is monotone at every Pe.00.250.50.75100.250.50.751xuexactcentral differencesupwindthe oscillation is exact‖Ax − b‖/‖b‖ for the central answer4.6·10⁻¹⁸values outside [0, 1]16worst excursion0.52the dashed lines are 0 and 1, which the equation guaranteesno solver was involved
Fig. 3 The one-dimensional threshold underneath all of this: the cell Péclet number at which central differencing starts to oscillate is exactly one, measured by bisection at 1.0000000000000002. Every Péclet number in this essay is above it.

What is actually added

The scheme adds a tensor, not a number, and the shape of it is where the rest of this essay comes from.

ε I → ε I + τ b bᵀ, with τ = ξ h / 2

In one dimension b bᵀ is the scalar 1 and the whole thing is a number. In two it is a rank-one matrix: τb₁² added to the xx diffusion, τb₂² to the yy, and τb₁b₂ to a cross term the five-point stencil does not have — so the discretisation grows a four-point diagonal stencil it did not previously need, and the matrix acquires entries at (i±1, j±1).

At θ = 0 that cross term is zero and the yy entry is zero: the added diffusion is entirely in x, which is the direction of the flow, and the scheme is the one-dimensional one applied along rows. At 45° the three coefficients are τ/2, τ/2 and τ/2, and the added diffusion is spread over five directions of which one is the flow.

The rank is the point. b bᵀ annihilates every direction perpendicular to b, so whatever τ is, the crosswind direction receives exactly nothing — which is the design, and which the next essay measures the price of.

Refining the grid fixes it, by removing the reason for the scheme

The obvious question about any of this is whether it survives refinement. At ε = 0.02 and 45°:

grid Pe tuned central upwind largest exact value on the grid
7×7 3.13 6.6·10⁻² 5.7·10⁻³ 1.9·10⁻³ 1.5·10⁻⁴
15×15 1.56 3.7·10⁻² 1.8·10⁻² 1.9·10⁻² 1.2·10⁻²
31×31 0.78 1.4·10⁻² 1.2·10⁻² 3.6·10⁻² 1.1·10⁻¹

Three things happen at once and only one of them is a convergence rate.

The Péclet number falls, because Pe = 1/(2ε(k+1)) and the grid is what is being refined. The exact solution’s size in the interior rises by three orders of magnitude, because the layer is now resolved and the domain is no longer almost entirely zero. And the three schemes converge on each other: at 31×31 the tuned scheme and central differencing are within 20% and upwinding is the worst of the three.

So the off-axis failure is a property of the under-resolved regime, and it disappears when the layer is resolved. That is not a reassurance. A resolved layer is the case where plain central differencing works and no artificial diffusion is wanted at all; the entire reason for a tuned scheme is the case where the layer is thinner than a cell. The failure lives exactly where the method is needed, which is the same sentence the depth phase wrote about the anisotropic V-cycle and is the reason both are worth measuring rather than bounding.

The third time

An aligned repair failing off its axis is now a pattern on this site rather than an observation.

The depth phase. A line smoother takes the anisotropic V-cycle’s convergence factor from 0.9565 to 0.0370, and semi-coarsening to 0.1074. Turn the same problem’s axes round and both return 0.967 and 0.966 — what the repair encodes is not cope with anisotropy but cope with anisotropy along y, and the direction was supplied by whoever typed the string.

The synthesis phase. Smoothed aggregation returns 0.193 on the aligned problem and 0.789 on the rotated one, and the reason is readable off the stencil before any solver runs.

And this. A scheme exact at 0° and the worst of three at 45°.

The three have nothing in common mathematically. One is a smoother, one is a coarsening, one is a discretisation; two are solvers and one is not. What they share is that each was tuned using a quantity measured along a coordinate direction — a line of the grid, a column of the stencil, a cell Péclet number computed from h — and each therefore encodes an assumption about where the difficulty lies that nothing in the method states.

The same anisotropy along each axis, ε = 0.001Six horizontal bars of convergence factor. The pairs aimed at the strong direction are short; the same methods on the same problem turned sideways are nearly full length.point · strong in y0.951point · strong in x0.956y-line · strong in y0.037y-line · strong in x0.967semi-y · strong in y0.107semi-y · strong in x0.9661.00 — no convergenceone problem, seen from two sidesy-line, aimed0.037y-line, turned sideways0.97the ratio2631×31 grid, twelve V-cyclesthe direction is in the code, not in the problem
Fig. 4 The depth phase’s version, drawn: two repairs that work beautifully on the aligned problem and both return 0.967 with the axes swapped. The figure in this essay is the same shape with a discretisation in place of a smoother.

What this does not say

Three limits on the claim, each of which would change the numbers.

The comparison is between three discretisations, not between three methods. All three use central differences for the convection term and differ only in what is added to the diffusion, which is the only way to attribute the difference to the addition. A practical upwind scheme differences the convection term itself, and is a different object from the one measured here even though it produces the same added diffusion in one dimension.

The flow is uniform. b is the same vector at every node, so “the angle to the grid” is one number rather than a field. In a real problem the flow turns, the alignment is good in one region and bad in another, and the tuned scheme is exact nowhere and best somewhere — which is a harder measurement and not obviously a worse situation, since the failure at 45° here is a failure over the whole domain at once.

And the exact solution is a function of one variable. That is what makes ground truth available at every angle, and it is also the most favourable possible case for a streamline method: the solution genuinely has no crosswind structure to represent. A scheme that adds nothing across the flow is being tested on a problem that has nothing across the flow, and it still fails at 45°.

That last one is worth sitting with. The failure is not that the crosswind physics was missed. There is no crosswind physics. It is that a discretisation which is correct along one direction and untouched across it produces an operator whose discrete solution has crosswind structure that the continuous one does not.

What a diagonal Péclet number would be

There is an obvious repair to try, and it is worth saying why it is not the repair.

The coefficient τ is built from a cell Péclet number Pe = |b|h/2ε, and h there is the grid spacing. For a flow at 45° the distance between grid lines along the flow is h√2, so a natural fix is to use the streamwise mesh size instead — a larger h, a larger Pe, a larger τ.

That changes the size of what is added and not its direction. The tensor is still τ b bᵀ, still rank one, still with nothing across the flow, and the crosswind oscillation the next essay measures is untouched by any choice of τ. A coefficient repair cannot fix a rank deficiency, which is the shape of the argument and is why the standard repairs add a second term rather than adjusting the first.

Where the error goes instead

The next essay is about the mechanism, and one figure from it belongs here because it answers the question this one leaves open: if the scheme is exact along the flow, what is it getting wrong?

The solution along a line across a flow at 30°Four curves along the anti-diagonal of the grid, which at 45° is exactly a line across the flow. The exact solution depends on the flow coordinate alone, so on this line it never rises above 1.96·10⁻²³ — the region the layer has decayed to nothing by. The streamline scheme's answer there swings over a range 8.9·10¹² times that value and changes direction 9 times; upwinding turns 1 time and stays inside [0, 1] everywhere on the grid, where the streamline scheme leaves it at 50 nodes.0246810121403.5·10⁻¹¹7·10⁻¹¹10⁻¹⁰1.4·10⁻¹⁰position across the flowcomputed valuestreamline onlywith crosswindexactwhat is left undampedturns along this line9swing, against the exact value8.9·10¹²nodes outside [0, 1]50with a crosswind term11upwind, for comparison0the exact solution is flat across the flowand the scheme aimed along it is not
Fig. 5 The computed solution along a line across the flow at 30°. The exact solution varies only along the flow, so on this line it should be smooth — and the scheme aimed along the flow is the one that oscillates.

The error is entirely across the flow. Along it the tuned coefficient is still doing what it does in one dimension; the direction it does not touch is the one where the discrete operator has been left with a central difference at a cell Péclet number above one, which is exactly the configuration the whole convection field exists to describe as unstable.

So the two-dimensional failure is the one-dimensional failure, in a direction the one-dimensional analysis has no name for. That is not a new mechanism; it is the same mechanism, unrepaired, because the repair was pointed somewhere else.

The optimal upwinding parameter, and the two schemes it containsξ = coth(Pe) − 1/Pe against the cell Péclet number on a logarithmic horizontal axis. It runs from zero to one: at small Pe it behaves like Pe/3, so the added diffusion vanishes faster than the grid and the scheme becomes central differencing; at large Pe it approaches one — 0.8333 at Pe = 6 — where the added diffusion is h/2 and the scheme becomes upwinding.10⁻²10⁻¹100.250.50.751cell Péclet numberξupwinding: ξ = 1Pe = 1ξ(Pe)Pe/3one curve, two schemesξ at Pe = 0.10.033ξ at Pe = 10.31ξ at Pe = 60.83central differencing at one endupwinding at the other
Fig. 6 The coefficient this essay carries into two dimensions, drawn against the Péclet number. Both older schemes are limits of the same curve, in one dimension.
The same three schemes on a problem with no layer in itWorst nodal error against the grid size, both axes logarithmic, for a manufactured smooth solution on the identical operator at ε = 0.005. Adding no diffusion gives 0.0016, 4·10⁻⁴, 10·10⁻⁵, falling by four at each refinement. The tuned diffusion gives 0.067, 0.022, 0.0061 — 42 times worse at the coarsest grid, and falling more slowly.10²10⁻⁴10⁻³10⁻²10⁻¹grid points nworst nodal errorupwindtunedcentralthe same tuning, another problemtuned ÷ central at n = 3142tuned ÷ central at n = 12761central's error at the finest grid10·10⁻⁵exact on the problem it was derived fromand harmful on the one beside it
Fig. 7 The exactness belongs to the problem: on a smooth manufactured solution of the identical operator the tuned scheme is forty-two times worse than adding nothing. This essay is the other boundary of the same result.
The upwind answer, against the two problems it might be answeringThe upwind solution drawn against two exact solutions: the one for the ε that was asked for, whose layer is thin, and the one for ε(1 + Pe) = 0.02063, whose layer is 4.125 times thicker. It lies on the second. The two operators are identical entry for entry, to 1.3·10⁻¹⁶.00.250.50.75100.250.50.751xuexact at ε = 0.005exact at ε(1 + Pe)the upwind answeran exact answer to a different question‖upwind(ε) − central(ε(1+Pe))‖/‖·‖1.3·10⁻¹⁶distance to the problem it solves0.39distance to the problem posed71the added diffusion is h/2 = 0.01563, whatever ε isso refining removes it
Fig. 8 What upwinding is: central differencing at a larger diffusion. In two dimensions that addition is isotropic, which is the property the tuned scheme gives up.

Why the exactness is a coincidence worth understanding

It is easy to read the one-dimensional result as a piece of good fortune — a coefficient that happens to make a discretisation exact — and the two-dimensional measurement says what kind of fortune it is.

The one-dimensional problem has an exact solution that is a single exponential, and the tuned difference operator has the same exponential as an exact discrete solution. The coefficient ξ = coth(Pe) − 1/Pe is the number that makes the discrete characteristic root equal the continuous one. That is a matching of two one-dimensional objects, and it is exact because both objects are one-dimensional.

In two dimensions the exact solution along a grid line is still that exponential, so the aligned case inherits the match. Off the axis the discrete operator’s characteristic behaviour is a two-dimensional object — a stencil with five or nine entries and a cross term — and there is no coefficient that makes it match, because there is no single number for a coefficient to be.

That is a stronger statement than the exactness does not extend. It says nothing of that shape can extend: a scalar τ cannot match a two-dimensional operator to a two-dimensional solution except in the cases where one of the two is degenerate. Which is why the practical schemes stopped looking for a better τ and started adding terms.

What the drag does

The slider is the diffusion, which is the Péclet number in disguise. Two things move with it and one does not.

The cone narrows: from about 35° at Pe = 0.63 to about 10° at 3.13. And the fall at five degrees gets steeper, because the exactness at zero is worth more when the layer is sharper.

What does not move is the exactness itself. At every position of the slider the tuned scheme reproduces the solution at the nodes to the level of rounding when the flow is along a grid line — which is what makes the cliff at the second point a statement about alignment rather than about the layer, and is the assertion the figure carries at every frame.

What links here

Computed from the collection, not written here: the essays that point at this one.

Named objects

A flat tag is an object no other essay names yet.

AnisotropyArtificial diffusionBoundary layerConvection diffusionGrid alignmentManufactured solutionNodal exactnessPeclet numberStreamline diffusionUpwinding