Numerical Methods · interactive worked example
Laplace's equation on a rectangle is easy to mesh — every interior point looks the same. Cut a slanted wall into the domain and suddenly the mesh itself has to be generated automatically, node by node, before you can even write the equations.
A perfect (inviscid, incompressible) fluid flows through a flat conduit that's 1.6 m long and 1.2 m tall — but it isn't a plain rectangle. The lower-left corner is cut away by a straight diagonal wall, so the conduit narrows on the inlet side:
Fluid enters along the top free surface at a steady velocity, and on the entrance (left) and exit (right) faces the velocity is zero at the wall and ramps linearly up to the free-surface value — a no-slip-like profile, not the free-stream value applied everywhere. Every other edge — the diagonal wall and the short wall segments — is a solid boundary at zero velocity. The question: what does the full velocity field look like everywhere inside?
The same setup, in the grid units the solver actually uses (each step = 0.2 m): the boundary is just the ordered list of corners (1,7)→(9,7)→(9,1)→(7,1)→(4,4)→(1,4)→(1,7). You can edit that list yourself in the panel below — it's prefilled with this exact shape, but any closed polygon on the grid works.
Velocity field u(x,y) — solved live on your domain
—
One "i,j" grid corner per line, in order around the boundary. Top edge = free surface, leftmost vertical edge = entrance, rightmost vertical edge = exit, everything else = wall.
None of this changes if you swap "potential flow velocity" for "steady-state temperature" or "electrostatic potential" — Laplace's equation doesn't know which physics it's describing. The geometry-handling machinery is the actual reusable skill.
With both free-surface velocities equal, entrance and exit are balanced — try making the exit velocity larger than the entrance instead: the flow accelerates through the narrowing/widening geometry, and the contour bands compress near the slanted wall where the domain changes shape fastest.
Try editing the boundary list itself — delete the diagonal-cut points (4,4) and (1,4) and replace them with a plain rectangle, or add your own notch or step. The mesh, the matrix, and the solve all rebuild automatically from whatever closed shape you type in.
EngineeringCandy · Mesh generated and matrix solved live, from raw boundary points · the slanted wall is just data, not a special case in the code