Coordinate transformation and construction of finite element mesh in a diverted tokamak geometry