zoomy_core.mesh.base_mesh module#
BaseMesh — topology-only mesh loaded from .msh via meshio (no PETSc).
All geometric quantities (volumes, normals, centers, …) are computed on the
fly from the stored topology. Derived classes (FVMMesh, LSQMesh, …)
cache selected quantities for performance.
- class zoomy_core.mesh.base_mesh.BaseMesh(*, boundary_conditions_sorted_names, boundary_conditions_sorted_physical_tags, boundary_face_cells, boundary_face_face_indices, boundary_face_function_numbers, boundary_face_ghosts, boundary_face_physical_tags, cell_faces, cell_neighbors, cell_vertices, dimension, face_cells, n_boundary_faces, n_cells, n_faces, n_faces_per_cell, n_inner_cells, n_vertices, type, vertex_coordinates, z_ordering, name)#
Bases:
ParameterizedTopology-only mesh. Geometry computed on the fly.
- dimension = 2#
- type = 'triangle'#
- n_cells = 0#
- n_inner_cells = 0#
- n_faces = 0#
- n_vertices = 0#
- n_boundary_faces = 0#
- n_faces_per_cell = 0#
- vertex_coordinates = array([], shape=(0, 0), dtype=float64)#
- cell_vertices = array([], shape=(0, 0), dtype=int64)#
- cell_faces = array([], shape=(0, 0), dtype=int64)#
- face_cells = array([], shape=(0, 0), dtype=int64)#
- cell_neighbors = array([], shape=(0, 0), dtype=int64)#
- boundary_face_cells = array([], dtype=int64)#
- boundary_face_ghosts = array([], dtype=int64)#
- boundary_face_function_numbers = array([], dtype=int64)#
- boundary_face_physical_tags = array([], dtype=int64)#
- boundary_face_face_indices = array([], dtype=int64)#
- boundary_conditions_sorted_physical_tags = array([], dtype=int64)#
- boundary_conditions_sorted_names = []#
- z_ordering = array([-1])#
- cell_centers_computed()#
Compute cell centers from vertex coordinates. Shape (3, n_cells).
- Return type:
ndarray
- cell_volumes_computed()#
Compute cell volumes. Shape (n_cells,).
- Return type:
ndarray
- cell_inradius_computed()#
Compute cell inradius (min distance from center to face plane).
Uses the same projection-based approach as PETSc’s
computeCellGeometryFVMfor consistency.- Return type:
ndarray
- face_normals_computed()#
Compute face normals. Shape (3, n_faces).
For 1D meshes all normals point in the +x direction (convention).
- Return type:
ndarray
- face_volumes_computed()#
Compute face areas/lengths. Shape (n_faces,).
For 1D meshes, face ‘volumes’ are 1.0 (point has no area).
- Return type:
ndarray
- face_centers_computed()#
Compute face centers. Shape (n_faces, 3).
- Return type:
ndarray
- face_subvolumes_computed()#
Compute face subvolumes. Shape (n_faces, 2).
- Return type:
ndarray
- compute_derivatives(u, degree=1, derivatives_multi_index=None)#
Compute derivatives using on-the-fly LSQ reconstruction.
- Parameters:
u (ndarray) –
degree (int) –
- Return type:
ndarray
- classmethod from_msh(filepath)#
Load a .msh file via meshio and build topology (no PETSc).
- 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:
- write_to_hdf5(filepath)#
Serialize topology-only fields to HDF5.
- Parameters:
filepath (str) –
- classmethod from_hdf5(filepath)#
Load a BaseMesh from HDF5.
- Parameters:
filepath (str) –
- Return type:
- classmethod extrude_2d(mesh_2d, n_layers, height)#
Extrude a 2D mesh into 3D by stacking layers in the z-direction.
- Parameters:
mesh_2d (BaseMesh) – A 2D mesh (type
"quad"or"triangle").n_layers (int) – Number of layers in the z-direction.
height (float or array-like) – Total extrusion height (uniform layers), or a list/array of
n_layersindividual layer heights.
- Returns:
A 3D mesh of type
"hexahedron"(from quads) or"wface"(from triangles).- Return type:
- name = 'BaseMesh'#
- resolve_periodic_bcs(bcs)#
Patch boundary_face_cells for periodic boundary conditions.