Every cell stores an integer grain or phase label φ and a sub-cell position α of its boundary. Nothing diffuse is stored: near a boundary, the indicator of the resident label is smoothed with a Gaussian of fixed width ℓG = 2Δx, and the normal and curvature are read from its gradient and Hessian. The Gaussian is then discarded.
Each time step:
- find interface cells and measure n̂ and κ;
- evaluate vn = M [ΔG − σ(n̂) κ] from the process model;
- average vn over the same pair of labels, so unrelated boundaries at a junction never mix;
- move α by vnΔt/Δx; when it reaches zero the cell switches to the neighbouring label, but only if a digital-topology test shows no grain is split or merged;
- apply volume-balanced exchanges that smooth staircase artefacts, remove grains smaller than the Gaussian scale, and diffuse solute.
The time step is Δt = Δx / (8 vmax), limited further by diffusion.
This page is a JavaScript port of the C++ code, in 2D and 3D, and follows it step by step. From the same initial grains it reproduces the C++ grain-growth trajectory: in 2D, 4 of 16,384 cells differ after 377 steps; in 3D, 1 of 32,768 cells differs after 100 steps. The C++ code computes in single precision and the port in double, so runs drift apart slowly after that.
In 3D the topology test checks face connectivity on the 3×3×3 block around a cell, the volume-balanced remap runs a second sweep to remove ledges as the C++ code does, and the 19³ Gaussian-Hessian stencil is evaluated as three one-dimensional passes, which gives the same numbers at a fraction of the cost.
GPK on GitHub · arXiv:2611.04582
A. Linda and D. Raabe, A general sharp-interface simulation framework for microstructure evolution, submitted to npj Computational Materials (2026).