Scientific ML Studio
Learn/ Studio Tour/ 3.2
3.2 · The blocks, one at a time

Complex geometries

The Composite domain block builds a 2-D domain from rectangles and circles, each added or cut out in turn: a plate with a hole, an L-shape, a channel with a cylinder in it.

The Domain block offers a line, a rectangle and a circle. Many real problems live on something else: a plate with a bolt hole, a bracket with a notch, a channel with an obstacle in the flow. For those, use the Composite domain block, shown on the canvas as DOM+. It does the same job as the Domain block (coordinates, interior points, one port per boundary, optional time) but builds its shape from up to four simple pieces.

Use it instead of the Domain block, not as well. A notebook has exactly one domain, and the Graph check complains if you wire two.

1. Place the block

Open the Domain family in the palette and choose Composite domain. Its outputs are the ones you know from the Domain block, and they wire to the same places:

Output Wire it to
Coords the Coords input of every PDE block, and of the Network
Interior the Interior input of every PDE block
BC1, BC2, … the Boundary input of a BC block, one per condition
Initial (only with time on) the IC block

A fresh block is already a complete shape, a unit plate with a centred hole, so you can see the idea before you change a number.

2. Build the shape from slots

The panel has four groups, Shape 1 · base and Shape 2 to Shape 4. Each slot is one piece:

Field Meaning
Shape Rectangle or Circle. Slots 2 to 4 also offer None (not used), which hides the rest of the slot.
Operation (slots 2 to 4) Subtract (cut out) removes the piece from the domain; Add (union) joins it on.
x min, x max, y min, y max a rectangle's edges (axis-aligned)
Centre x, Centre y, Radius a circle

The slots are applied in order, top to bottom. Shape 1 is the starting domain; every later shape acts on everything above it. Order matters when you mix the two operations: cut a hole and then add a rectangle over it, and the hole is filled in; add the rectangle first and then cut the hole, and the hole stays.

A few recipes, all in plain numbers you can type in:

Domain Shape 1 Shape 2 Shape 3
Plate with a hole (the default) Rectangle 0 to 1 by 0 to 1 Circle, subtract, centre (0.5, 0.5), radius 0.2 None
L-shape Rectangle 0 to 1 by 0 to 1 Rectangle, subtract, 0.5 to 1 by 0.5 to 1 None
Plate with two holes Rectangle 0 to 1 by 0 to 1 Circle, subtract, (0.3, 0.5), 0.1 Circle, subtract, (0.7, 0.5), 0.15
Rectangle with a rounded end Rectangle 0 to 0.6 by 0 to 1 Circle, add, (0.6, 0.5), 0.5 None
Channel with a cylinder (worked problem 13.11) Rectangle 0 to 22 by 0 to 4.1 Circle, subtract, (2, 2), 0.5 None
Left: a plate with a hole. Shape 1 is a rectangle and shape 2 a subtracted circle. Five boundaries: BC1 left, BC2 right, BC3 bottom, BC4 top, and BC5 the rim of the hole, whose outward normal points into the hole. Right: an L-shape, a square with a quarter square subtracted. Six boundaries: BC1 left, BC2 the lower half of the right side, BC3 bottom, BC4 the left half of the top, BC5 and BC6 the two inner edges of the cut. The cut's other two edges lie on the outer square and are drawn as dotted grey: they are unused.
Figure. Two composite domains, with the boundary numbers the Studio gives them. Dashed outlines are the shapes in the slots (S1, S2); the coloured edges are the boundary of the result.

3. Read the boundaries

Every edge of every shape you chose gets an output port: four for a rectangle, one (the rim) for a circle. The numbers then decide which of those edges are really part of the boundary of the combined shape.

  • Edges that are, entirely or in part, are numbered BC1, BC2, … in slot order, and within a rectangle in the order left, right, bottom, top.
  • Edges that end up wholly inside or outside the result keep their port, but it is labelled unused and greyed out. Nothing is sampled on them, and a condition wired to one is ignored.

In the L-shape, the cut's right and top edges lie exactly on the outer square, so they are unused. The square's right and top edges lose the half that was cut away. Detect boundaries spells this out, and hovering over a port shows the same text:

Detected 6 boundaries: BC1 (Shape 1 (base rectangle) left edge, x = 0), BC2 (Shape 1 (base rectangle) right edge, x = 1 -- 50% of it is on the boundary), BC3 (Shape 1 (base rectangle) bottom edge, y = 0), BC4 (Shape 1 (base rectangle) top edge, y = 1 -- 50% of it is on the boundary), BC5 (Shape 2 (cut rectangle) left edge, x = 0.5), BC6 (Shape 2 (cut rectangle) bottom edge, y = 0.5). Not on the boundary (ports marked "unused"): Shape 2 (cut rectangle) right edge, x = 1, Shape 2 (cut rectangle) top edge, y = 1

Why keep a port that is unused? The ports depend only on which kinds of shape you chose, never on the numbers. While you type 0.25 into a field, the shape passes through values where an edge briefly leaves the boundary. If that removed the port, it would also remove the wire on it, and you would lose a condition without noticing. Instead, the labels update as you type and the wires stay where you put them.

Two edges of different shapes that lie on top of each other count once. If two rectangles share a side, that side is inside the union and belongs to neither. If they share part of a bottom edge, the earlier slot owns the shared part.

4. Normals on a hole point into the hole

A boundary's outward normal points out of the domain. On the rim of a hole, that is into the hole, toward the circle's centre. This only matters for conditions that use the normal derivative: on a Neumann edge, du/dn = 2 on a hole means $u$ increases toward the hole's centre. An insulated hole, du/dn = 0, is the same either way. The preview draws every normal, so check it there.

5. Sample the points

The sampling settings are the Domain block's, and they mean the same:

  • Interior points: the script draws points over the bounding box and keeps the ones inside the shape, drawing more until it has the number you asked for. With Regular grid the grid keeps its spacing, so you get close to the number rather than exactly it.
  • Points per boundary: one row per live boundary. Unused edges have no row. On an edge that is only partly boundary, all of its points go on the live part.

Holes are where the solution usually changes fastest, so give the rim its own, larger count in the table.

6. Preview the shape

Plot geometry and points is the quickest way to check the numbers you typed. It draws:

  • each slot's own outline, dashed and tagged S1 to S4, in teal if it is added and red if it is cut out;
  • the coordinates of the bounding box's corners;
  • the interior points;
  • each boundary in its own colour, with its label and an outward normal (the same colours as the boundary table);
  • unused edges as grey dotted lines.

While the preview is open it redraws as you type, so you can move a hole and watch it move.

7. What the Graph check says

Message What to do
Composite domain, shape 1: x_min must be smaller than x_max (currently 2 and 1). Swap or fix the two numbers.
Composite domain, shape 2 (circle) cuts out nothing: it does not overlap the shape built so far. Check its numbers. The piece misses the domain, usually a typo in its centre.
Composite domain: the shapes cancel out, so the domain is empty. A subtracted piece covers everything.
A Boundary condition block is wired to an unused edge (…). That edge is not on the boundary of the combined shape, so the condition is ignored. Move the wire to a live port.
No condition on BC5. Those boundaries are left free. Add a BC block for it, or leave it if a free edge is what you meant.
Periodic conditions are not available on a Composite domain. Use the plain Domain block for periodic problems.

8. Limits worth knowing

  • 2-D only, with up to four pieces. Rectangles are axis-aligned.
  • No periodic conditions.
  • Re-entrant corners are hard. At the inner corner of an L-shape, the solution of many problems has a singular gradient. A PINN smooths over it, so expect the largest error there.
  • Plots are blank outside the domain. The generated field plots and residual maps cover the bounding box and leave the holes and cut-outs empty, rather than drawing what the network says where there is no material.

Checklist

  • The shape in the preview is the one in your problem: holes where they belong, cuts on the right side.
  • Every live boundary you mean to constrain has a BC block on it, and no BC block sits on an unused port.
  • Normal-derivative conditions on holes were written with the normal pointing into the hole.
  • The rim of a hole has enough points of its own.

Next: choosing the equation.