Gyre/Mathematics & Numerical Methods
Output error estimation
In one minuteThe adjoint that provides gradients also measures how much each element's unresolved residual contaminates an output. One extra linear solve yields an error estimate, a corrected output and per-element indicators.
A design optimizer exploits whatever errors the analysis has. Knowing the discretization error of the objective — not of the solution in some norm — is therefore the relevant quality measure, and the adjoint provides it.
Let denote the working space (degree ) and an enriched space (degree on the same mesh). Inject the converged coarse solution, . It does not satisfy the fine equations; the fine residual measures by how much. Linearising the fine output about the injected state gives
with the fine-space discrete adjoint linearised about . Gyre solves that one linear system with the p-multigrid hierarchy and returns
value,estimate,corrected, anderror$= J_h - $corrected;indicators: , the share of each element — the quantity an adaptation strategy would act on.
No fine nonlinear solve is needed.
The estimate is the first-order term of a Taylor expansion, so its error is quadratic in the distance between and . Its quality hinges on being a good approximation of the continuous adjoint, i.e. on adjoint consistency of the discretization and of the output definition (see BR2 and boundary conditions). For an adjoint-consistent scheme, outputs converge at up to twice the rate of the solution in the energy norm, and the corrected output converges faster still. Singularities (a sharp trailing edge) reduce these rates, as they reduce everything else.
Effectivity is assessed against the actually converged solution — an exact test of the estimator, independent of any “true” solution:
| mesh | p | cd (p) | estimate δ | corrected | cd (p + 1, converged) | effectivity | remaining / original error |
|---|---|---|---|---|---|---|---|
| 12x4 | 1 | 0.0177275 | -0.00857008 | 0.00634203 | 0.00569478 | 0.929779 | 0.0537907 |
| 24x8 | 1 | 0.012233 | -0.00806656 | 9.2333e-04 | 3.4443e-04 | 0.93304 | 0.0486938 |
| 12x4 | 2 | 0.00569478 | -0.0026344 | 5.0612e-04 | 1.4077e-04 | 0.878207 | 0.065781 |
| 24x8 | 2 | 3.4443e-04 | -2.0704e-04 | 2.1391e-05 | 1.4254e-05 | 0.966676 | 0.0216164 |
gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build
Reference: finest mesh at degree 4, a solution used by no plotted point and no estimate. It differs from the degree-3 output on the same mesh by 1.4e-05; the reference is itself a computed value, and differences of that size or below are not resolved. Corrected outputs are the injected p + 1 output plus the adjoint estimate.
Data table
| h (1 / nx) | p = 1: cd | p = 2: cd | p = 1: corrected | p = 2: corrected |
|---|---|---|---|---|
| 0.0833333 | 0.0177271 | 0.00569443 | 0.00634168 | 5.0577e-04 |
| 0.0416667 | 0.0122327 | 3.4408e-04 | 9.2298e-04 | 2.1043e-05 |
gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build
gyre run naca0012_euler --error cd
or request error_estimate: ["cd"] in a job, or call session_error_estimate from an agent.
The command prints value, estimate, corrected and error for each output. To keep the
per-element indicators, add -o <dir> (the full record is then in result.json) or use a job
or a session (the agent tool session_error_estimate returns them summarised).
In a design loop the estimate answers three practical questions: whether the current mesh/order is adequate for the objective at the current design, whether a change in the objective between two designs is larger than its numerical uncertainty, and where resolution is missing.
The estimate exists for the built-in scalar outputs, which can be rebuilt in the enriched
space with the same reference quantities; a user-defined functional or f_surface raises
KeyError. It is computed at a converged state only: a job, run_case() or gyre run whose
solve did not converge returns no estimate. The job result and the result of run_case() list
it under skipped; for gyre run that entry is in result.json (with -o <dir>), not in the
printed summary.
Order selection turns the estimate into a stopping rule. Given an output and an absolute tolerance, the case is solved at its own degree , the error of the output is estimated, and the degree is raised by one until
that is, until |error| of the estimate above is within the tolerance, or the largest allowed
degree is reached. Each new degree starts from the interpolated solution of the one below.
Usage is in Gradients and error estimates;
the order-selection study checks the rule.
- The lowest sufficient degree among those tried. Degrees are tried in ascending order from the case’s own, and the first whose estimate meets the tolerance is returned. Degrees below the starting one are never tried.
- Relative to the next degree. The estimate at degree predicts the output at on the same mesh. The tolerance therefore bounds the estimated distance to the output, not to the exact one. Where enrichment in captures little of the true error (a singularity, an under-resolved shock, a geometry that the mesh itself misrepresents) the estimate, and with it the selection, is optimistic.
- An estimate, not a bound. is a linearisation; on a mesh too coarse for it to
hold,
met: truesays that the estimate is within the tolerance, nothing more. - Only a certified estimate counts. The tolerance is met only by a finite estimate whose
adjoint solve converged. If a degree does not converge, after it has also been tried with
the full continuation and from the free stream, the selection stops with
met: falseand the last converged degree. - Uniform enrichment. Every element gets the same degree. The indicators are reported with the estimate but not used; the mesh is not changed.
- One output. The degree that suffices for one output need not suffice for another; other outputs of the result carry no accuracy statement unless their own estimate is requested.
- A discrete choice. The selected degree can change between two nearby designs, and the output then changes by the difference between two discretizations. Inside an optimization, select once and keep the degree fixed.