Spatial optimisation of three-dimensional circulation