High-order output¶
How a run writes what its high-order reconstruction knows inside each cell, not only the cell averages. Issue #1448. User docs: The high-order view.
What is written¶
- A companion view, the solution files unchanged. Each whole-mesh
[[write_data]]entry invtkhdforvtuof a TENO run (on by default, so ParaView shows what the scheme computes;high_order = falseopts out) writesPREFIX_high_order...beside its own files, at the same steps, in the same format and series layout. The solution files stay cell averages byte for byte, so restarts,mallard post, statistics and every reader of cell values are untouched, and a user who wants neither size nor view deletes or skips the companion. Boundary, surface, region and point writers have no view: their samples are already point values or averages over something else. - Lagrange cells at the reconstruction's degree. A TENO run of order
rhas central polynomials of degreep = r - 1; each owned cell is a VTK Lagrange cell of orderpwhose nodes hold those polynomials. No lower degree: it would resample the scheme's polynomial into another one, and the view would no longer show what the scheme computed. The nodes are built once, shared by every writer. MUSCL and first order have no polynomial beyond the average: they write no view, andhigh_order = trueis an error there. - Point values where the reconstruction has them. Nodes of smooth cells
with admissible values take the central polynomial of the conservative
variables, the derived fields (
U,P,T,H,MACH, ...) from those point values. Troubled cells take the polynomial the flux's stencil selection chooses for the whole cell (TENOFunctor::troubled_point_polynomial), below; nodes outside the admissible set, and troubled cells whose polynomial leaves it at a face point (where the flux falls back to first order), take their averages, exactly as the probes'point_valuesampling does. Fields without a polynomial (indicators, sources, statistics,CFL, ...) are written as cell data of the view, so one file shows them all. The view's snapshot block names node fieldspoint_valuewith the reconstruction and its fallback. - Not a new solution format. Nothing reads the view back; restarts stay
cell averages.
mallard post derive --high-order onwrites it for runs written without it (from their restart files' averages, rebuilding the polynomials).
Cells and nodes¶
| Mesh cell | VTK cell | Nodes of order p | Exact for |
|---|---|---|---|
| triangle | VTK_LAGRANGE_TRIANGLE (69) |
(p+1)(p+2)/2 | P_p (affine) |
| quadrilateral | VTK_LAGRANGE_QUADRILATERAL (70) |
(p+1)^2 | P_p: x(xi) bilinear, P_p∘x ⊂ Q_p |
| tetrahedron | VTK_LAGRANGE_TETRAHEDRON (71) |
(p+1)(p+2)(p+3)/6 | P_p (affine) |
| hexahedron | VTK_LAGRANGE_HEXAHEDRON (72) |
(p+1)^3 | P_p: trilinear map, P_p∘x ⊂ Q_p |
| prism | VTK_LAGRANGE_WEDGE (73) |
(p+1)^2(p+2)/2 | P_p: map in P_1(xi,eta)⊗P_1(zeta) |
| pyramid | two VTK_LAGRANGE_TETRAHEDRON |
2 x (p+1)(p+2)(p+3)/6 | P_p (affine, planar base) |
- Exact interpolation. Each polynomial is evaluated at the cell's nodes and VTK interpolates between them in the cell's own space: affine simplices span P_p in physical coordinates; on quadrilaterals, hexahedra and prisms the bi-/trilinear geometry composed with P_p lies in the Lagrange space (Q_p, or P_p⊗Q_p), so the rendered field is the polynomial everywhere in the cell, not only at nodes.
- Curved cells keep their exact shape. A cell touching a curved face
takes explicit nodes: the cell's quadratic geometry (
quadratic_nodes, as before) at every Lagrange node, then the nodes on each curved face moved tocurved::Geometry::evalat their face coordinates (the face's corners give the affine map from the cell's reference coordinates to the face's), so the wall nodes lie on the exact curve or surface, not its quadratic interpolant. The polynomial is evaluated at those nodes, so the view is exact at nodes; between them VTK interpolates both the geometry and the field at the view's degree. Curved pyramids (rare: a pyramid on a curved wall) stay straight tetrahedra. - Pyramids as two tetrahedra. VTK defines
VTK_LAGRANGE_PYRAMID(74) but 9.x has no cell class for it: readers drop it. A Lagrange hexahedron with its top face collapsed to the apex draws correctly, but VTK's point location (Newton on the inverse map) fails at its singular apex: with VTK 9.7.1 a probe of a pyramid mesh found 59 of 300 interior points. Each pyramid is instead tetrahedra (0,1,2,4) and (0,2,3,4) on the base diagonal 0-2, positive like the pyramid: affine, so exact for P_p and located like any tetrahedron (all 300 of the same points), at the cost of view cells that are not mesh cells: a pyramid's cell data are repeated on its two tetrahedra, and the VTKHDF records carry the Lagrange cells of each mesh cell so the file stays in global cell order. Pyramids with a non-planar base are split along one diagonal, a first-order change of the geometry. - Orderings.
lagrange::latticenumbers nodes asvtkLagrangeTriangle...vtkLagrangeWedgedo: vertices, edges in VTK's edge order, faces in its face order (tetrahedron faces (0,1,3), (2,3,1), (0,3,2), (0,2,1) with recursive triangle interiors; hexahedron faces x=0, x=1, y=0, y=1, z=0, z=1, first free axis fastest; wedge triangle faces and body row-major, quad faces edge direction fastest), then the body. All five shapes at orders 1 to 6 were compared with VTK 9.7.1's parametric coordinates; the tests keep the orders where each rule first differs from its alternatives.
Troubled cells¶
The flux of a troubled cell selects stencils per face and per characteristic
variable, so the cell has no one polynomial. Its average (a flat cell) or
linear least squares (a straight one) is not what the scheme used either:
just above troubled_threshold the adaptive cutoff is 1e-10, so the flux
almost always keeps the central polynomial, and on coarse meshes of smooth
fields most cells can be troubled (64% of a 6 x 6 mesh of a 0.3 amplitude
Gaussian). Output therefore gives the cell the polynomial the selection would
choose for the whole cell, troubled_point_polynomial, from the flux's own
functions (smoothness, select_stencils, cutoff_of, bound_range,
bound_theta), decided on each conservative variable instead of each face's
characteristic ones. That is the one approximation: it is exact wherever the
central polynomial passes, and without characteristic variables the decision
does not depend on the face, so it is the flux's (order 4's face rule aside,
which here rejects the central polynomial if it would on any face).
Bound-preserving scaling takes theta from the output points, since those are
the values shown; a cell whose chosen polynomial is inadmissible at a face
point, where the flux falls back to first order, keeps its average.
Only output takes this path (point_values(..., select_troubled = true):
the view, probes, sampled surfaces): it is its own kernel
(OutputPointPass), so the per-step point values of transmissive boundaries
and particles keep PointPass unchanged. It recomputes the sector
coefficients and, in 3D, forms the smoothness matrix from the cell's moments
per cell, in the same single launch as before, with no host synchronization.
mallard post keeps the sector stencils when its output samples points (a
view or point probes), which costs their setup.
Writers¶
- VTKHDF. Its own
UnstructuredGridwithPointsper node (nodes are not shared between cells: neighbors' polynomials differ on their common face, and the discontinuity is what the view shows),Connectivitythe identity,PointDatafor node fields andCellDatafor the rest. Ranks gather nodes in global cell order, as cell data already are, so the file is the same on any number of ranks. Series: per-snapshot files with the geometry externally linked toPREFIX_high_order_mesh.vtkhdf, exactly as the solution's. - VTU / PVD. Each rank writes its piece's nodes and
PPointDatain the.pvtu; the.pvdlists the view's steps. - XDMF and restart files write no view: XDMF entries keep cell values, restart files the averages the solver restarts from.
Cost¶
- Size. Per snapshot the view writes
N_nodes x (3 + components)reals plus the cells, againstN_cells x componentsfor the solution: about(p+1)^dtimes the solution for tensor cells,(p+1)(p+2)/2for triangles.mallard checkreports each writer's projected bytes per snapshot, both, and warns (W-OUTPUT-SIZE) above 10 GB;high_order = falseopts an entry out. - Memory. The nodes' geometry and basis tables are built once at setup; values for the requested fields live in one pinned host array the writers read, and evaluation runs in chunks of 2^18 nodes, so the device scratch is bounded whatever the mesh.
- Device path. Node coordinates come from small basis tables times each
cell's geometry nodes (kernel), the point values from TENO's
point_valueson the chunk (the same kernel as the probes), and the fields from those (kernel), writing straight into the pinned array: no host work, no allocation and no synchronization per snapshot besides the writers' existing fence. The step graph stages it with the other output arrays, inside the conditional node of a due output (whenever any writer has a view: one flag fewer in the graph than a flag per view). - Measured (Apple M4 Pro, 2 threads, 256^2 periodic quadrilaterals,
TENO5, VTU of
RHO,U,Pevery 10 steps, 3 alternated runs each): the output phase takes 50 ms per snapshot with the view (evaluation, copy and queueing; the files are written in the background) against 2.6 ms without, out of 100 ms per step; the files are 18 times larger (613 MB against 34 MB for 5 snapshots); setup adds 35 ms.
Determinism¶
The view of a snapshot is a pure function of the cell averages, the mesh and the reconstruction: within a build it is bitwise the same on any number of ranks (VTKHDF in global cell order; VTU pieces per rank, as the solution). The polynomials need the halo current: the snapshot exchanges it once when a view is due.