puncturedfem.Edge
Oriented joining two vertices of a planar mesh.
This class contains both the parameterization of the edge as well as mesh topology information.
The orientation of the Edge is from the anchor vertex to the endpnt vertex. The positive MeshCell is the MeshCell such that the Edge is oriented counterclockwise on the boundary of the MeshCell if the Edge lies on the outer boundary of the MeshCell. If the Edge lies on the inner boundary of the MeshCell, then the Edge is oriented clockwise on the boundary of the positive MeshCell. The negative MeshCell is the MeshCell such that the boundary of the negative MeshCell intersects the boundary of the positive MeshCell exactly on this Edge.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor |
Vert
|
The vertex at the start of the Edge. |
endpnt |
Vert
|
The vertex at the end of the Edge. |
pos_cell_idx |
int
|
The index of the positively oriented MeshCell. |
neg_cell_idx |
int
|
The index of the negatively oriented MeshCell. |
curve_type |
str
|
The type of curve used to parameterize the Edge. |
curve_opts |
dict
|
The options for the curve parameterization. |
quad_type |
str
|
The type of Quadrature used to parameterize the Edge. |
idx |
Any
|
The global index of the Edge as it appears in the mesh. |
is_on_mesh_boundary |
bool
|
True if the Edge is on the mesh boundary. |
is_loop |
bool
|
True if the Edge is a loop. |
is_parameterized |
bool
|
True if the Edge is parameterized. |
num_pts |
int
|
The number of points sampled on the Edge. |
x |
np.ndarray
|
The sampled points on the Edge. |
unit_tangent |
np.ndarray
|
The unit tangent vector at each sampled point on the Edge. |
unit_normal |
np.ndarray
|
The unit normal vector at each sampled point on the Edge. |
dx_norm |
np.ndarray
|
The norm of the derivative of the parameterization at each sampled point on the Edge. |
curvature |
np.ndarray
|
The signed curvature at each sampled point on the Edge. |
__init__(anchor, endpnt, pos_cell_idx=-1, neg_cell_idx=-1, curve_type='line', quad_type='kress', idx=None, t_bounds=(0.0, 2 * np.pi), **curve_opts)
Initialize an Edge object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor |
Vert
|
The vertex at the start of the Edge. |
required |
endpnt |
Vert
|
The vertex at the end of the Edge. |
required |
pos_cell_idx |
int, optional
|
The index of the positively oriented MeshCell. Default is -1. |
-1
|
neg_cell_idx |
int, optional
|
The index of the negatively oriented MeshCell. Default is -1. |
-1
|
curve_type |
str, optional
|
The type of curve used to parameterize the Edge. Default is "line". |
'line'
|
quad_type |
str, optional
|
The type of Quadrature used to parameterize the Edge. Default is "kress". |
'kress'
|
idx |
Any, optional
|
The index of the Edge as it appears in the mesh. Default is None. |
None
|
__str__()
Return a string representation of the Edge.
apply_orthogonal_transformation(A, write_diary=True)
Apply an orthogonal transformation to the sampled points on the Edge.
Transforms 2-dimensional space with the linear map x mapsto A * x where A is a 2 by 2 orthogonal matrix, i.e. A^T * A = I It is important that A is orthogonal, since the first derivative norm as well as the curvature are invariant under such a transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A |
np.ndarray
|
The orthogonal 2 by 2 transformation matrix. |
required |
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|
deparameterize()
Reset the parameterization of the Edge.
dilate(alpha, write_diary=True)
Dilate by a scalar alpha.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha |
float
|
The dilation factor. |
required |
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|
dot_with_normal(comp1, comp2, ignore_endpoint=True)
Return the dot product (comp1, comp2) * unit_normal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comp1 |
np.ndarray
|
The first component of the vector to dot with the unit normal. |
required |
comp2 |
np.ndarray
|
The second component of the vector to dot with the unit normal. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the returned values. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
np.ndarray
|
The dot product (comp1, comp2) * unit_normal. |
dot_with_tangent(comp1, comp2, ignore_endpoint=True)
Return the dot product (comp1, comp2) * unit_tangent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comp1 |
np.ndarray
|
The first component of the vector to dot with the unit tangent. |
required |
comp2 |
np.ndarray
|
The second component of the vector to dot with the unit tangent. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the returned values. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
np.ndarray
|
The dot product (comp1, comp2) * unit_tangent. |
evaluate_function(fun, ignore_endpoint=True)
Return fun(x1, x2) for each sampled point on Edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fun |
Func_R2_R
|
The function to evaluate. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the returned values. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
np.ndarray
|
The values of fun(x1, x2) at each sampled point on the Edge. |
get_bounding_box()
Return the bounding box of the Edge.
Returns:
| Name | Type | Description |
|---|---|---|
x_min |
float
|
The minimum x-coordinate of the edge. |
x_max |
float
|
The maximum x-coordinate of the edge. |
y_min |
float
|
The minimum y-coordinate of the edge. |
y_max |
float
|
The maximum y-coordinate of the edge. |
get_parameterization_module()
Return the module with the functions X, DX, DDX.
The module is imported from the puncturedfem.mesh.edgelib package.
get_sampled_points(ignore_endpoint=True)
Return the sampled points on the Edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the returned points. Default is True. |
True
|
integrate_over_edge(vals, ignore_endpoint=False)
Integrate vals * dx_norm over the Edge via trapezoidal rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vals |
np.ndarray
|
The values to integrate. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the integration. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
float
|
The integral of vals * dx_norm over the Edge. |
integrate_over_edge_preweighted(vals_dx_norm, ignore_endpoint=False)
Integrate vals_dx_norm over the Edge via trapezoidal rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vals_dx_norm |
np.ndarray
|
The values to integrate, already multiplied by dx_norm. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the integration. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
float
|
The integral of vals_dx_norm over the Edge. |
join_points(a, b, write_diary=True)
multiply_by_dx_norm(vals, ignore_endpoint=True)
Return f multiplied against the norm of the derivative of the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vals |
np.ndarray
|
The values to multiply. |
required |
ignore_endpoint |
bool, optional
|
If True, the endpoint of the Edge is not included in the returned values. Default is True. |
True
|
Returns:
| Type | Description |
|---|---|
np.ndarray
|
The values multiplied by the norm of the derivative of the curve. |
parameterize(quad_dict)
Parameterize the Edge using the specified Quadrature rule.
The parameterization is stored in the following attributes: x : np.ndarray The sampled points on the Edge. unit_tangent : np.ndarray The unit tangent vector at each sampled point on the Edge. unit_normal : np.ndarray The unit normal vector at each sampled point on the Edge. dx_norm : np.ndarray The norm of the derivative of the parameterization at each sampled point on the Edge. curvature : np.ndarray The signed curvature at each sampled point on the Edge.
reflect_across_x_axis(write_diary=True)
Reflect across the horizontal axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|
reflect_across_y_axis(write_diary=True)
Reflect across the vertical axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|
reverse_orientation()
Reverse the orientation of this Edge.
A reparameterization x(2 pi - t). The chain rule flips the sign of some derivative-based quantities.
Notes
This should not be recorded in the transformation diary.
rotate(theta, write_diary=True)
Rotate counterclockwise by theta (degrees).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta |
float
|
The angle of rotation in degrees. |
required |
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|
run_transform_diary()
Execute all the transformations in the diary.
This method is called after the parameterization of the Edge is computed. The transformations are applied to the sampled points on the Edge.
The diary is a list of tuples, where the first element is the name of the method to call and the second element is a tuple of arguments to pass to the method.
set_cells(pos_cell_idx, neg_cell_idx)
Set the positively and negatively oriented MeshCells of the Edge.
set_curve_type(curve_type)
Set the curve_type string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_type |
str
|
The type of curve used to parameterize the Edge. |
required |
set_idx(idx)
Set the global index of the Edge.
set_t_bounds(t_bounds)
Set the bounds on t, where x(t) parameterizes the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_bounds |
tuple[float, float]
|
The upper and lower bounds on t, respectively. |
required |
set_verts(anchor, endpnt)
translate(a, write_diary=True)
Translate by a vector a.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a |
Vert
|
The translation vector. |
required |
write_diary |
bool, optional
|
If True, record the transformation in the diary. Default is True. |
True
|