zoomy_core.mesh.lsq_mesh module#
LSQMesh — FVMMesh with precomputed least-squares reconstruction stencils.
This is the highest-fidelity mesh class: it caches the LSQ derivative
operators so that compute_derivatives is a single matrix–vector product
per cell instead of building the stencil on every call.
- class zoomy_core.mesh.lsq_mesh.LSQMesh(**kwargs)#
Bases:
FVMMeshFVMMesh + precomputed LSQ derivative operators.
- property lsq_gradQ#
- property lsq_neighbors#
- property lsq_boundary_face_neighbors#
- property lsq_monomial_multi_index#
- property lsq_scale_factors#
- property face_neighbors#
- compute_derivatives(u, degree=1, derivatives_multi_index=None, *, u_boundary_face)#
Compute derivatives using precomputed LSQ stencil.
- Parameters:
u_boundary_face (ndarray |
'extrapolation') – Required. Either(n_boundary_faces,)array of face values (from a prescribed BC kernel), or the string'extrapolation'for Neumann-zero / face = inner-cell. Seezoomy_core.mesh.lsq_reconstruction.compute_derivatives()for the rationale: silent extrapolation was deprecated because it masks Dirichlet BCs as Neumann-zero.u (ndarray) –
degree (int) –
- Return type:
ndarray
- derivative_operator(multi_index)#
Sparse-matrix realisation of the LSQ derivative stencil.
Returns a
(n_inner_cells, n_inner_cells)sparse matrixDsuch thatD @ uequals the cell-wise estimate of the derivative∂^multi_index u— the same quantitycompute_derivatives()produces for thatmulti_index, but as an explicit linear operator.compute_derivativesapplies the stencil to a known field;derivative_operatorexposes the stencil itself, for assembling implicit / elliptic systems where the field is the unknown (e.g. the Chorin pressure-projectionA·P = rhs, where∂_xx Pmust enter the matrix, not be evaluated).Per cell
ithe stencil isderiv[i] = Σ_j w_j·(u[nbr_j] − u[i])withw_j = sf[idx]·A_loc[j, idx]— soD[i, nbr_j] += w_jandD[i, i] -= w_j.- Parameters:
multi_index (tuple[int]) – Spatial-derivative orders per axis, e.g.
(1,)for∂_xor(2,)for∂_xxin 1D — the same convention ascompute_derivatives()and theaux_registrymulti_indexfield.- Raises:
ValueError – If
multi_indexis not in the mesh’s monomial set — i.e. the mesh was built with too low anlsq_degree.- Return type:
csr_matrix
- classmethod from_fvm(fvm)#
Build an LSQMesh shell from an FVMMesh, populating the LSQ stencil at degree 1 (the minimum that supports any derivative reconstruction).
The LSQ polynomial degree is not a hand-adjustable knob here — use
zoomy_core.mesh.ensure_lsq_mesh(mesh, model)()for any solver setup, which sizes the stencil from the model’s NumericalSystemModel. This factory exists for low-level mesh construction; the degree is set by the model in the higher layers.
- classmethod from_msh(filepath)#
Load .msh and build FVMMesh with precomputed geometry.
- Parameters:
filepath (str) –
- Return type:
- classmethod from_hdf5(filepath)#
Load BaseMesh from H5 and compute geometry.
- Parameters:
filepath (str) –
- Return type:
- classmethod create_1d(domain, n_inner_cells)#
Build a uniform 1D interval mesh.
- Parameters:
domain (tuple) –
n_inner_cells (int) –
- Return type:
- classmethod create_2d(domain, nx, ny)#
Build a uniform 2D quad mesh.
- Parameters:
domain ((x_min, x_max, y_min, y_max)) –
nx (number of inner cells in x and y directions) –
ny (number of inner cells in x and y directions) –
- Return type:
- classmethod create_3d(domain, nx, ny, nz)#
Build a uniform 3D hexahedral mesh.
- Parameters:
domain ((x_min, x_max, y_min, y_max, z_min, z_max)) –
nx (number of inner cells in each direction) –
ny (number of inner cells in each direction) –
nz (number of inner cells in each direction) –
- Return type:
- name = 'LSQMesh'#