zoomy_core.mesh.geometry_xp

zoomy_core.mesh.geometry_xp#

Mesh geometry for the solver template (prepare_mesh): static topology and LSQ stencils built once in numpy (build_topology), then gather-only geometry and LSQ operators from the node coordinates (compute_geometry). It is written against X.__array_namespace__(), so numpy and jax.numpy run the same code and jax.grad w.r.t. X goes through; the module never imports jax.

Module Contents#

Classes#

MeshTopology

Static integer topology plus frozen geometric decisions (normal signs, ghost ranges, LSQ stencils and plan, TPFA masks, boundary routing) of a mesh.

Functions#

periodic_vertices

Identify the vertices of periodic seams; returns (canon, translations) or None without Periodic BCs.

cell_face_geometry

FVMMesh geometry of mesh (cell centres with ghost mirrors, volumes, inradii, face normals, volumes, centres), vectorised in numpy.

build_topology

Build the static topology and LSQ stencils of mesh once in numpy, freezing the geometric decisions (normal orientation, ghost axes, boundary routing by tag name, periodic partners).

compute_geometry

All template geometry from the node coordinates X (dim, n_vertices), numpy or jax.numpy as X decides; gather-only and differentiable in X.

lsq_closure_derivatives

Boundary-closure LSQ derivatives for the rows of U that have a closure class, at the closure cells.

lsq_derivatives

Batched LSQ derivatives of the fields U (n_v, n_cells) using ghost values at the boundary-face virtual points, rows with a closure class taking the constrained fit.

lsq_gradient

First derivatives (n_v, dim, n_cells) from lsq_derivatives.

API#

class zoomy_core.mesh.geometry_xp.MeshTopology#

Static integer topology plus frozen geometric decisions (normal signs, ghost ranges, LSQ stencils and plan, TPFA masks, boundary routing) of a mesh.

dim: int#

None

mesh_type: str#

None

n_cells: int#

None

n_inner_cells: int#

None

n_faces: int#

None

n_vertices: int#

None

n_boundary_faces: int#

None

cell_vertices: numpy.ndarray#

None

cell_faces: numpy.ndarray#

None

face_cells: numpy.ndarray#

None

face_vertices: numpy.ndarray#

None

face_sign: numpy.ndarray#

None

face_first_cell: numpy.ndarray#

None

boundary_faces: numpy.ndarray#

None

boundary_owner: numpy.ndarray#

None

boundary_ghost: numpy.ndarray#

None

interior_faces: numpy.ndarray#

None

interior_A: numpy.ndarray#

None

interior_B: numpy.ndarray#

None

face_other_inner: numpy.ndarray#

None

inradius_fallback: numpy.ndarray#

None

lsq_degree: int#

None

lsq_monomial_multi_index: tuple#

None

lsq_scale_factors: numpy.ndarray#

None

lsq_grad_cols: numpy.ndarray#

None

lsq_neighbors: numpy.ndarray#

None

lsq_boundary_face_neighbors: numpy.ndarray#

None

lsq_plan: dict#

‘field(…)’

lsq_shift: Optional[numpy.ndarray]#

‘field(…)’

lsq_closure_class: dict#

‘field(…)’

tpfa_faces: numpy.ndarray#

‘field(…)’

tpfa_A: numpy.ndarray#

‘field(…)’

tpfa_B: numpy.ndarray#

‘field(…)’

tpfa_boundary_valid: numpy.ndarray#

‘field(…)’

bc_tags: Optional[list]#

None

bc_branch: Optional[numpy.ndarray]#

None

bc_input_cells: Optional[numpy.ndarray]#

None

bc_periodic: Optional[numpy.ndarray]#

None

property ghost_range#

Ghost cells are range(n_inner_cells, n_cells).

branch_groups()#

[(branch, boundary-face positions), ...] of bc_branch.

zoomy_core.mesh.geometry_xp.periodic_vertices(mesh, bcs, centers=None)#

Identify the vertices of periodic seams; returns (canon, translations) or None without Periodic BCs.

Args

  • centers: cell centres (3, n_cells), default computed from the mesh.

Returns

canon (n_vertices,), the smallest vertex id of each class of vertices coinciding modulo the periods, and translations (k, dim), one period vector per seam.

zoomy_core.mesh.geometry_xp.cell_face_geometry(mesh)#

FVMMesh geometry of mesh (cell centres with ghost mirrors, volumes, inradii, face normals, volumes, centres), vectorised in numpy.

zoomy_core.mesh.geometry_xp.build_topology(mesh, *, nsm=None, lsq_degree=None, bcs=None, partners=None, periodic_ids=None, systems=(), closure=None)#

Build the static topology and LSQ stencils of mesh once in numpy, freezing the geometric decisions (normal orientation, ghost axes, boundary routing by tag name, periodic partners).

Args

  • nsm: supplies the LSQ degree and the boundary conditions; lsq_degree and bcs override them.

  • partners: input cell of each boundary face for a mesh that cannot pair its own periodic faces (a distributed piece).

  • periodic_ids: seam vertex identification of such a piece.

  • closure: {key: (n_rows, n_bf) kinds} of the row spaces closed at the boundary (degree >= 2); default from nsm and systems.

Returns

MeshTopology.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_core.mesh.geometry_xp.compute_geometry(topo: zoomy_core.mesh.geometry_xp.MeshTopology, X, *, lsq=True)#

All template geometry from the node coordinates X (dim, n_vertices), numpy or jax.numpy as X decides; gather-only and differentiable in X.

Args

  • lsq: also compute lsq_gradQ and the closure tables lsq_closure.

Returns

dict with the FVMMesh/LSQMesh fields (cell centres with ghosts, volumes, inradii, face normals, volumes, centres), boundary distances, interior face vectors, TPFA coefficients and, with lsq, the LSQ operators.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_core.mesh.geometry_xp.lsq_closure_derivatives(topo: zoomy_core.mesh.geometry_xp.MeshTopology, table, U, U_ghost, classes)#

Boundary-closure LSQ derivatives for the rows of U that have a closure class, at the closure cells.

Args

  • U_ghost: ghost values at the boundary-face virtual points.

  • table: class tables geom["lsq_closure"].

  • classes: closure class per row of U (-1: none).

Returns

(rows, D) with D (len(rows), n_cc, n_mon) scaled derivatives, or ([], None) without closure.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_core.mesh.geometry_xp.lsq_derivatives(topo: zoomy_core.mesh.geometry_xp.MeshTopology, geom, U, U_ghost, classes=None)#

Batched LSQ derivatives of the fields U (n_v, n_cells) using ghost values at the boundary-face virtual points, rows with a closure class taking the constrained fit.

Args

  • U_ghost: (n_v, n_bf) ghost values; None: the cell value (extrapolation).

  • classes: closure class per row of U (-1: none).

Returns

(n_v, n_cells, n_mon) derivatives scaled by lsq_scale_factors.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_core.mesh.geometry_xp.lsq_gradient(topo: zoomy_core.mesh.geometry_xp.MeshTopology, geom, U, U_ghost, classes=None)#

First derivatives (n_v, dim, n_cells) from lsq_derivatives.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986