Skip to main content

build_flat_mesh

Function build_flat_mesh 

Source
pub fn build_flat_mesh(
    blocks: &[Block],
    face_matches: &[FaceMatch],
    outer_faces: &[FaceRecord],
) -> FlatMesh
Expand description

Build a flat mesh from multi-block Plot3D data.

This is the central conversion function: structured blocks + connectivity data are transformed into flat, GPU-friendly arrays.

§Pipeline

  1. Build dual graph: compute global cell numbering via build_cell_graph.
  2. Compute cell metrics: volumes and centroids for each block using the metrics module, then scatter into global arrays.
  3. Build interior faces: within each block, iterate over the three face families (I-faces, J-faces, K-faces). Each interior face connects two adjacent cells.
  4. Build cross-block faces: from the face_matches, each interface cell pair becomes a face. Area vectors are taken from the metrics of whichever block “owns” the face (block1 side).
  5. Build boundary faces: the outer_faces parameter lists all unmatched boundary surfaces. Each boundary face has neighbor = -1 and carries the surface’s ID for boundary condition dispatch.

§Arguments

  • blocks - All blocks in the multi-block grid.
  • face_matches - Block-block interface connectivity.
  • outer_faces - Unmatched boundary faces with surface IDs. Each FaceRecord should have its id field set to the desired surface ID.

§Returns

A FlatMesh ready for GPU upload.