Skip to content

puncturedfem.MeshCell

Represent a mesh cell, which may be multiply connected.

Contains: - parameterization of the boundary - methods to evaluate and integrate functions on the boundary - interior points - relative position of the cell in the mesh (topological info)

Attributes:

Name Type Description
idx int

The cell id as it appears in the mesh.

components list[ClosedContour]

The boundary components of the cell.

num_holes int

The number of holes in the cell.

num_edges int

The number of edges on the cell boundary.

num_pts int

The number of sampled points on the cell boundary.

component_start_idx list[int]

The index of the first sampled point on each boundary component.

closest_vert_idx np.ndarray

The index of the closest vertex in the mesh to each sampled point.

edge_orients list[int]

The orientation of each Edge in the cell (+/- 1).

int_mesh_size tuple[int, int]

__init__(idx, edges, int_mesh_size=(33, 33), rtol=0.05, atol=0.05)

Initialize a MeshCell object.

Parameters:

Name Type Description Default
idx int

The cell id.

required
edges list[Edge]

The edges in the cell.

required
int_mesh_size tuple[int, int], optional

The size of the interior mesh, by default (101, 101)

(33, 33)
rtol float, optional

The relative tolerance for interior points, by default 0.02

0.05
atol float, optional

The absolute tolerance for interior points, by default 0.02

0.05

deparameterize()

Remove parameterization of each edge.

dot_with_normal(comp1, comp2)

Return the dot product (comp1, comp2) * unit_normal.

Parameters:

Name Type Description Default
comp1 np.ndarray

The first component of the vector.

required
comp2 np.ndarray

The second component of the vector.

required

Returns:

Type Description
np.ndarray

The dot product (comp1, comp2) * unit_normal.

dot_with_tangent(comp1, comp2)

Return the dot product (comp1, comp2) * unit_tangent.

Parameters:

Name Type Description Default
comp1 np.ndarray

The first component of the vector.

required
comp2 np.ndarray

The second component of the vector.

required

Returns:

Type Description
np.ndarray

The dot product (comp1, comp2) * unit_tangent.

evaluate_function_on_boundary(fun)

Return fun(x) for each sampled point on the cell boundary.

Parameters:

Name Type Description Default
fun Func_R2_R

The function to evaluate.

required

Returns:

Type Description
np.ndarray

The values of fun(x) at each sampled point on the boundary.

find_boundary_components(edges)

Find the boundary components of the cell.

Parameters:

Name Type Description Default
edges list[Edge]

The edges in the cell.

required

Notes

The following attributes are set: - components: the boundary components of the cell - num_holes: the number of holes in the cell

find_edge_orientations(edges)

Find the orientation of each Edge in the cell.

The orientation is +1 if the Edge starts at the cell, -1 if it ends at the cell, and 0 if the Edge is not incident to the cell.

Parameters:

Name Type Description Default
edges list[Edge]

The edges in the cell.

required

find_num_edges()

Find the number of edges in the cell.

The following attributes are set: - num_edges: the number of edges in the cell

generate_interior_points()

Generate interior points for the cell.

The following attributes are set: - int_x1: the x-coordinates of the interior points - int_x2: the y-coordinates of the interior points - is_inside: a boolean array indicating whether each point is in the interior

get_boundary_points()

Return the boundary points.

Returns:

Name Type Description
x1 np.ndarray

The x-coordinates of the boundary points.

x2 np.ndarray

The y-coordinates of the boundary points.

get_bounding_box()

Return the bounding box of the cell.

Returns:

Name Type Description
xmin float

The minimum x-coordinate of the cell.

xmax float

The maximum x-coordinate of the cell.

ymin float

The minimum y-coordinate of the cell.

ymax float

The maximum y-coordinate of the cell.

get_distance_to_boundary(x, y)

Return the distance to the boundary at each point.

Parameters:

Name Type Description Default
x float

The x-coordinate of the point.

required
y float

The y-coordinate of the point.

required

Returns:

Type Description
float

The distance to the boundary at the point.

get_dx_norm()

Return the norm of the first derivative.

Returns:

Type Description
np.ndarray

The norm of the first derivative.

get_edge_endpoint_incidence(edges)

Get the incidence array for the edges in the cell.

Return incidence array: for each Edge i, point to an Edge j whose starting point is the terminal point of Edge i Edge i vertex Edge j --->--->--->--- o --->--->--->---

get_edges()

Return a list of all edges in the cell.

Returns:

Type Description
list[Edge]

A list of all edges in the cell.

get_unit_normal()

Return the components of the unit normal vector.

Returns:

Type Description
tuple[np.ndarray, np.ndarray]

The components of the unit normal vector.

get_unit_tangent()

Return the components of the unit tangent vector.

Returns:

Type Description
tuple[np.ndarray, np.ndarray]

The components of the unit tangent vector.

integrate_over_boundary(vals)

Integrate vals over the boundary.

Parameters:

Name Type Description Default
vals np.ndarray

The values of f at each sampled point on the boundary.

required

Returns:

Type Description
float

The integral of f over the boundary.

integrate_over_boundary_preweighted(vals_dx_norm)

Integrate vals over the boundary without multiplying by dx_norm.

Parameters:

Name Type Description Default
vals_dx_norm np.ndarray

The values of f * dx_norm at each sampled point on the boundary.

required

Returns:

Type Description
float

The integral of f over the boundary.

is_in_interior(x, y)

Return a boolean array indicating whether each point is in the interior.

Parameters:

Name Type Description Default
x np.ndarray

The x-coordinates of the points.

required
y np.ndarray

The y-coordinates of the points, same shape as x.

required

Returns:

Type Description
np.ndarray

A boolean array indicating whether each point is in the interior, same shape as x and y.

is_parameterized()

Return whether all edges of the cell are parameterized.

Returns:

Type Description
bool

True if the cell is parameterized, False otherwise.

multiply_by_dx_norm(vals)

Return vals * dx_norm for each sampled point on the cell boundary.

Parameters:

Name Type Description Default
vals np.ndarray

The values of f at each sampled point on the boundary.

required

Returns:

Type Description
np.ndarray

The values of f * dx_norm at each sampled point on the boundary.

parameterize(quad_dict, compute_interior_points=True)

Sample the boundary on each edge.

Parameters:

Name Type Description Default
quad_dict QuadDict

The quadrature dictionary, which specifies how the edges are to be sampled.

required
compute_interior_points bool, optional

Whether to generate the interior points and triangulation. True by default.

True

set_idx(idx)

Set the global cell index.

Parameters:

Name Type Description Default
idx int

The cell index.

required

set_interior_mesh_size(rows, cols)

Set the size of the mesh of interior points.

Parameters:

Name Type Description Default
rows int

The number of rows in the mesh.

required
cols int

The number of columns in the mesh.

required

set_interior_point_tolerance(rtol=0.02, atol=0.02)

Set the minimum distance to the boundary for sampled interior points.

Parameters:

Name Type Description Default
rtol float, optional

The relative tolerance, by default 0.02

0.02
atol float, optional

The absolute tolerance, by default 0.02

0.02