A Finite Element Cavitation Algorithm