Solution (source code)

= Solution

Constant density in each layer and negligible ambient acceleration far from the front give
$$
\boxed{u_t+uu_x+g'h_x=0.}
$$
This primitive <momentum conservation> equation remains valid with slowly varying $B$. In conservative form it is
$$
\partial_t(Au)+\partial_x\left(Au^2+\frac{g'Bh^3}{6}\right)=\frac{g'h^3}{6}B',
$$
where the right side is the longitudinal component of the <hydrostatic pressure> force on the sloping sidewalls. Omitting that term while retaining variable $B$ would give the wrong acceleration.

Together with <volume conservation>, the principal coefficient matrix in $(h,u)$ is
$$
\begin{pmatrix}u&h/2\\g'&u\end{pmatrix}.
$$
Its real <eigenvalues> and <characteristic curves> are
$$
\boxed{\frac{dx}{dt}=u\pm c,\qquad c=\sqrt{\frac{g'h}{2}}.}
$$
These are downstream and upstream <gravity waves> relative to the moving fluid. The factor $1/2$ is geometric: the hydraulic depth is $A/b(h)=h/2$. Both waves move downstream in a sufficiently fast current, whereas one can carry information upstream in a slower current.

For $B=1$, differentiate $c^2=g'h/2$ and combine the two equations. The <Riemann invariants> are
$$
\boxed{\left[\partial_t+(u\pm c)\partial_x\right](u\pm4c)=0.}
$$
For variable $B$ they instead obey
$$
\left[\partial_t+(u\pm c)\partial_x\right](u\pm4c)=\mp cu\frac{B'}B,
$$
which also checks that the invariant claim depends on a prismatic channel.