zoomy_core.mesh.lsq_reconstruction module#
Least-squares polynomial reconstruction for FVM derivative estimation.
Pure-numpy utilities: monomial construction, Vandermonde matrices, weighted least-squares stencils, and cell-wise derivative computation.
- zoomy_core.mesh.lsq_reconstruction.build_monomial_indices(degree, dim)#
Build monomial multi-indices up to total degree (excluding constant).
- Parameters:
degree (int) –
dim (int) –
- zoomy_core.mesh.lsq_reconstruction.scale_lsq_derivative(mon_indices)#
Factorial scaling so LSQ coefficients equal derivatives.
- zoomy_core.mesh.lsq_reconstruction.find_derivative_indices(full_monomials_arr, requested_derivs_arr)#
Map requested derivative multi-indices to positions in monomial list.
Returns shape (M,) array; -1 where a requested derivative is not found.
- zoomy_core.mesh.lsq_reconstruction.get_polynomial_degree(mon_indices)#
- zoomy_core.mesh.lsq_reconstruction.get_required_monomials_count(degree, dim)#
- zoomy_core.mesh.lsq_reconstruction.build_vandermonde(cell_diffs, mon_indices)#
- zoomy_core.mesh.lsq_reconstruction.expand_neighbors(neighbors_list, initial_neighbors, n_valid=None)#
Expand neighbor set by one ring. Skips sentinel/invalid indices.
- zoomy_core.mesh.lsq_reconstruction.compute_gaussian_weights(dX, sigma=1.0)#
- zoomy_core.mesh.lsq_reconstruction.least_squares_reconstruction_local(n_cells, dim, neighbors_list, cell_centers, lsq_degree, n_inner_cells=None, boundary_face_centers=None, cell_boundary_faces=None)#
Build per-cell LSQ gradient operators.
Interior cells (index <
n_inner_cells) are used as neighbors. Boundary cells additionally include the boundary-face center(s) they touch as virtual sampling positions — the LSQ row at a boundary face contributes the BC-prescribed face value, so the cell-centered derivative is boundary-aware. This is the ghost-cell-free analogue of “apply boundary_operator then take the gradient”: the boundary face is a first-class entity in the mesh, sampled at distance|face_center − cell_center|(= dx/2 in 1D, vs. dx for the legacy ghost-cell convention), so the boundary-face stencil is also tighter and more accurate.- Parameters:
boundary_face_centers (ndarray, shape
(n_boundary_faces, dim), optional) – Face centers of all boundary faces. Required whencell_boundary_facesprovides any non-empty entry.cell_boundary_faces (sequence, length
n_cells, optional) – For each cell, the list of boundary-face indices touching that cell. Empty list for interior cells. When omitted, the stencil reduces to the legacy interior-only form.
- Returns:
A_glob (
(n_cells, max_neighbors + max_bdy_per_cell, n_monomials))neighbors_array (
(n_cells, max_neighbors)int)boundary_face_neighbors_array (
(n_cells, max_bdy_per_cell)int) – Boundary-face indices used by each cell’s stencil, padded with-1in unused slots. Empty array (shape(n_cells, 0)) when no boundary-face augmentation was requested.mon_indices (list of tuples)
- zoomy_core.mesh.lsq_reconstruction.compute_derivatives(u, mesh, derivatives_multi_index=None, *, u_boundary_face)#
Cell-wise derivative estimates using the mesh LSQ stencil.
- Parameters:
u (ndarray, shape
(n_cells,)) – Field values at cell centers (interior + sentinel/ghost slots).u_boundary_face (ndarray |
'extrapolation') – Required. Either an(n_boundary_faces,)array of values at boundary face centers (typically from the SystemModel’sboundary_conditionsruntime kernel applied to the inner- cell state) — for prescribed-value BCs (Dirichlet, Lambda) — or the literal string'extrapolation'to request Neumann-zero / face = inner-cell-value treatment (the Chorin pressure projection’s natural P BC, and the safe fallback for intrinsically-Neumann fields like static bathymetry).
- zoomy_core.mesh.lsq_reconstruction.get_physical_boundary_labels(filepath)#
Extract physical boundary labels from a .msh file via meshio.
- zoomy_core.mesh.lsq_reconstruction.compute_inradius_generic(cell_center, face_centers, face_normals)#
Inradius of a cell: shortest normal distance from center to any face.