I am currently working on the 3D potts model in a temperature gradient to identify the critical temperature and critical exponent. I use the Swendsen-Wang algorithm to simulate the dynamics of the system, and I use the Hoshen-Kopelman algorithm to identify the clusters of spins. The problem is: The method I am currently using to identifying the front between the ordered and disordered region is too naive, I think, because I get a slight error in the critical temperature for Q = 2, whose value is known from series expansion. What I have done: The temperature gradient is along the z-axis, and I use a regular cubic lattice of size (NX x NY x NZ). I have currently used the highest z-value (for each x and y) that corresponds to the cluster spanning most of the ordered region to define the front. With this method, I get J/(k_b T) ~ 0.226, while the correct value is closer to 0.2216. What I want to do is the following: Find a way to identify the boundary/contour of the spanning cluster in the ordered region, and use that to define the interface between the ordered and the disordered regions. I currently have a way to identify these, but I think it is very inefficient and complicated, and it may not be entirely correct. So my question is this: Are there any known algorithms to identify the boundary of a given (generally convex) structure/set of points?