/** # Saint Venant / Shallow Water "transcritical flow on a bump", ## Problem For a given bump at the bottom of a river, find the free surface deformation. We test the analytical linearized solution : $$h = 1 + \frac{z_b(x)}{Fr^2-1}$$ ## Shallow-Water Saint-Venant model The classical Shallow Water Equations in 1D with a topography and no friction. $$\left\{\begin{array}{l} \partial_t h+\partial_x Q=0\\ \partial_t Q+ \partial_x \left[\dfrac{Q^2}{h}+g\dfrac{h^2}{2}\right] = - gh \partial_x z_b \end{array}\right.$$ with a given topography $z_b(x)$, and we vary the Froude number $Fr$. As we are without dimension, $g=1$, the depth is measured with unit, and the initial velocity will be $Fr$, in practice $z_b=\alpha exp(-x^2)$ with $\alpha=0.1$ Depending on the Froude number, the free surface will present various deformations. ## Code */ #include "grid/cartesian1D.h" #include "saint-venant.h" double tmax,Fr; /** free output */ u.n[left] = neumann(0); u.n[right] = neumann(0); h[left] = neumann(0); h[right] = neumann(0); /** start by a constant flow */ event init (i = 0) { foreach(){ zb[] = .1*exp(-x*x); h[] = 1 - zb[]; u.x[] = Fr; } boundary({zb,h,u}); #ifdef gnuX printf("\nset grid\n"); #endif } /** position of domain X0, length L0, no dimension G=1 run with 512 points (less is not enough). Do a loop on Froude */ int main() { X0 = -10.; L0 = 20.; G = 1; N = 512; tmax=50; double FF[4]={ .2 , .4 , 0.65 , 2}; // loop on Froude for (int iF=0;iF<=3;iF++){ Fr = FF[iF]; run();} } /** Output in gnuplot if the flag gnuX is defined */ #ifdef gnuX event plot (t