Skip to content

puncturedfem.ClosedContour

List of edges forming a closed contour.

Assumed to be simple with edges listed successively.

Attributes:

Name Type Description
edges list[Edge]

List of edges forming the contour.

num_edges int

Number of edges in the contour.

edge_orient list[int]

List of orientations of the edges, where +1 indicates the edge is oriented in the same direction as the contour and -1 indicates the edge is oriented in the opposite direction.

interior_point Vert

A point in the interior of the contour.

num_pts int

Number of sampled points on the contour.

vert_idx list[int]

Index of the starting point of each edge.

local_vert_idx list[int]

Index of the starting point of each edge, relative to the edge.

closest_vert_idx np.ndarray

Index of the closest vertex for each sampled point on the contour.

__init__(cell_id, edges=None, edge_orients=None)

Initialize a ClosedContour object.

Parameters:

Name Type Description Default
cell_id int

The MeshCell id of the contour. (This is the MeshCell id of the MeshCell that the contour is part of the boundary of.)

required
edges Optional[list[Edge]]

List of edges forming the contour.

None
edge_orients Optional[list[int]]

List of orientations of the edges, where +1 indicates the edge is oriented in the same direction as the contour and -1 indicates the edge is oriented in the opposite direction.

None

add_edge(e, edge_orient)

Add an edge to the contour.

Parameters:

Name Type Description Default
e Edge

The edge to add to the contour.

required
edge_orient int

Orientation of the edge, where +1 indicates the edge is oriented in the same direction as the contour and -1 indicates the edge is oriented in the opposite direction.

required

add_edges(edges, edge_orients)

Add a list of edges to contour.

Parameters:

Name Type Description Default
edges list[Edge]

List of edges to add to the contour.

required
edge_orients list[int]

List of orientations of the edges, where +1 indicates the edge is oriented in the same direction as the contour and -1 indicates the edge is oriented in the opposite direction.

required

Raises:

Type Description
ValueError

If the number of edges and orientations do not match.

deparameterize()

Delete the sampled points of the edges comprising the contour.

dot_with_normal(comp1, comp2)

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

Parameters:

Name Type Description Default
comp1 np.ndarray

First component of the vector to dot with the normal.

required
comp2 np.ndarray

Second component of the vector to dot with the normal.

required

Returns:

Type Description
numpy.ndarray

Array of dot products (comp1, comp2) * unit_normal for each sampled point on the contour, having the same length as the number of sampled points on the contour.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

dot_with_tangent(comp1, comp2)

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

Parameters:

Name Type Description Default
comp1 np.ndarray

First component of the vector to dot with the tangent.

required
comp2 np.ndarray

Second component of the vector to dot with the tangent.

required

Returns:

Type Description
numpy.ndarray

Array of dot products (comp1, comp2) * unit_tangent for each sampled point on the contour, having the same length as the number of sampled points on the contour.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

evaluate_function_on_contour(fun)

Return fun(x) for each sampled point on contour.

Parameters:

Name Type Description Default
fun Func_R2_R

Function of two real variables returning a real value.

required

Returns:

Type Description
numpy.ndarray

Array of function values at each sampled point on the contour, having the same length as the number of sampled points on the contour.

find_closest_local_vertex_index()

Determine the index of the nearest index.

Specifically determine the sampled point index of the starting point of the closest vertex to each sampled point on the contour. Stores the result in the attribute closest_vert_idx.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

find_interior_point()

Find a single point in the interior of the contour.

Stores the result in the attribute interior_point.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

InteriorPointError

If an interior point cannot be found.

find_local_vert_idx()

Determine the sampled point index of the starting point of each edge.

Stores the result in the attribute vert_idx.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

find_num_pts()

Determine the total number of sampled points on the contour.

This is the sum of the number of sampled points on each edge, neglecting the last point on each edge (since it is repeated on the next edge). Stores the result in the attribute num_pts.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

get_distance_to_boundary(x, y)

Get the minimum distance to sampled points on the contour.

Parameters:

Name Type Description Default
x float

x-coordinate of the point.

required
y float

y-coordinate of the point.

required

Returns:

Type Description
float

The minimum distance to the contour.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

get_sampled_points()

Return the x1 and x2 coordinates of the boundary points.

Returns:

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

Tuple containing the x1 and x2 coordinates of the boundary points.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

integrate_over_closed_contour(vals)

Quadrature to approximate the integral of vals over the contour.

Parameters:

Name Type Description Default
vals np.ndarray

Array of values to integrate over the contour, having the same length as the number of sampled points on the contour.

required

Returns:

Type Description
float

Approximation of the integral of vals over the contour.

integrate_over_closed_contour_preweighted(vals_dx_norm)

Quadrature to approximate the integral of vals over the contour.

Assumes vals_dx_norm is already multiplied by the norm of the derivative of the curve parameterization.

Parameters:

Name Type Description Default
vals_dx_norm np.ndarray

Array of values to integrate over the contour, already multiplied by the norm of the derivative of the curve parameterization.

required

Returns:

Type Description
float

Approximation of the integral of val over the contour.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

SizeMismatchError

If vals_dx_norm is not a vector or is not the same length as the number of sampled points on the contour.

is_in_interior_contour(x, y)

Return which points lie in the interior of the contour.

Return a boolean array indicating whether each point (x[i], y[i]) is inside the contour.

Parameters:

Name Type Description Default
x np.ndarray

x-coordinates of the points.

required
y np.ndarray

y-coordinates of the points.

required

Returns:

Type Description
numpy.ndarray

Boolean array indicating whether each point is inside the contour, having the same shape as x and y.

Raises:

Type Description
SizeMismatchError

If x and y do not have the same shape.

is_parameterized()

Check if the edges of the contour have been sampled.

Returns:

Type Description
bool

True if all edges are parameterized, False otherwise.

multiply_by_dx_norm(vals)

Return vals multiplied by the norm of the derivative of the curve.

Returns f multiplied against the norm of the derivative of the curve parameterization.

Parameters:

Name Type Description Default
vals np.ndarray

Array of values to multiply by the norm of the derivative of the curve parameterization.

required

Returns:

Type Description
numpy.ndarray

Array of values multiplied by the norm of the derivative of the curve parameterization, having the same length as the number of sampled points on the contour.

Raises:

Type Description
NotParameterizedError

If the edges have not been sampled.

parameterize(quad_dict)

Sample each edge of the contour.

Parameters:

Name Type Description Default
quad_dict QuadDict

Dictionary of quadrature rules.

required

set_mesh_id(cell_id)

Set the cell_id of the contour.

This is the global index of the MeshCell that the contour is part of the boundary of.

Parameters:

Name Type Description Default
cell_id int

The MeshCell id of the contour.

required

Raises:

Type Description
TypeError

If cell_id is not a positive integer.