Find weak solution to Riemann problem for conservation law 
Find the weak solution of the following conservation law
$$ u_t + (u^2)_x = 0 $$
with the initial condition
$$ u(x,0) = \left\lbrace
\begin{aligned}
&u_l & &\text{if } x < 0 ,\\
&u_r & &\text{if } x > 0.
\end{aligned}\right. $$
Consider both cases $u_l>u_r$ and $u_l<u_r$. Fin the solution at $x=0$ in each case.

Attempt
We have  equation: $u_t + 2 u u_x = 0 $ and characteristics are given by $t' = 1 $ and $x' = 2u $ and $u' = 0$ and so $u = const$, $t = s$, $x = 2 u s + r $ so that
$$ x = 2 u(x,0) t + r $$
are characteristicts. so that
$$ x = \begin{cases} 2 u_l t + r, \; \; r < 0 \\ 2 u_r t + r, \; \; r > 0 \end{cases} $$
so thereis a shock formation at $x=0$. Any help in how to continue this problem?

This is very similar to the Riemann problem of the inviscid Burgers' equation (see e.g. (1), (2), (3), (4) and related posts). For this type of problem, weak solutions are not unique. Thus, I guess that the problem statement asks for the entropy solution. I will provide a detailed general answer for the case of conservation laws $u_t + f(u)_x = 0$ with Riemann data $u(x<0,0) = u_l$ and $u(x>0,0) = u_r$, where the flux $f$ is smooth and convex (the case of concave fluxes is very similar). If the flux has inflection points, the more general solution is provided here.
In the case of convex a flux $f$, there are only two possible types of waves:

*

*shock waves. If the solution is a shock wave with speed $s$,
$$
u(x,t) = \left\lbrace\begin{aligned}
&u_l & &\text{if } x < s t, \\
&u_r & &\text{if } st < x,
\end{aligned}\right.
$$
then the speed of shock must satisfy the Rankine-Hugoniot jump condition $s = \frac{f(u_l)-f(u_r)}{u_l-u_r}$. Moreover, to be admissible, the shock wave must satisfy the Lax entropy condition $f'(u_l) > s > f'(u_r)$,
where $f'$ denotes the derivative of $f$.


*rarefaction waves. They are obtained from the self-similarity Ansatz $u(x,t) = v(\xi)$ with $\xi = x/t$, which leads to the identity $f'(v(\xi)) = \xi$. Since $f'$ is an increasing function, we can invert the previous equation to find $v(\xi) = (f')^{-1}(\xi)$. The final solution reads
$$
u(x,t) = \left\lbrace\begin{aligned}
&u_l & &\text{if } x \leq f'(u_l) t, \\
&(f')^{-1}(x/t) & &\text{if } f'(u_l) t \leq x \leq f'(u_r) t, \\
&u_r & &\text{if } f'(u_r) t \leq x,
\end{aligned}\right.
$$
where $(f')^{-1}$ denotes the inverse function of $f'$. One notes that this solution requires $f'(u_l) \leq f'(u_r)$.

In the present case, the flux $f: u \mapsto u^2$ is a smooth convex function, so that its derivative $f':u\mapsto 2u$ is increasing. Shock waves are obtained for $u_l \geq u_r$ (cf. Lax entropy condition), and rarefaction waves are obtained for $u_l \leq u_r$. In the first case, the shock speed deduced from the Rankine-Hugoniot condition reads $s = u_l + u_r$. The value of the solution at $x=0$ for positive times is $u_r$ if $s < 0$, and $u_l$ otherwise. In the second case, the reciprocal of the derivative is given by $(f')^{-1} : \xi \mapsto \xi/2$. The value of the solution at $x=0$ for positive times is $u_r$ if $u_r < 0$, $u_l$ if $u_l > 0$, and $0$ otherwise (i.e., if $u_l < 0 < u_r $).
