A finite-element method for the 1-D water flooding problem with gravity