Gyredocs
Depth Practice
API

Gyre/Verification

Imported meshes

In one minuteA mesh read from a Gmsh or NPZ file must behave exactly like a generated one. The study reads genuine Gmsh files, tests the node-ordering tables, the operator identities on unstructured curved meshes in 2-D and 3-D, and solves a flow with an adjoint derivative on an imported mesh.

Written at L2 Practice goes to L3 Mechanics 2576 words Markdown
PassedImported meshes29 of 29 checks passed · 184.5 s · quick suite

A mesh read from a file must behave exactly like a generated one, including unstructured topology, where neighbouring elements use different local axes. (i) Every Gmsh fixture of the test suite is read; the files are genuine Gmsh output (tools/make_mesh_fixtures.py), and on the straight-sided ones every high-order node must be the multilinear image of the element's vertices, which tests the node-ordering tables for quadrilaterals of degree 1 to 5 and hexahedra of degree 1 to 4. (ii) On curved unstructured meshes from Gmsh in 2-D and 3-D, and on a 3-D mesh whose elements were randomly re-oriented and passed through a file, a uniform flow must remain steady, the residuals of a perturbed state must sum to zero, and the inviscid residual of a continuous state must not depend on the Riemann solver away from the boundary (the jump across every face is zero only if its nodes are matched with the right ones of the neighbour; the viscous terms cancel in this comparison, so it is made for the Euler equations only). The coupling of the viscous terms across faces (gradient traces of the neighbour, lifted jumps) is tested separately, for both sets of equations: a rough state with varying velocity and temperature and a jump on every face must give the same residual, node by node, when every element of the mesh is stored in other, randomly chosen local axes. (iii) The coarse annulus of the cylinder case, written to a Gmsh file after randomly re-orienting its elements and read back through a case specification, must give the force coefficients of the generated mesh to solver tolerance. (iv) Laminar flow past a cylinder in a channel (Re = 40, M = 0.2, slip walls) is solved on the unstructured example mesh at degree 2, and the adjoint derivative of the drag coefficient with respect to the Mach number is compared with a central finite difference of re-converged flows.

  • usable Gmsh fixtures read15 of 15expected allpass
  • unusable Gmsh fixtures (triangles, binary, untagged) refused with a message3 of 3expected allpass
  • straight-sided fixtures cover quadrilaterals of degree 1–5 and hexahedra of degree 1–49expected = 9 (dimension, degree) pairspass
  • node ordering: largest distance of a node of a straight-sided mesh from the multilinear map of its vertices4.44e-15expected < 1e-13 (round-off; coordinates of order one)pass
  • straight-sided meshes: relative error of the area / volume3.06e-16expected < 1e-12 (the quadrature is exact for multilinear elements)pass
  • every straight-sided fixture is unstructured: fewest face pairs with a non-identity orientation44expected > 0pass
  • curved quadrilateral meshes (circular hole): area error at geometry degree pg + 1 relative to pg, largest0.1473expected < 1 (the boundary interpolant converges with the degree)pass
  • MSH 2.2 and MSH 4.1 files of one periodic mesh: largest node difference0expected < 1e-12pass
  • periodic node pairs of the file became topology (slave nodes)13expected > 0, and no boundary group on the periodic sidespass
  • hole_quad_p3.msh (Gmsh, curved, 2-D), inviscid: perturbed state is not trivial (max |Rw|)0.4158expected > 1e-3pass
  • hole_quad_p3.msh (Gmsh, curved, 2-D), viscous: perturbed state is not trivial (max |Rw|)0.4359expected > 1e-3pass
  • hole_quad_p3.msh (Gmsh, curved, 2-D): face pairs with a non-identity orientation48expected > 0pass
  • hole_hex_p2.msh (Gmsh, curved, 3-D), inviscid: perturbed state is not trivial (max |Rw|)0.6203expected > 1e-3pass
  • hole_hex_p2.msh (Gmsh, curved, 3-D), viscous: perturbed state is not trivial (max |Rw|)0.3062expected > 1e-3pass
  • hole_hex_p2.msh (Gmsh, curved, 3-D): face pairs with a non-identity orientation72expected > 0pass
  • periodic warped 3x3x3 box, re-oriented, written and read back, inviscid: perturbed state is not trivial (max |Rw|)0.1151expected > 1e-3pass
  • periodic warped 3x3x3 box, re-oriented, written and read back, viscous: perturbed state is not trivial (max |Rw|)0.1204expected > 1e-3pass
  • periodic warped 3x3x3 box, re-oriented, written and read back: face pairs with a non-identity orientation74expected > 0pass
  • re-oriented 3-D box read from a file: relative face orientations present8expected = 8 (all)pass
  • free stream on imported meshes: largest max |Rw|4.44e-15expected < 1e-12pass
  • conservation on imported meshes: largest |sum of Rw| of a perturbed state1.38e-14expected < 1e-12 (residuals of order 0.1 to 1)pass
  • neighbour matching on imported meshes (inviscid): largest |Rw(Roe) − Rw(LLF)| off the boundary for a continuous state9.99e-16expected < 1e-12 (zero jump across every correctly matched face; residuals of order 0.1 to 1)pass
  • neighbour coupling on imported meshes, Euler and Navier–Stokes: largest difference of the residual of a rough state between two descriptions of the mesh (elements re-oriented)2.48e-14expected < 1e-12 (round-off; residuals of order 0.1 to 1)pass
  • the rough state exercises the viscous terms: smallest max |Rw(Navier–Stokes) − Rw(Euler)|0.02271expected > 1e-3 (velocity and temperature vary; far above the bound of the coupling check)pass
  • generated and imported annulus: both solves convergedyesexpected truepass
  • imported annulus: face pairs with a non-identity orientation42expected > 0 (elements were re-oriented before writing)pass
  • force and moment coefficients, |imported − generated| (largest)2.13e-14expected < 1e-10 (both solves reduce the residual by 1e-12)pass
  • cylinder in a channel (examples/meshes/cylinder_channel_p3.msh), Re = 40, p = 2: convergedyesexpected truepass
  • cylinder in a channel: dcd/dmach, adjoint vs central finite difference (rel.)1.18e-07expected < 1e-6pass

Run notes Measured in this run: the largest free-stream residual on the imported meshes was 4.4e-15, the largest conservation defect 1.4e-14 and the largest dependence of the inviscid residual of a continuous state on the Riemann solver 1.0e-15. The residual of a rough state changed by at most 2.5e-14 when the elements were re-oriented, with and without viscous terms; the viscous terms contributed between 2.3e-02 and 1.4e-01 to that residual. Conservation alone would not notice a wrong index map between two straight faces (their normals are constant); the Riemann-solver comparison (trace matching, an inviscid test: the viscous terms cancel in it), the comparison of two descriptions (which includes the gradient traces and lifted jumps of the viscous discretization) and the solves of parts (iii) and (iv) do. The annulus written to a file with re-oriented elements (42 of 84 face pairs with a non-identity orientation) gave force coefficients within 2.1e-14 of those on the generated mesh. On the example mesh the adjoint derivative of the drag coefficient with respect to the Mach number differs from the central difference by a relative 1.2e-07. The Gmsh fixtures contain only two of the eight relative face orientations of hexahedra (see the table); all eight occur in the re-oriented box, which is written by Gyre's own writer, not by Gmsh.

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

A generated mesh is a structured block: neighbouring elements share their local axes. A mesh from a file is unstructured, so two elements can meet with any relative orientation of their common face, and the file’s node ordering has to be mapped onto Gyre’s tensor-product lattice. The study tests those two things, then the whole path from a file to forces and derivatives.

Reading Gmsh files#

Gmsh fixtures (tests/data/meshes)Imported meshes
filedimgeometry degreeelementsnodesface pairs with non-identity orientationmin scaled Jacobiandistance from the multilinear maprelative area / volume errorformat / outcome
hole_hex_p2.msh3278896720.138625—4.3003e-05gmsh-4.1
hole_quad_p2.msh22136600480.361963—2.7250e-06gmsh-4.1
hole_quad_p3.msh231361308480.361963—4.0127e-07gmsh-2.2
hole_quad_p4.msh241362288480.361963—1.0421e-09gmsh-4.1
periodic_channel_p3_v2.msh232424700.886508——gmsh-2.2
periodic_channel_p3_v4.msh232424700.886508——gmsh-4.1
reject_binary.msh————————refused: binary MSH files are not supported: save as ASCII (Mesh.Binary = 0, or `gmsh -format msh41
reject_triangles.msh————————refused: the mesh contains triangles. Gyre needs an all-quadrilateral (2-D) or all-hexahedral (3-D)
reject_untagged.msh————————refused: 32 boundary faces belong to no physical group (the first one is near (3, -1.125)). Give ev
straight_hex_p1.msh3160126440.31030201.5292e-16gmsh-2.2
straight_hex_p2.msh3260720440.3103021.3323e-150gmsh-4.1
straight_hex_p3.msh33602142440.3103022.2204e-150gmsh-2.2
straight_hex_p4.msh34604752440.3103024.4409e-153.0585e-16gmsh-4.1
straight_quad_p1.msh21120144440.47363401.2234e-16gmsh-4.1
straight_quad_p2.msh22120528440.4736341.3323e-150gmsh-2.2
straight_quad_p3.msh231201152440.4736341.3323e-152.4468e-16gmsh-4.1
straight_quad_p4.msh241202016440.4736342.4425e-152.4468e-16gmsh-2.2
straight_quad_p5.msh251203120440.4736343.1086e-152.4468e-16gmsh-4.1

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

The files under tests/data/meshes are genuine Gmsh output, produced by tools/make_mesh_fixtures.py. The reader is therefore tested against Gmsh’s node ordering, not against Gyre’s own writer.

  • Node ordering. On the straight-sided fixtures every high-order node must be the multilinear image of the element’s vertices, to round-off. A wrong entry in an ordering table moves a node by a fraction of an element. The fixtures cover quadrilaterals of degree 1 to 5 and hexahedra of degree 1 to 4, which is every element type the reader accepts.
  • Area and volume. The quadrature of a multilinear element is exact, so the measure of each straight-sided mesh must match the geometry to round-off.
  • Curved boundaries. On the meshes with a circular hole, the error of the area must fall when the geometry degree is raised.
  • Format versions and periodicity. The MSH 2.2 and MSH 4.1 files of one periodic mesh must give the same nodes, and the periodic node pairs of the file must become periodic topology with no boundary group on the periodic sides.
  • Refusal. Files with triangles, a binary file and a file with untagged boundary faces must be refused with a message.

Operator identities on unstructured meshes#

Free stream, conservation and neighbour coupling on imported meshesImported meshes
meshpequationselementsinterior face pairsnon-identity orientationrelative orientations presentfree stream max |Rw|perturbed nodesperturbed elementsmax |Rw| of the perturbed state|sum of Rw| (conservation)max |Rw| of the continuous state (inviscid)max |Rw(Roe) − Rw(LLF)| off the boundary (inviscid)non-identity orientation after re-orientingmax |Rw| of the rough statemax |Rw(Navier–Stokes) − Rw(Euler)| of the rough statemax |Rw − Rw re-oriented| of the rough state
hole_quad_p3.msh (Gmsh, curved, 2-D)3Euler136244482 of 24.4409e-151956 of 21761360.4157746.0785e-150.3742429.9920e-161310.825899—2.4758e-14
hole_quad_p3.msh (Gmsh, curved, 2-D)3Navier–Stokes136244482 of 24.4409e-151344 of 2176840.4358981.3767e-14——1310.8578550.1081842.4813e-14
hole_hex_p2.msh (Gmsh, curved, 3-D)2Euler78172722 of 81.0527e-151162 of 2106780.6202723.9101e-150.7321095.2736e-161560.846379—7.3830e-15
hole_hex_p2.msh (Gmsh, curved, 3-D)2Navier–Stokes78172722 of 81.0527e-15162 of 210660.3061935.2173e-15——1560.8539960.1398577.3830e-15
periodic warped 3x3x3 box, re-oriented, written and read back2Euler2781748 of 85.2633e-16729 of 729270.1151165.4123e-160.1132262.6368e-16670.181751—4.4686e-15
periodic warped 3x3x3 box, re-oriented, written and read back2Navier–Stokes2781748 of 85.2633e-16729 of 729270.1204251.8596e-15——670.187040.02271054.4756e-15

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

The meshes are a curved 2-D Gmsh mesh, a curved 3-D Gmsh mesh, and a periodic warped 3-D box whose elements were randomly re-oriented, written to a file and read back.

  • Free stream. A uniform flow must leave the residual at round-off.
  • Conservation. The residuals of a perturbed state must sum to zero. This test alone would not notice a wrong index map between two straight faces, whose normals are constant.
  • Neighbour matching. For a continuous state the inviscid residual must not depend on the Riemann solver away from the boundary: the jump across a face is zero only if its nodes are matched with the right nodes of the neighbour. The viscous terms cancel in this comparison, so it is an Euler test.
  • Neighbour coupling, including the viscous terms. A rough state with varying velocity and temperature and a jump on every face must give the same residual, node by node, when every element of the mesh is stored in other, randomly chosen local axes. This covers the gradient traces of the neighbour and the lifted jumps of the viscous discretization, for the Euler and the Navier–Stokes equations. A companion check requires that the viscous terms contribute to that residual, so the comparison is not vacuous.

Each configuration also has a check that the perturbed state is not trivial and that the mesh has face pairs with a non-identity orientation.

Two hexahedra can meet in eight relative face orientations. The table lists which of them occur in each mesh; the run notes state how many the Gmsh fixtures contain. All eight are required of the re-oriented box, and that mesh is written by Gyre’s own writer, not by Gmsh. The complete set of orientations is therefore tested on the operator, through a file, but not on files from an external generator.

From a file to forces and derivatives#

Cylinder Re = 40 on the generated annulus (12 x 4, p = 2) and on the same mesh read from a fileImported meshes
quantitygeneratedimporteddifference
cd1.698241.698242.1316e-14
cl-2.0933e-14-2.1852e-149.1940e-16
cm-2.8159e-15-6.9159e-154.1000e-15
Newton steps1313—
final / reference residual4.0911e-143.5832e-14—

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

Residual histories on generated and imported meshesImported meshes

The histories of the generated and of the imported annulus coincide.

Data table
seriesnonlinear iteration|Rw|
annulus, generated028.3595
annulus, generated118.8413
annulus, generated215.4035
annulus, generated35.38765
annulus, generated44.32122
annulus, generated51.04459
annulus, generated60.203824
annulus, generated70.0763292
annulus, generated80.00731001
annulus, generated91.0453e-04
annulus, generated101.0185e-06
annulus, generated118.2949e-09
annulus, generated125.3854e-11
annulus, generated131.1602e-12
annulus, re-oriented and read from a file028.3595
annulus, re-oriented and read from a file118.8413
annulus, re-oriented and read from a file215.4035
annulus, re-oriented and read from a file35.38765
annulus, re-oriented and read from a file44.32122
annulus, re-oriented and read from a file51.04459
annulus, re-oriented and read from a file60.203824
annulus, re-oriented and read from a file70.0763292
annulus, re-oriented and read from a file80.00731001
annulus, re-oriented and read from a file91.0453e-04
annulus, re-oriented and read from a file101.0185e-06
annulus, re-oriented and read from a file118.2949e-09
annulus, re-oriented and read from a file125.3709e-11
annulus, re-oriented and read from a file131.0162e-12
cylinder in a channel (Gmsh mesh)024.7737
cylinder in a channel (Gmsh mesh)113.8753
cylinder in a channel (Gmsh mesh)28.51098
cylinder in a channel (Gmsh mesh)35.12228
cylinder in a channel (Gmsh mesh)43.3529
cylinder in a channel (Gmsh mesh)52.0295
cylinder in a channel (Gmsh mesh)60.910516
cylinder in a channel (Gmsh mesh)70.36902
cylinder in a channel (Gmsh mesh)80.0892722
cylinder in a channel (Gmsh mesh)90.0363698
cylinder in a channel (Gmsh mesh)100.00262342
cylinder in a channel (Gmsh mesh)113.1460e-05
cylinder in a channel (Gmsh mesh)123.0281e-07
cylinder in a channel (Gmsh mesh)132.5325e-09
cylinder in a channel (Gmsh mesh)141.9079e-11

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

The coarse annulus of the cylinder case is written to a Gmsh file after its elements were randomly re-oriented, and read back through a case specification with mesh.generator: file. Both solves must converge, and the force and moment coefficients must agree with those on the generated mesh to solver tolerance. This exercises the case path for mesh files (boundary conditions per group, reference quantities) and the solver on a mesh with non-identity orientations.

Cylinder in a channel on examples/meshes/cylinder_channel_p3.mshImported meshes
quantityvalue
elements284
geometry degree3
degrees of freedom10224
face pairs with a non-identity orientation104 of 528
Newton steps14
final / reference residual7.7014e-13
cd3.21039
cl2.2180e-04
cm (about the cylinder axis)-0.00200862
dcd/dmach, adjoint0.331089
dcd/dmach, central difference (step 0.0001)0.331089
relative difference1.1825e-07

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

Laminar flow past a cylinder in a channel (Re=40Re = 40, M=0.2M = 0.2, slip walls) is solved at degree 2 on examples/meshes/cylinder_channel_p3.msh, an unstructured mesh of cubic quadrilaterals. The solve must converge, and the adjoint derivative of the drag coefficient with respect to the Mach number must match a central finite difference of re-converged flows.

  • No flow solve on an imported 3-D mesh. The 3-D evidence is the operator identities above; the 3-D solver path is tested on a generated mesh in Three-dimensional consistency.
  • No comparison with a reference solution on the channel mesh. That case shows that the solver converges and that the adjoint is consistent with the discrete problem; it is not an accuracy study.
  • Mesh quality. The reader refuses elements with a non-positive Jacobian determinant and reports the smallest scaled Jacobian. It does not judge whether a valid mesh resolves the flow.
  • The NPZ format and malformed files are covered by the unit tests in tests/test_meshio.py (Testing strategy), not by this study.
bash
gyre verify --only imported_mesh
gyre mesh info examples/meshes/cylinder_channel_p3.msh

The second command prints the summary of the example mesh: size, geometry degree, boundary groups, quality numbers and content hash.

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