zoomy_core.mesh.lsq_reconstruction

zoomy_core.mesh.lsq_reconstruction#

Pure-numpy least-squares reconstruction: monomial bases, Vandermonde matrices, per-cell LSQ stencils and derivatives, used by LSQMesh.

Module Contents#

Functions#

build_monomial_indices

Monomial multi-indices up to total degree in dim dimensions, excluding the constant.

scale_lsq_derivative

Factorial scale factors that turn monomial coefficients into derivatives.

find_derivative_indices

Positions of the requested derivative multi-indices in the monomial list, as an (M,) array (-1 where absent).

get_polynomial_degree

Maximum total degree among the monomial multi-indices.

get_required_monomials_count

Number of monomials (constant included) of a polynomial of degree in dim dimensions.

build_vandermonde

Vandermonde matrix of the monomials mon_indices at the offsets cell_diffs.

expand_neighbors

Grow a neighbour set by one ring, skipping sentinel indices >= n_valid.

build_vertex_to_cells

Inverse of cell_vertices (shape (verts_per_cell, n_cells)): per vertex, the inner cells touching it.

vertex_one_ring

Inner cells sharing at least one vertex with cell ic (excluding ic), sorted.

compute_gaussian_weights

Gaussian weights exp(-(|dX|/sigma)^2) of the offsets dX.

least_squares_reconstruction_local

Build the per-cell LSQ gradient operators over the vertex-1-ring stencil, with boundary faces as virtual ghost samples at 2*(face_center - cell_center). The value placed there must be a ghost value (2*u_face - u_cell).

compute_derivatives

Cell-wise derivative estimates of u from the mesh LSQ stencil.

get_physical_boundary_labels

Map physical-group names of a .msh file to their tags via meshio.

compute_inradius_generic

Inradius of a cell: the shortest normal distance from its centre to any face.

API#

zoomy_core.mesh.lsq_reconstruction.build_monomial_indices(degree: int, dim: int)#

Monomial multi-indices up to total degree in dim dimensions, excluding the constant.

zoomy_core.mesh.lsq_reconstruction.scale_lsq_derivative(mon_indices)#

Factorial scale factors that turn monomial coefficients into derivatives.

zoomy_core.mesh.lsq_reconstruction.find_derivative_indices(full_monomials_arr, requested_derivs_arr)#

Positions of the requested derivative multi-indices in the monomial list, as an (M,) array (-1 where absent).

zoomy_core.mesh.lsq_reconstruction.get_polynomial_degree(mon_indices)#

Maximum total degree among the monomial multi-indices.

zoomy_core.mesh.lsq_reconstruction.get_required_monomials_count(degree, dim)#

Number of monomials (constant included) of a polynomial of degree in dim dimensions.

zoomy_core.mesh.lsq_reconstruction.build_vandermonde(cell_diffs, mon_indices)#

Vandermonde matrix of the monomials mon_indices at the offsets cell_diffs.

zoomy_core.mesh.lsq_reconstruction.expand_neighbors(neighbors_list, initial_neighbors, n_valid=None)#

Grow a neighbour set by one ring, skipping sentinel indices >= n_valid.

zoomy_core.mesh.lsq_reconstruction.build_vertex_to_cells(cell_vertices, n_inner_cells)#

Inverse of cell_vertices (shape (verts_per_cell, n_cells)): per vertex, the inner cells touching it.

zoomy_core.mesh.lsq_reconstruction.vertex_one_ring(ic, cell_vertices, vertex_to_cells, n_inner_cells)#

Inner cells sharing at least one vertex with cell ic (excluding ic), sorted.

zoomy_core.mesh.lsq_reconstruction.compute_gaussian_weights(dX, sigma=1.0)#

Gaussian weights exp(-(|dX|/sigma)^2) of the offsets dX.

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, cell_vertices=None)#

Build the per-cell LSQ gradient operators over the vertex-1-ring stencil, with boundary faces as virtual ghost samples at 2*(face_center - cell_center). The value placed there must be a ghost value (2*u_face - u_cell).

Args

  • neighbors_list: face-neighbour table, used only to top up or replace the vertex ring.

  • boundary_face_centers: (n_boundary_faces, dim); required when cell_boundary_faces is non-empty.

  • cell_boundary_faces: per cell, the boundary faces it touches.

  • cell_vertices: (verts_per_cell, n_cells); without it the stencil is the biased face-neighbour expansion.

Returns

(A_glob, neighbors_array, boundary_face_neighbors_array, mon_indices); A_glob is (n_cells, max_neighbors + max_bdy_per_cell, n_monomials), boundary slots are padded with -1.

References

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

zoomy_core.mesh.lsq_reconstruction.compute_derivatives(u, mesh, derivatives_multi_index=None, *, u_boundary_face)#

Cell-wise derivative estimates of u from the mesh LSQ stencil.

Args

  • u: (n_cells,) values at cell centres (inner plus ghost slots).

  • u_boundary_face: required; (n_boundary_faces,) face values for prescribed BCs, or 'extrapolation' for Neumann-zero.

Returns

(n_cells, len(derivatives_multi_index)) array.

References

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

zoomy_core.mesh.lsq_reconstruction.get_physical_boundary_labels(filepath)#

Map physical-group names of a .msh file to their tags via meshio.

zoomy_core.mesh.lsq_reconstruction.compute_inradius_generic(cell_center, face_centers, face_normals)#

Inradius of a cell: the shortest normal distance from its centre to any face.