Geometry and dynamics of magma chambers