zoomy_core.mesh.distributed#
Distributed meshes: each MPI rank holds its owned cells plus two halo layers and never the whole mesh, with cells numbered along a Hilbert (2D) or Morton (3D) space-filling curve. Backend-neutral (numpy, h5py, mpi4py); a backend adds the halo exchange and global reductions.
Module Contents#
Classes#
In-memory mesh (identical on every rank) renumbered on the fly; |
|
Mesh file written by |
|
One rank’s piece: local cells (owned, then halo layer 1, then 2) and the exchange lists;
|
Functions#
Position along the space-filling curve of centres |
|
Cell order along the space-filling curve through the centres |
|
|
|
Arrays of |
|
Write |
|
Read a mesh file as one serial BaseMesh. |
|
FileSource for a path, ArraySource for a mesh. |
|
Write the mesh file of |
|
Build this rank’s local BaseMesh (owned cells, two halo layers, cut faces tagged |
Data#
API#
- zoomy_core.mesh.distributed.HALO#
‘halo’
- zoomy_core.mesh.distributed.FORMAT_VERSION#
3
- zoomy_core.mesh.distributed.curve_keys(centers, lo, hi)#
Position along the space-filling curve of centres
(dim, n)in the boxlo..hi(Hilbert in 2D, Morton in 3D, x in 1D).
- zoomy_core.mesh.distributed.curve_order(centers)#
Cell order along the space-filling curve through the centres
(dim, n), ties by index.
- zoomy_core.mesh.distributed.cell_face_tags(mesh)#
(faces_per_cell, n_inner_cells)physical tag of each boundary face at its inner cell’s local face, -1 elsewhere.
- zoomy_core.mesh.distributed.partitioned(mesh)#
Arrays of
meshin the global numbering (cells along the curve, vertices by first appearance), built from the cells’ own faces so a periodic remap ofboundary_face_cellsdoes not enter.
- zoomy_core.mesh.distributed.write_mesh(mesh, path, cell_data=None)#
Write
meshas a partition-ready mesh file (serial); usewrite_mesh_parallelfor large meshes.Args
cell_data:{name: (n_cells,)}per-cell values in the mesh’s cell order.
- zoomy_core.mesh.distributed.read_mesh(path)#
Read a mesh file as one serial BaseMesh.
- class zoomy_core.mesh.distributed.ArraySource(mesh)#
In-memory mesh (identical on every rank) renumbered on the fly;
cell_ids/vertex_idsmap the global numbering back to the mesh.Initialization
Renumber
meshinto the global numbering.- is_file#
False
- cells(ids)#
Vertex ids of the cells
ids,(verts_per_cell, n).
- face_tags(ids)#
Face tags of the cells
ids,(faces_per_cell, n).
- vertices(ids)#
Coordinates of the vertices
ids,(dim, n).
- periodic_partners(bcs)#
Periodic faces of
bcsin the global numbering as(cell, slot, partner): faceslotofcelltakespartner’s state.
- periodic_vertices(bcs)#
Seam vertex identification of
bcsin the global vertex numbering,(canon, translations).
- class zoomy_core.mesh.distributed.FileSource(path)#
Mesh file written by
write_mesh; each read touches only the rows asked for.Initialization
Open the mesh file at
path; raises ValueError if it is not partition-ready.- is_file#
True
- cell_data(name, ids)#
Per-cell values
nameof the cellsids.
- cells(ids)#
Vertex ids of the cells
ids,(verts_per_cell, n).
- face_tags(ids)#
Face tags of the cells
ids,(faces_per_cell, n).
- vertices(ids)#
Coordinates of the vertices
ids,(dim, n).
- abstract periodic_partners(bcs)#
Not supported from a file; pass the mesh object instead.
- periodic_vertices#
None
- zoomy_core.mesh.distributed.source(mesh)#
FileSource for a path, ArraySource for a mesh.
- zoomy_core.mesh.distributed.write_mesh_parallel(comm, path, mesh_type, X, v0, cv, c0, *, faces=None, face_tags=None, tag_names=None, default_tag=0, cell_data=None)#
Write the mesh file of
write_meshfrom pieces held by the ranks, no rank holding the whole mesh.Args
X: this rank’s vertices(dim, n), idsv0, v0 + 1, ...in contiguous rank-ordered blocks.cv: this rank’s cells(verts_per_cell, n)with global vertex ids, idsc0, c0 + 1, ....faces: boundary elements(verts_per_face, n)withface_tags(any rank); untagged boundary faces getdefault_tag.cell_data:{name: (n,)}of this rank’s cells.
- class zoomy_core.mesh.distributed.Partition(comm, src, offsets, gids, n_own, n_ring, vids, send, recv, periodic=None, periodic_ids=None)#
One rank’s piece: local cells (owned, then halo layer 1, then 2) and the exchange lists;
cells/verticesmap local to the source’s numbering.Initialization
Store the rank’s cells, vertices, exchange lists and periodic data, and clone
commfor host-side collectives.- gather(X, root=0)#
Owned columns of
X(rows, local cells)from every rank in the source’s cell order, onroot(None elsewhere).
- scatter(X_global)#
Local columns (owned plus halo) of a global
(rows, cells)array.
- sum_to_global(G_local, ids, n_global)#
Sum local contributions per global index over all copies on all ranks, i.e. the derivative with respect to a global quantity every rank holds copies of.
Args
ids: global index of each local column (self.vertices,self.cells), or None for replicated parameters.
- resolve_periodic(local_mesh)#
Point every periodic face whose partner cell this piece holds at the partner’s halo copy.
- check(local_mesh)#
Raise if a cut face touches an owned or first-layer cell, i.e. the halo is too thin.
- parallel_io()#
Whether each rank can write its own block (mesh-file source and h5py with MPI).
- write_mesh(path, names=None)#
Write the output file’s
/mesh(each rank its share of the input blocks) and the field names.
- write_fields(path, i, time, Q, Qaux)#
Write snapshot
i, each rank its owned columns ofQandQaux.
- zoomy_core.mesh.distributed.distribute(src, comm, bcs=None)#
Build this rank’s local BaseMesh (owned cells, two halo layers, cut faces tagged
halo) and itsPartition. Periodic partners of owned cells join layer 1 and those of layer 1 join layer 2.Args
src: ArraySource, FileSource, mesh or path.bcs: boundary conditions; theirPeriodicentries are paired across ranks.
Returns
(local_mesh, partition).