Failure in accretionary wedges with the maximum strength theorem: numerical algorithm and 2D validation