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#
Static integer topology plus frozen geometric decisions (normal signs, ghost ranges, LSQ stencils and plan, TPFA masks, boundary routing) of a mesh. |
Functions#
Identify the vertices of periodic seams; returns |
|
FVMMesh geometry of |
|
Build the static topology and LSQ stencils of |
|
All template geometry from the node coordinates |
|
Boundary-closure LSQ derivatives for the rows of |
|
Batched LSQ derivatives of the fields |
|
First 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), ...]ofbc_branch.
- zoomy_core.mesh.geometry_xp.periodic_vertices(mesh, bcs, centers=None)#
Identify the vertices of periodic seams; returns
(canon, translations)or None withoutPeriodicBCs.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, andtranslations(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
meshonce 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_degreeandbcsoverride 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 fromnsmandsystems.
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 asXdecides; gather-only and differentiable inX.Args
lsq: also computelsq_gradQand the closure tableslsq_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
Uthat have a closure class, at the closure cells.Args
U_ghost: ghost values at the boundary-face virtual points.table: class tablesgeom["lsq_closure"].classes: closure class per row ofU(-1: none).
Returns
(rows, D)withD(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 ofU(-1: none).
Returns
(n_v, n_cells, n_mon)derivatives scaled bylsq_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)fromlsq_derivatives.References
Mavriplis 2003, https://doi.org/10.2514/6.2003-3986