Solution (source code)

= Solution

Take $y$ from the first wall to the second, with $f>0$. Negligible transverse velocity and cross-channel <geostrophic balance> give $fu=-g\partial_y(h+H)=-gh_y$, since the bed elevation $H(x)$ is independent of $y$. Therefore the <volume flux> is
$$
Q=\int_0^{b}uh\,dy=-\frac gf\int_0^{b}h h_y\,dy=\boxed{\frac g{2f}(h_1^2-h_2^2).}
$$
For positive downstream <volume flux>, the layer is deeper at the first wall: $h_1>h_2$. This calculation does not require zero <shallow-water potential vorticity>.

Here $h_j$ must denote the wall depth above the local bed. If the surface heights are instead measured from a fixed vertical datum, write them as $\eta_j$ and use $h_j=\eta_j-H(x)$, giving $Q=g[(\eta_1-H)^2-(\eta_2-H)^2]/(2f)$. The compact formula thus uses a bed-relative meaning of the wall heights.