  We propose a systematic and efficient quantum circuit composed solely of
Clifford gates for simulating the ground state of the surface code model. This
approach yields the ground state of the toric code in $\lceil
2L+2+log_{2}(d)+\frac{L}{2d} \rceil$ time steps, where $L$ refers to the system
size and $d$ represents the maximum distance to constrain the application of
the CNOT gates. Our algorithm reformulates the problem into a purely geometric
one, facilitating its extension to attain the ground state of certain 3D
topological phases, such as the 3D toric model in $3L+8$ steps and the X-cube
fracton model in $12L+11$ steps. Furthermore, we introduce a gluing method
involving measurements, enabling our technique to attain the ground state of
the 2D toric code on an arbitrary planar lattice and paving the way to more
intricate 3D topological phases.
