The mass is changed by injecting molecules at the left. The density (mass/volume) remains a constant for constant pressure and temperature.