pihnn.geometries.line#

class pihnn.geometries.line(P1, P2, bc_type, bc_value=0, order=1, ref_loc='center', check_consistency=True, on_boundary=True, sampling_ratio=None)#

Bases: curve

Straight line between \(P_1,P_2 \in \mathbb{C}\), defined as:

\[\gamma:=\{z \in \mathbb{C}: z=tP_1 + (1-t)P_2 \text{ for some } t\in[0,1]\}.\]
Parameters:
  • P1 (int/float/complex/list/tuple/torch.tensor) – First edge of the line.

  • P2 (int/float/complex/list/tuple/torch.tensor) – Second edge of the line.

  • bc_type (str) – Type of boundary condition to assign to the curve (see above).

  • bc_value (callable / complex) – Values assigned at the boundary condition. It can be either a constant or a variable value defined through a function.

  • order (float) – Order of sampling refinement at the edges, 1 for no refinement (uniform distribution). For example, if the curve is \([0,1]\) and we want to refine on the right side, then the sampled points are distributed as \(u^{1/order}\), where \(u \sim \mathcal{U}(0,1)\) and \(order\ge1\).

  • ref_loc (str) – Where to apply refinement. ‘center’ for symmetric refinement (i.e., both edges), ‘start’ only at the first edge and ‘end’ only at the second edge.

  • check_consistency (bool) – If False, the current curve is excluded from the pihnn.geometries.boundary.check_consistency() check.

  • on_boundary (bool) – Set to False if the current curve is not really part of the domain boundary.

  • sampling_ratio (float) – Number of sampled points on the curve with respect to the total sampled points on the boundary. By default, it’s the ratio between the curve length and the boundary perimeter.

map_point(s)#

Parametrization of the curve, i.e., the bijective function \([0,1] \rightarrow \gamma \subset \mathbb{C}\).

Parameters:

s (float/torch.tensor) – Value(s) in [0,1], typically obtained from a pseudo-random generator.

Returns:

  • point (torch.tensor) - Coordinates of the mapped point(s).

  • normal (torch.tensor) - Coordinates of the boundary outward vectors at the mapped point(s).

is_inside(points, tol=1e-06)#

Verifies whether a point lies on the curve, considering a tolerance.

Parameters:
  • points (torch.tensor) – Batch of points to inspect.

  • tol (float) – Tolerance for the measure of distance.

Returns:

inside (torch.tensor) - For each input point, True if it is inside and False if it outside.

intersect_ray(points)#

Verifies whether a point is on the left of the curve, i.e., if the horizontal leftward straight line starting from the point intersects the curve. This function is used for the ‘ray casting algorithm’ in pihnn.geometries.boundary.is_inside().

Parameters:

points (torch.tensor) – Batch of points to inspect.

Returns:

inside (torch.tensor) - For each input point, True if it is inside and False if it outside.