Open or closed geochemical systems during diagenesis in sedimentary basins: Constraints on mass transfer during diagenesis and the prediction of porosity in sandstone and carbonate reservoirs