Any flow on a closed surface is a gradient plus a rotation plus a harmonic part, uniquely. Split flows on surfaces of every genus and count the harmonic part: it is twice the number of holes
Any flow on a closed surface is, in exactly one way, a gradient (flowing from high to low), plus a rotation (swirling round), plus a harmonic part that goes round the holes. The three parts never interfere with each other, and the harmonic part is the only one the holes can feel.
Paint on the first picture with a source, a sink, a swirl or the wind, and watch the other three pictures split what you painted. Notice that only the wind ever moves the harmonic part.
energy 533.87 · the three parts’ energies add to 533.87
energy 55.49 (10.4%) · runs downhill, from emerald to rose
energy 319.64 (59.9%) · anticlockwise round emerald, clockwise round rose
energy 158.75 (29.7%) · the same arrow everywhere
The square’s opposite edges are glued (dashed border), so it is a flat torus: what leaves on the right comes back on the left. A flow is one number on each edge of the 48 × 48 grid; the split is computed exactly by two Fourier solves. All four pictures use the same arrow scale, so a part can be larger than the flow where the others cancel it. The shading is the height the gradient part runs down, and the stream function the rotation part circles.
Helmholtz. In 1858, studying vortices in fluids, Hermann von Helmholtz showed that a vector field in space that dies away fast enough splits as a gradient plus a field with no divergence: v = ∇φ + ∇ × A. The gradient carries all the sources and sinks, and the second part all the swirl. On a flat torus there is a third piece, because a steady wind blowing the same way everywhere has neither sources nor swirl, yet is not the gradient of anything: a function whose slope is always 1 to the east would have to climb forever, and on the torus it comes back to where it started.
Hodge. On a closed surface (or any compact oriented manifold with a metric) the same split holds for differential forms: every 1-form is uniquely ω = dα + δβ + h, with α a function, β a 2-form, δ the adjoint of d, and h harmonic, meaning dh = 0 and δh = 0. W. V. D. Hodge developed the theory of harmonic forms in the 1930s, and Kunihiko Kodaira gave the decomposition in its general form in 1949. On the grid, d is the difference across each edge, its adjoint is minus the net outflow at each vertex, the curl is the circulation round each cell, and the two Poisson problems are solved exactly by a discrete Fourier transform. The vector-calculus words for these, divergence and curl, are in Stokes and Divergence; see also Vector Calculus.
Orthogonality. The parts are perpendicular in the inner product ⟨a, b⟩ = ∫ a · b (on the grid, the sum over edges). For a gradient and a rotation, ⟨dα, δβ⟩ = ⟨ddα, β⟩ = 0, because d∘d = 0: the circulation of a gradient round any cell is zero. Likewise ⟨dα, h⟩ = ⟨α, δh⟩ = 0 and ⟨δβ, h⟩ = ⟨β, dh⟩ = 0. So the energy of the flow is the sum of the energies of its parts, Pythagoras in a space with thousands of dimensions, and the split is unique: a flow that were two different sums would give a nonzero vector perpendicular to itself.
The flat torus. Here the harmonic flows are exactly the constant winds, a 2-dimensional space: one direction for each of the 2g = 2 independent loops round the torus. Sources, sinks and swirls all have average zero, since whatever leaves one edge enters the next, so the harmonic part of any flow is its average wind. The last two readouts show it computed both ways: directly, as the mean of the edge values, and as what the solves leave over.
Switch between the flow and its three parts, and click the surface to add sources and swirls. Then choose the sphere and see the harmonic part vanish.
The discrete split. On a triangulated surface a flow is a number per edge, d takes functions on vertices to flows and flows to numbers on triangles, and d∘d = 0 exactly. The metric enters through positive weights on the edges (the Hodge star ⋆1, here cotangent weights), which define the inner product. The gradient part solves one Poisson problem on the vertices, the rotation part one on the triangles, and the harmonic part is what is left. Because the inner product is a genuine one and d∘d = 0, the parts are orthogonal and the harmonic part is closed and co-closed, exactly, up to the rounding of the solver; that is what the cross terms and the last readout show.
What the metric changes. Change the weights, which is what changing the shape of the surface does, and the parts change shape: a different flow counts as the gradient part, and the harmonic part bends to stay perpendicular. What does not change is the dimension of each space (V − 1 gradients, F − 1 rotations, 2g harmonic flows) and the class of the harmonic part: for a flow with no swirl, the harmonic part has the same integral round every loop as the flow itself, whatever the weights. The harmonic part depends on the metric; the class it represents does not.
Discrete and smooth. The statements above are exact for the mesh. The shape of the mesh’s harmonic part only approximates the smooth harmonic form, getting closer as the triangles shrink. On the sphere there are no loops that cannot be shrunk, so there are no harmonic flows at all, and every flow is a gradient plus a rotation. For the smoothest member of each class, found by letting the flow settle, see The Smoothest Representative.
Move the slider from the sphere to five holes and watch random flows go through the split one at a time. Compare the number of emerald bars with the count from Euler’s formula beside it.
The count. The flows on a mesh form a space of dimension E, one number per edge. The gradients are the image of d on functions; its kernel is the constants, so they fill V − 1 dimensions. The rotations are the image of the adjoint of d on triangle values; its kernel is again the constants, so they fill F − 1. The harmonic flows are the rest: E − (V − 1) − (F − 1) = 2 − (V − E + F) = 2 − χ = 2g, which is the first Betti number b1, the number of independent loops counted in Counting Holes.
Two routes. The demo finds 2g by analysis: it solves the two Poisson problems for each random flow and measures how many independent harmonic parts come out, using Gram–Schmidt with a tolerance far above rounding and far below any real direction. It finds 2g again by topology, counting vertices, edges and triangles. Neither route looks at the other. The ranks of d on functions and on flows are found exactly, by counting the connected pieces of the edge graph and of the graph of neighbouring triangles.
The Hodge theorem. In the smooth setting the statement is that every class of closed forms contains exactly one harmonic form, so the harmonic k-forms have dimension bk, the k-th Betti number. This is Hodge’s theorem, for compact Riemannian manifolds, and it is the bridge the rest of the module crosses: on a complex manifold, harmonic forms split further by type (p, q), and the Hodge conjecture asks which classes of type (p, p) come from subvarieties. The count here is the discrete shadow of the theorem, not the conjecture.
Spot a mistake or have an idea?