Energy-based modeling of cohesive and cohesionless cracks via X-FEM