A numerical method for fracture of rods