Skip to content

puncturedfem.PlanarMesh

Planar mesh geometry and topology.

The edges of the mesh are permitted to be curved, and mesh cells are permitted to be multiply connected.

edges meet at an interior angle strictly between 0 and 2 pi (no slits or cusps). Hanging nodes (i.e. an interior angle of pi) are permitted. Looped edges (edges with identical endpoints) are permitted under the same restrictions.

The mesh geometry is determined by the parameterization of the edges. The mesh topology is automatically determined by observing that each Edge is shared by the boundary of exactly two MeshCells.

Computations on the mesh dictate that the boundary of each MeshCell have an oriented boundary (counterclockwise on the outer boundary, clockwise on the inner boundary). Rather than storing the parameterization of each Edge twice (once for each MeshCell), we record the orientation of each Edge relative to the boundary of each MeshCell.

For instance, if the Edge is oriented counterclockwise to a MeshCell boundary, with that Edge lying on the outer boundary of this MeshCell, then the Edge is said to have positive orientation with respect to that MeshCell. Each Edge object stores the MeshCell index of the MeshCell on either side of the Edge, one positive and one negative. If the Edge is on the boundary of the domain, the "missing" MeshCell is assigned a negative MeshCell index.

Usage

See examples/ex0-mesh-building.ipynb for an example of how to build a mesh.

Attributes:

Name Type Description
num_edges int

Number of edges in the mesh.

num_cells int

Number of MeshCells in the mesh.

num_verts int

Number of Vertices in the mesh.

edges list[Edge]

List of edges in the mesh.

vert_idx_list list[int]

List of vertex indices in the mesh, excluding Vertices of loops.

cell_idx_list list[int]

List of MeshCell indices in the mesh.

Notes

  • The vertex indices are taken to be nonnegative integers. These indices are not necessarily 0, 1, ...., num_verts - 1, but instead are determined by the indices assigned to the endpoints of the edges.
  • The MeshCell indices are taken to be nonnegative integers, except for the case of edges on the boundary of the domain. In this case, the MeshCell index is assigned to be negative. Similar to the vertex indices, the MeshCell indices are not necessarily 0, 1, ...., num_cells - 1, but instead are determined by the indices assigned to the edges in the pos_cell_idx and neg_cell_idx attributes.

__init__(edges, verbose=True)

Initialize a PlanarMesh object.

Parameters:

Name Type Description Default
edges list[Edge]

List of edges in the mesh.

required
verbose bool, optional

If True, print information about the mesh. Default is True.

True

__str__()

Return a string representation of the PlanarMesh object.

add_edge(e)

Add an Edge to the mesh.

Parameters:

Name Type Description Default
e Edge

Edge to add to the mesh.

required

add_edges(edges)

Add a list of edges to the mesh.

Parameters:

Name Type Description Default
edges list[Edge]

List of edges to add to the mesh.

required

edge_is_on_boundary(edge_idx)

Return True if the Edge with index edge_idx is on the boundary.

Parameters:

Name Type Description Default
edge_idx int

Index of the Edge.

required

Returns:

Type Description
bool

True if the Edge is on the boundary, False otherwise.

get_abs_cell_idx(cell_idx)

Return the absolute MeshCell index of cell_idx.

Parameters:

Name Type Description Default
cell_idx int

Index of the MeshCell to return.

required

Returns:

Type Description
int

Absolute index of the MeshCell.

get_cell(cell_idx)

Return the MeshCell with index cell_idx.

Parameters:

Name Type Description Default
cell_idx int

Index of the MeshCell to return.

required

Returns:

Type Description
MeshCell

MeshCell with index cell_idx.

vert_is_on_boundary(vert_idx)

Return True if the vertex with index vert_idx is on the boundary.

Parameters:

Name Type Description Default
vert_idx int

Index of the vertex.

required

Returns:

Type Description
bool

True if the vertex is on the boundary, False otherwise.