Direct method in calculus of variations