Gyredocs
Depth Practice
API

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.

Written at L3 Mechanics goes to L4 Theory 1011 words Markdown

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 hh denote the working space (degree pp) and HH an enriched space (degree p+1p+1 on the same mesh). Inject the converged coarse solution, UHh=I Uh\mathbf U_H^h = \mathbf I\,\mathbf U_h. It does not satisfy the fine equations; the fine residual Rw,H(UHh)\mathbf R_{w,H}(\mathbf U_H^h) measures by how much. Linearising the fine output about the injected state gives

δJ  ≡  JH(UH)−JH(UHh)  ≈  −ψHT Rw,H(UHh),\delta J \;\equiv\; J_H(\mathbf U_H) - J_H(\mathbf U_H^h) \;\approx\; -\boldsymbol\psi_H^{\mathsf T}\,\mathbf R_{w,H}(\mathbf U_H^h),

with ψH\boldsymbol\psi_H the fine-space discrete adjoint linearised about UHh\mathbf U_H^h. Gyre solves that one linear system with the p-multigrid hierarchy (p+1,p,…,0)(p+1, p, \dots, 0) and returns

  • value =Jh= J_h, estimate =δJ=\delta J, corrected =JH(UHh)+δJ= J_H(\mathbf U_H^h) + \delta J, and error $= J_h - $ corrected;
  • indicators: ηe=∣∑i∈eψH,i⋅Rw,H,i∣\eta_e = \big|\sum_{i\in e}\boldsymbol\psi_{H,i}\cdot\mathbf R_{w,H,i}\big|, 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 UHh\mathbf U_H^h and UH\mathbf U_H. Its quality hinges on ψH\boldsymbol\psi_H 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 p+1p+1 solution — an exact test of the estimator, independent of any “true” solution:

Adjoint-weighted-residual estimate versus the p + 1 solutionOutput error estimation
meshpcd (p)estimate δcorrectedcd (p + 1, converged)effectivityremaining / original error
12x410.0177275-0.008570080.006342030.005694780.9297790.0537907
24x810.012233-0.008066569.2333e-043.4443e-040.933040.0486938
12x420.00569478-0.00263445.0612e-041.4077e-040.8782070.065781
24x823.4443e-04-2.0704e-042.1391e-051.4254e-050.9666760.0216164

gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build

Drag error: raw and adjoint-correctedOutput error estimation

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: cdp = 2: cdp = 1: correctedp = 2: corrected
0.08333330.01772710.005694430.006341685.0577e-04
0.04166670.01223273.4408e-049.2298e-042.1043e-05

gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build

bash
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 p0p_0, the error of the output is estimated, and the degree is raised by one until

∣Jh−(JH(UHh)+δJ)∣≤tolerance,|J_h - (J_H(\mathbf U_H^h) + \delta J)| \le \text{tolerance},

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 pp predicts the output at p+1p + 1 on the same mesh. The tolerance therefore bounds the estimated distance to the p+1p + 1 output, not to the exact one. Where enrichment in pp 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. δJ\delta J is a linearisation; on a mesh too coarse for it to hold, met: true says 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: false and the last converged degree.
  • Uniform enrichment. Every element gets the same degree. The indicators ηe\eta_e 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.

    ↑ ↓ moveEnter open[ ] change depthResults show section and depth level