Decoders and volume fields
From the model’s internal state to surface pressure, shear or volume flow at any query point.
Outcome: Recognise DeepONet's trunk as the first query decoder; explain anchors: expensive attention on a few points, cheap reads for millions; say why volume fields are usually harder than surface fields, and compare surrogate and solver in two planes.
Builds on Cross-attention and latent space, Neural operators
A surrogate ends with numbers an engineer can use: pressure and shear on the surface, velocity in the volume. The decoder produces them. Many current models use a query decoder.
DefinitionQuery decoder
From DeepONet's trunk to cross-attention
DeepONet's trunk was already a query decoder: a neural field whose output the branch weights for each case. A query decoder built from cross-attention, as in Example 6-4, generalises it: each location reads different parts of the internal state instead of one fixed weighting.
Anchor attention
The latent model compressed the points into learned tokens. Another design keeps real points and splits them in two. A sample of the mesh points, the anchors, carry the expensive attention among themselves. Every other point is a query point that attends to the anchors and to nothing else, so the cost is linear in the number of queries, and since no query depends on another they can be processed in chunks. The price is that a prediction depends on which anchors were drawn, so two draws should be compared on validation runs. AB-UPT (Anchored-Branched Universal Physics Transformer; Alkin and colleagues, 2025) is built this way, with thousands of anchors and up to millions of query points. Its separate branches handle surface and volume, which a classical simulation computes differently, while sharing the geometry encoding.
import torch
from torch import nn
B, N, A, d = 1, 200_000, 4_000, 128
# All surface and volume points, embedded as tokens.
tokens = torch.randn(B, N, d)
idx = torch.randperm(N)[:A] # A random anchor points1
anchors = tokens[:, idx] # (B, A, d)
mha = lambda: nn.MultiheadAttention(d, 8, batch_first=True)
self_attn, cross_attn = mha(), mha()
# Pressure and three velocity components.
head = nn.Linear(d, 4)
# A x A attention among the anchors only.
a = self_attn(anchors, anchors, anchors,2
need_weights=False)[0]
anchors = anchors + a
# The query points read the anchors: Q x A.
queries = tokens[:, :50_000]
r = cross_attn(queries, anchors, anchors,3
need_weights=False)[0]
print(head(r).shape) # (1, 50000, 4)
randpermshuffles the indices, so the first are a random sample without repeats.- Self-attention among the anchors only: a weight matrix of per head.
- Cross-attention from the queries to the anchors, . Queries never attend to each other, so they can be split into chunks and the results concatenated.
Example 6-6 prints torch.Size([1, 50000, 4]): pressure and three velocity components at 50,000 query points, read from 4,000 anchors.
Physics in the output
A decoder can also build a law into its output, for example a velocity with zero divergence, derived from a predicted stream function (Equation 7-4, in physics in the loss and in the model).
Surface and volume fields
Surface quantities (pressure, shear, heat flux) give the loads; volume quantities (velocity, pressure, temperature, vorticity) explain them: wakes, vortices, separation, mixing. Volume prediction is usually harder. A 3D simulation has far more cells than surface points, which usually makes volume data the main storage and loading cost of an industrial training set; the regions that matter are small; and the model must answer anywhere in space. The largest errors tend to sit in those small regions, such as thin shear layers, wakes and vortex cores. DrivAerML is one public benchmark with full car volume fields.
On the site's wing, two neural fields predict the flow in two planes (Figure 6-8), trained on the same simulations as the surface model.
Each plane is a small grid of points, but the principle is that of the volume decoders of AB-UPT and CANTO: the field is queried anywhere, not only on the surface.
Flow speed around the airfoil. Air accelerates over the upper surface (low pressure, lift) and stops near the leading edge (stagnation). Streamlines show the upwash ahead of the wing. Equivalent 2D angle here: 2°, section lift cl = 0.482.
Inside the training range: interpolation. RMSE 0.006 (|V| / V∞), largest error 0.29; the solver here is a 2D panel method.