padne.mesh

Attributes

Exceptions

MeshingException

Raised when CGAL fails to mesh a polygon due to degenerate geometry.

Classes

Vector

Point

ZeroForm

Element-wise arithmetic shared by the discrete forms.

OneForm

A discrete 1-form defined on the (h)edges of a mesh.

TwoForm

A discrete 2-form defined on the faces of a mesh.

Mesher

This class is responsible for generating a mesh from a Shapely polygon.

Module Contents

padne.mesh.index_type[source]
class padne.mesh.Vector[source]
dx: float[source]
dy: float[source]
dot(other: Vector) → float[source]
class padne.mesh.Point[source]
x: float[source]
y: float[source]
distance(other: Point) → float[source]
to_shapely() → shapely.geometry.Point[source]

Convert this Point to a shapely.geometry.Point.

Returns:

A shapely Point with the same coordinates

padne.mesh.Mesh[source]
padne.mesh.Vertex[source]
padne.mesh.HalfEdge[source]
padne.mesh.Face[source]
class padne.mesh.ZeroForm[source]

Bases: _Form

Element-wise arithmetic shared by the discrete forms.

d() → OneForm[source]

Compute the exterior derivative (gradient) of this 0-form.

For a function f on vertices, the exterior derivative df is a 1-form where: (df)[edge] = f(target_vertex) - f(source_vertex)

Returns:

A OneForm representing the gradient of this function

class padne.mesh.OneForm[source]

Bases: _Form

A discrete 1-form defined on the (h)edges of a mesh.

class padne.mesh.TwoForm[source]

Bases: _Form

A discrete 2-form defined on the faces of a mesh.

padne.mesh.PolyBoundaryDistanceMap[source]
padne.mesh.CGALPolygon[source]
exception padne.mesh.MeshingException[source]

Bases: RuntimeError

Raised when CGAL fails to mesh a polygon due to degenerate geometry.

class padne.mesh.Mesher(config: Mesher | None = None)[source]

This class is responsible for generating a mesh from a Shapely polygon. Works through CGAL.

class Config[source]

Configuration parameters for mesh generation.

minimum_angle: float = 20.0[source]
maximum_size: float = 0.6[source]
variable_density_min_distance: float = 0.5[source]
variable_density_max_distance: float = 3.0[source]
variable_size_maximum_factor: float = 3.0[source]
distance_map_quantization: float = 1.0[source]
RELAXED = None[source]
property is_variable_density: bool[source]

Return True if variable density meshing is enabled.

config[source]
poly_to_mesh(poly: shapely.geometry.Polygon, seed_points: Sequence[Point | shapely.geometry.Point] = ()) → Mesh[source]

Convert a Shapely polygon to a triangular mesh.

Args:

poly: A Shapely polygon, potentially with holes

Returns:

A Mesh object representing the triangulated polygon