A general and e cient formulation of fractures and boundary conditions in the nite element method