An algorithm for simulating fracture of cohesive–frictional materials