Skip to content

puncturedfem.DirichletTrace

Dirichlet trace.

This class is used to represent the trace of a LocalFunction on the boundary of a MeshCell. The trace is represented as a list of edges, and the values of the trace on the edges are stored in an array. The class also contains methods to set the values of the trace and to evaluate the trace on the edges. The weighted normal and tangential derivatives can also be set, but must be computed separately.

Attributes:

Name Type Description
edges list[Edge]

The edges on which the trace is defined.

num_pts int

The number of points on the edges.

values np.ndarray

The values of the trace on the edges.

w_norm_deriv Optional[np.ndarray]

The weighted normal derivatives of the trace on the edges.

w_tang_deriv Optional[np.ndarray]

The weighted tangential derivatives of the trace on the edges.

funcs list[Func_R2_R]

The functions used to define the trace.

edge_sampled_indices list[tuple[int, int]]

The start and end indices of the edges in the values array.

__add__(other)

Add two Dirichlet traces.

Parameters:

Name Type Description Default
other DirichletTrace

The other Dirichlet trace.

required

Returns:

Type Description
DirichletTrace

The sum of the two Dirichlet traces.

__init__(edges, custom=False, funcs=None, values=None)

Construct a DirichletTrace object.

Parameters:

Name Type Description Default
edges Union[MeshCell, list[Edge]]

The edges on which the trace is defined.

required
custom bool, optional

A flag indicating whether the trace is defined using custom functions. If True, the user must set the values and functions manually.

False
funcs Optional[Union[Func_R2_R, list[Func_R2_R]]], optional

The functions used to define the trace. Default is None.

None
values Optional[Union[FloatLike, list[FloatLike]]], optional

The values of the trace on the edges. Default is None. Takes precedence over funcs.

None

__mul__(other)

Multiply the trace by a scalar.

Parameters:

Name Type Description Default
other Union[int, float]

The scalar to multiply the trace by.

required

Returns:

Type Description
DirichletTrace

The trace multiplied by the scalar.

__rmul__(other)

Multiply the trace by a scalar.

Parameters:

Name Type Description Default
other Union[int, float]

The scalar to multiply the trace by.

required

Returns:

Type Description
DirichletTrace

The trace multiplied by the scalar.

__sub__(other)

Subtract two Dirichlet traces.

Parameters:

Name Type Description Default
other DirichletTrace

The other Dirichlet trace.

required

Returns:

Type Description
DirichletTrace

The difference of the two Dirichlet traces.

__truediv__(other)

Divide the trace by a scalar.

Parameters:

Name Type Description Default
other Union[int, float]

The scalar to divide the trace by.

required

Returns:

Type Description
DirichletTrace

The trace divided by the scalar.

edges_are_parametrized()

Check if all edges are parametrized.

Returns:

Type Description
bool

True if all edges are parametrized, False otherwise.

find_edge_sampled_indices()

Find the start and end indices of the edges in the values array.

The result is stored in the attribute 'edge_sampled_indices'.

find_num_pts()

Find the total number of sampled points on the edges.

The result is stored in the attribute 'num_pts'.

find_values()

Find the values of the trace on the edges.

This is done by evaluating the trace functions at the sampled points on each edge.

The result is stored in the attribute 'values'.

get_edge_sampled_point_indices(edge_index)

Get the indices of the sampled points on given edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge.

required

Returns:

Type Description
tuple[int, int]

The start and end indices of the sampled points on the edge.

set_edges(edges)

Set the edges on which the trace is defined.

Parameters:

Name Type Description Default
edges Union[MeshCell, list[Edge]]

The edges on which the trace is defined.

required

set_func_from_poly_on_edge(edge_index, poly, compute_vals=True)

Set the polynomial used to define the trace on a specific edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge on which the function is set.

required
poly Polynomial

The polynomial used to define the trace on the edge.

required
compute_vals bool, optional

A flag indicating whether the values of the trace should be computed. Default is True.

True

set_func_on_edge(edge_index, func)

Set the function used to define the trace on a specific edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge on which the function is set.

required
func Func_R2_R

The function used to define the trace on the edge.

required

set_funcs(funcs, compute_vals=True)

Set the functions used to define the trace.

Parameters:

Name Type Description Default
funcs Union[Func_R2_R, list[Func_R2_R]]

The functions used to define the trace.

required
compute_vals bool, optional

A flag indicating whether the values of the trace should be computed. Default is True.

True

set_funcs_from_polys(polys)

Set the functions used to define the trace from a list of polynomials.

Parameters:

Name Type Description Default
polys Union[Polynomial, list[Polynomial]]

The polynomials used to define the trace.

required

set_trace_values(values)

Set the values of the trace on all edges.

Parameters:

Name Type Description Default
values FloatLike or list[FloatLike]

The values of the trace on the edges. If a scalar, the same value is set on all edges. If a list, the length must be equal to the number of edges. If an np.ndarray, the shape must be equal to the number of points on the edges.

required

set_trace_values_on_edge(edge_index, values)

Set the values of the trace on a specific edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge on which the values are set.

required
values FloatLike

The values of the trace on the edge.

required

set_weighted_normal_derivative(wnd)

Set the weighted normal derivatives of the trace on all edges.

Parameters:

Name Type Description Default
wnd FloatLike or list[FloatLike]

The weighted normal derivatives of the trace on the edges. If a scalar, the same value is set on all edges. If a list, the length must be equal to the number of edges. If an np.ndarray, the shape must be equal to the number of points on the edges.

required

set_weighted_normal_derivative_on_edge(edge_index, wnd)

Set the weighted normal derivative of the trace on a specific edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge on which the weighted normal derivative is set.

required
wnd FloatLike

The weighted normal derivative of the trace on the edge.

required

set_weighted_tangential_derivative(wtd)

Set the weighted tangential derivatives of the trace on all edges.

Parameters:

Name Type Description Default
wtd FloatLike or list[FloatLike]

The weighted tangential derivatives of the trace on the edges. If a scalar, the same value is set on all edges. If a list, the length must be equal to the number of edges. If an np.ndarray, the shape must be equal to the number of points on the edges.

required

set_weighted_tangential_derivative_on_edge(edge_index, wtd)

Set the weighted tangential derivative of the trace on a specific edge.

Parameters:

Name Type Description Default
edge_index int

The index of the edge on which the weighted tangential derivative is set.

required
wtd FloatLike

The weighted tangential derivative of the trace on the edge.

required