Name the pieces of a boundary

Use this when the boundary of a shape in the plane has several pieces with different conditions, and you want plans and messages to call them by names of your own.

Steps

  1. Give each curve, line or arc a name when you draw it.

  2. Check the names with region.pieces.

  3. In boundary=, use the piece itself or its name as the key.

  4. Read the plan: its notes refer to the pieces by these names.

Example

Half a disk. The solution is known: \(u = y\) is harmonic, vanishes on the diameter, and is \(y\) on the arc.

import math

import numpy as np
import sympy as sp
import pdemagic as pm
from pdemagic import curves

x, y = sp.symbols("x y", real=True)
u = sp.Function("u")(x, y)

arc = curves.Arc((0, 0), 1, 0, math.pi, name="arc")
diameter = curves.Line((-1, 0), (1, 0), name="diameter")
half = pm.Region(x, y, curves.Curve(arc, diameter))
assert half.pieces == ("arc", "diameter")

problem = pm.Problem(
    sp.Eq(pm.laplacian(u), 0),
    domain=half,
    boundary={"arc": sp.Eq(u, y), "diameter": sp.Eq(u, 0)},
)
solution = pm.solve(problem)
assert abs(solution(0.3, 0.5) - 0.5) < 1e-10

print(solution.plan.notes[1])
Boundary conditions: the value on `arc`, the value on `diameter`.

Notes

  • Without a name, a piece is called by where it is: curve 1 for a circle or an ellipse, curve 1 side 2 for the second side of a polygon, counted from the first corner, and curve 1 piece 2 for the second piece of a Curve.

  • A polygon takes one name for all of its sides. With name="edge" they are edge side 1, edge side 2 and so on, and polygon.sides[0] is the first of them as an object.

  • Two pieces must not share a name. A key in boundary= that is no piece is refused, and the message lists the pieces.

  • A curve as a key stands for all of its pieces.

  • A box and a round domain have faces, not pieces: see Give each face its own condition.

  • Shapes in the plane explains curves and pieces, and the reference lists them.