A new approach to grid generation based on local optimisation