Skip to content
Get started

eqiora.meshing

← Python API index

Plan and generate meshes from geometry.

View source

Continue with geometry from the geometry example:

python
from eqiora import meshing
mesh_plan = meshing.resolve(geometry, meshing.CartesianMesher(cells=(8, 4)))
mesh = meshing.generate(mesh_plan)
print(mesh.dimension, mesh.cell_count, mesh.vertex_count)
print(mesh.coordinates.shape)

The rectangle becomes 32 cells with 45 vertices in two dimensions. coordinates contains the vertex positions. Use this same mesh when resolving a spatial model bound to this geometry; see modeling.

Mesh a rectangle with a structured grid of affine triangles.

Each grid cell is split along its lower-left to upper-right diagonal. You choose only the (positive) number of subdivisions in each direction.

python
@final
class AffineTriangleMesher:
def __new__(cls, *, cells: tuple[int, int]) -> Self: ...
@property
def cells(self) -> tuple[int, int]: ...
@property
def diagonal(self) -> str: ...
def __eq__(self, other: object, /) -> bool: ...
def __repr__(self) -> str: ...

Mesh a Cartesian domain with a structured grid.

python
@final
class CartesianMesher:
def __new__(cls, *, cells: tuple[int] | tuple[int, int] | tuple[int, int, int]) -> Self: ...
@property
def cells(self) -> tuple[int] | tuple[int, int] | tuple[int, int, int]: ...
def __eq__(self, other: object, /) -> bool: ...
def __repr__(self) -> str: ...

Generate the mesh with Gmsh (requires the gmsh extra).

python
@final
class GmshMesher:
def __new__(cls, *, maximum_boundary_error: float=..., maximum_target_size: float | None=..., minimum_mean_ratio: float=..., maximum_boundary_facets: int=...) -> Self: ...
@property
def maximum_boundary_error(self) -> float: ...
@property
def maximum_target_size(self) -> float | None: ...
@property
def minimum_mean_ratio(self) -> float: ...
@property
def maximum_boundary_facets(self) -> int: ...
def __eq__(self, other: object, /) -> bool: ...
def __repr__(self) -> str: ...

Immutable mesh, linked to the geometry and plan that produced it.

python
@final
class Mesh:
@staticmethod
def coordinate_factors(model: Model, domain: DomainRef, cells_per_factor: list[int]) -> Mesh: ...
@staticmethod
def from_bytes(data: bytes) -> Mesh: ...
def to_bytes(self) -> bytes: ...
def refine(self, marked_cells: Iterable[int], /, *, maximum_cells: int) -> Mesh: ...
@property
def source_digest(self) -> str: ...
@property
def realized_geometry_digest(self) -> str | None: ...
@property
def digest(self) -> str: ...
@property
def correspondence_digest(self) -> str | None: ...
@property
def production_lineage_bytes(self) -> bytes: ...
@property
def production_lineage_digest(self) -> str: ...
@property
def canonical_bytes(self) -> bytes: ...
@property
def dimension(self) -> int: ...
@property
def vertex_count(self) -> int: ...
@property
def cell_count(self) -> int: ...
@property
def coordinates(self) -> npt.NDArray[np.float64]: ...
@property
def cells(self) -> npt.NDArray[np.uint32]: ...
def entity_vertices(self, entity: tuple[int, int]) -> tuple[int, ...]: ...
@property
def minimum_mean_ratio(self) -> float: ...
@property
def selection_names(self) -> tuple[str, ...]: ...
def selection_entity_count(self, name: str | GeometrySelection) -> int: ...
def selection_entities(self, name: str | GeometrySelection) -> tuple[tuple[int, int], ...]: ...
def __repr__(self) -> str: ...

Fully resolved meshing plan for one geometry.

python
@final
class MeshPlan:
@property
def source_digest(self) -> str: ...
@property
def provider(self) -> AffineTriangleMesher | CartesianMesher | GmshMesher: ...
def __repr__(self) -> str: ...

Run a resolved meshing plan and return the mesh.

python
def generate(plan: MeshPlan, /) -> Mesh: ...

Resolve a meshing request into a plan for the given geometry.

python
def resolve(geometry: Geometry, provider: AffineTriangleMesher | CartesianMesher | GmshMesher, /) -> MeshPlan: ...