A direct method for the construction of solutions of the Hamilton-Jacobi equation