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#
Monomial multi-indices up to total |
|
Factorial scale factors that turn monomial coefficients into derivatives. |
|
Positions of the requested derivative multi-indices in the monomial list, as an |
|
Maximum total degree among the monomial multi-indices. |
|
Number of monomials (constant included) of a polynomial of |
|
Vandermonde matrix of the monomials |
|
Grow a neighbour set by one ring, skipping sentinel indices |
|
Inverse of |
|
Inner cells sharing at least one vertex with cell |
|
Gaussian weights |
|
Build the per-cell LSQ gradient operators over the vertex-1-ring stencil, with boundary faces
as virtual ghost samples at |
|
Cell-wise derivative estimates of |
|
Map physical-group names of a |
|
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
degreeindimdimensions, 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
degreeindimdimensions.
- zoomy_core.mesh.lsq_reconstruction.build_vandermonde(cell_diffs, mon_indices)#
Vandermonde matrix of the monomials
mon_indicesat the offsetscell_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(excludingic), sorted.
- zoomy_core.mesh.lsq_reconstruction.compute_gaussian_weights(dX, sigma=1.0)#
Gaussian weights
exp(-(|dX|/sigma)^2)of the offsetsdX.
- 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 whencell_boundary_facesis 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_globis(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
ufrom 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
.mshfile 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.