Desaturation of porous media. I. Unconsolidated materials