zoomy_core.mesh.lsq_mesh

zoomy_core.mesh.lsq_mesh#

LSQMesh: FVMMesh with cached least-squares derivative stencils, the mesh every backend differentiates on.

Module Contents#

Classes#

LSQMesh

FVMMesh plus precomputed LSQ derivative operators.

API#

class zoomy_core.mesh.lsq_mesh.LSQMesh(**kwargs)#

Bases: zoomy_core.mesh.fvm_mesh.FVMMesh

FVMMesh plus precomputed LSQ derivative operators.

Initialization

Create the mesh from its topology arrays and normalise boundary faces so face_cells[0] is the inner cell.

property lsq_gradQ#

Per-cell LSQ pseudo-inverse matrices.

property lsq_neighbors#

Per-cell neighbour indices of the LSQ stencil.

property lsq_boundary_face_neighbors#

Per-cell boundary-face indices of the LSQ stencil (-1 pads).

property lsq_monomial_multi_index#

Multi-indices of the LSQ monomial basis.

property lsq_scale_factors#

Factorial scale factors turning monomial coefficients into derivatives.

property face_neighbors#

Per-face flux-reconstruction stencil.

compute_derivatives(u: numpy.ndarray, degree: int = 1, derivatives_multi_index=None, *, u_boundary_face) → numpy.ndarray#

Batched LSQ derivatives of u over all cells using the cached stencil.

Args

  • u_boundary_face: (n_boundary_faces,) face values from the BC kernel, or 'extrapolation' for Neumann-zero.

Returns

(n_cells, n_derivatives) array in the order of derivatives_multi_index.

References

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

derivative_operator(multi_index) → scipy.sparse.csr_matrix#

Sparse (n_inner_cells, n_inner_cells) matrix D with D @ u equal to the LSQ derivative d^multi_index u. Used to assemble implicit systems (e.g. the Chorin pressure matrix) where the field is unknown.

Args

  • multi_index: derivative order per axis, e.g. (2,) for d_xx in 1D.

Returns

CSR matrix; raises ValueError if multi_index is not in the mesh’s monomial set.

References

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

classmethod from_fvm(fvm: zoomy_core.mesh.fvm_mesh.FVMMesh) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Build an LSQMesh from an FVMMesh with the degree-1 stencil; use ensure_lsq_mesh to size the degree from the model.

Args

  • fvm: source mesh with precomputed geometry.

classmethod from_msh(filepath: str) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Load a gmsh .msh file as an LSQMesh.

classmethod from_hdf5(filepath: str) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Load an HDF5 mesh as an LSQMesh.

classmethod create_1d(domain: tuple, n_inner_cells: int) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Structured 1D LSQMesh on domain with n_inner_cells cells.

classmethod create_2d(domain: tuple, nx: int, ny: int) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Structured 2D LSQMesh on domain with nx x ny cells.

classmethod create_3d(domain: tuple, nx: int, ny: int, nz: int) → zoomy_core.mesh.lsq_mesh.LSQMesh#

Structured 3D LSQMesh on domain with nx x ny x nz cells.