Filling or emptying a chamber with granular material