A numerical procedure for geochemical compaction in the presence of discontinuous reactions