Finite element simulation of two- and three-dimensional free surface flows