Stratified flow over a mountain with a gap: Linear theory and numerical simulations