Shock in the Inviscid Burgers Equation

characteristicsnumerical methodspartial differential equations

I'm trying to implement the Finite-Volume method using local Lax-Friedrichs flux function. I found an example to the Riemann-problem, here is the solution plot:
enter image description here

So from characteristics $$u=\begin{cases}
1, x<\frac{1}{2}t \\
0, x>\frac{1}{2}t
\end{cases}$$

How can we see from the plot where the shock is?

Best Answer

If you want a numerical way of finding the shock, you could take your array $u[i,j]$ and consider the partial derivative in the x-direction: dudx = diff(u) / dx

And then if you contour plot dudx, you should get an image where the shock shows up as yellow. This should be along the line $t = 2x$, which you can see in your plot above.