Gyre/Mathematics & Numerical Methods
Curvilinear elements and metric terms
In one minuteElements are curved with the same polynomial technology as the solution. Metric terms are computed so that a uniform flow stays exactly uniform on any mesh, and they are evaluated inside the differentiated code so that shape derivatives come for free.
High-order accuracy near curved walls needs curved elements: a straight-sided mesh limits the whole solution to second order regardless of , and its kinks generate spurious entropy. Each Gyre element carries geometry nodes on an LGL lattice (degree , default 4) that define its polynomial mapping . Geometry nodes on shared faces are shared, so any smooth displacement of the global node array keeps the mesh watertight — which is how surface design variables enter.
On a curved element the divergence of a constant flux is discretised as . It vanishes only if the discrete metric identities
hold. If they do not, a uniform flow generates spurious waves at every curved element. Gyre satisfies the identities to round-off in 2-D and 3-D, including with viscous terms:
| dim | elements | p | geometry degree | viscous | min J / max J | max |Rw| | surface closure |
|---|---|---|---|---|---|---|---|
| 2-D | 6x5 | 3 | 4 | no | 0.451047 | 1.3492e-15 | 3.0531e-16 |
| 2-D | 6x5 | 3 | 4 | yes | 0.451047 | 1.3368e-15 | 3.0531e-16 |
| 2-D | 4x4 | 5 | 4 | no | 0.453556 | 2.8560e-15 | 4.9960e-16 |
| 2-D | 4x4 | 5 | 4 | yes | 0.453556 | 2.9091e-15 | 4.9960e-16 |
| 3-D | 3x3x3 | 2 | 2 | no | 0.276159 | 2.6316e-16 | 3.4694e-17 |
| 3-D | 3x3x3 | 2 | 2 | yes | 0.276159 | 2.6316e-16 | 3.4694e-17 |
| 3-D | 3x3x3 | 3 | 3 | no | 0.417089 | 3.2526e-16 | 6.9823e-17 |
| 3-D | 3x3x3 | 3 | 3 | yes | 0.417089 | 3.2823e-16 | 6.9823e-17 |
gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build
The geometry is first interpolated from the geometry nodes to the solution nodes (degree ), then differentiated with the same used for the solution.
Two dimensions. The cross-product form is already divergence-free discretely:
Three dimensions. Products such as are of degree and their derivatives no longer commute after interpolation, so the cross-product form violates the identities. Gyre uses Kopriva’s conservative curl form,
where is nodal interpolation at degree . Being the discrete curl of a polynomial, each contravariant vector is discretely divergence-free by construction.
Outward face normals and surface Jacobians are the face values of the same arrays: on the two faces normal to , which makes the normals of two elements sharing a face exactly opposite — a requirement for conservation.
Metric terms are not precomputed constants: Discretization.geometry(X) is an ordinary JAX
function of the global node coordinates . The residual is and the chain
is differentiated end-to-end by reverse-mode AD. There is no separate “mesh sensitivity” code to keep consistent with the solver. The verification study on mesh deformation checks the derivative of a geometric integral through this chain against finite differences.
Surface displacements are propagated to all high-order geometry nodes by inverse-distance weighting. The study deforms a NACA 0012 O-mesh with a thickness bump of increasing amplitude and checks that elements stay valid, that wall nodes follow the prescription exactly while far-field nodes stay fixed, and that the derivative of a geometric quantity through deformation and metric evaluation matches finite differences.
- scale 0.0: mesh valid (min J > 0)4.33e-05expected > 0pass
- scale 0.0: surface/far-field prescription defect0expected < 1e-13pass
- scale 0.5: mesh valid (min J > 0)4.33e-05expected > 0pass
- scale 0.5: surface/far-field prescription defect0expected < 1e-13pass
- scale 1.0: mesh valid (min J > 0)4.33e-05expected > 0pass
- scale 1.0: surface/far-field prescription defect0expected < 1e-13pass
- scale 2.0: mesh valid (min J > 0)4.33e-05expected > 0pass
- scale 2.0: surface/far-field prescription defect0expected < 1e-13pass
- d(weighted area)/d(surface displacement): AD vs FD1.08e-08expected < 1e-7pass
gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build
The coarsest p-multigrid level uses one node per element. Differentiating a one-point
“polynomial” gives no metrics, so this level takes its geometry from the degree-
description by exact reduction: the cell Jacobian is the mean , face normals are
the face integrals divided by the reference face area. For the
inviscid terms the resulting scheme is a first-order finite-volume method on the curved cell
whose faces close exactly (geometric conservation), verified in
test_finite_volume_geometry_reduction. The viscous terms keep only the face-normal two-point
difference at this level (penalty parameter).
All built-in generators evaluate a smooth mapping on the LGL lattice, so elements are curved to degree :
| generator | topology | notes |
|---|---|---|
airfoil_omesh |
O-mesh around a NACA 4-digit section or a spline fit of coordinate data | sharp trailing edge and leading edge at element vertices; wall-normal lines from a smoothed normal field; geometric wall-normal growth from a first cell of the requested height |
annulus |
O-mesh between two circles | cylinder flows |
bump_channel |
channel with a Gaussian bump | smooth-wall verification |
box |
Cartesian block, 2-D or 3-D | optional smooth warp that preserves periodicity |
A detail worth knowing: classical cosine clustering along the chord has zero parametric speed at the trailing edge, which makes the Jacobian vanish at the trailing-edge vertex. The aerofoil generator uses with , which keeps the smooth behaviour at the nose but a finite tangent at the trailing edge.
A mesh read from a file (mesh.generator: file) becomes the same global node array and
element lattice as a generated one, so everything on this page applies unchanged. For a Gmsh
file the reader maps Gmsh’s node ordering of each element onto the tensor-product lattice,
re-orients left-handed elements, and interpolates the equispaced Gmsh nodes to the
Legendre–Gauss–Lobatto distribution of the same degree (the identity up to degree 2). Lattice
nodes are numbered topologically (a vertex by its file node, an edge or face node by the
vertices of that edge or face and its position on it), so neighbouring elements share nodes
exactly and nodes that merely coincide in space, at a slit or a periodic pair, stay distinct.
Elements may meet in any relative orientation. A mesh is refused if the Jacobian determinant
is not positive at every geometry node. The
imported-mesh study tests these steps.