A variational model for fracture mechanics: a finite element algorithm and numerical simulations