The variable $u$ is constant along the characteristic curves, which satisfy
\begin{aligned}
x'(t) & = u(x(t),t) \, ,
\\
& = u(x(0),0) \, .
\end{aligned}
Thus, the latter are straight lines in the $x$-$t$ plane, determined by the initial data. Here, the initial data is piecewise constant, i.e. we solve Riemann problems. As displayed in the figure below,
- characteristics separate in the vicinity of $x=0$, and a rarefaction wave occurs;
- characteristics cross in the vicinity of $x=1$, and a shock-wave occurs.
The rarefaction wave is a continuous self-similar solution, deduced from the self-similarity Ansatz $u (x,t)=v (\xi)$ with $\xi = x/t$. Indeed,
$$
\partial_t
u(x,t) + u(x,t)\, \partial_x u(x,t) = \left(v(\xi) - \xi\right) \frac{v'(\xi)}{t} \, ,
$$
and thus, $v(\xi) = \xi$ or $u(x,t) = x/t$.
The shock speed $s$ is given by the Rankine-Hugoniot jump condition:
$$
s = (1+0)/2\, .
$$
As long as the rarefaction and the shock don't interact, the solution is
therefore
$$
u(x,t) =
\left\lbrace
\begin{aligned}
& 0 &&\text{if }\; x\leq 0 \, , \\
& x/t &&\text{if }\; 0\leq x\leq t \, , \\
& 1 &&\text{if }\; t \leq x < 1+ t/2 \, ,\\
& 0 &&\text{if }\; 1+t/2 < x \, ,
\end{aligned}
\right.
$$
valid for times $t<t^*$ such that $t^* = 1 + t^*/2 = 2$. At the time $t^*$, both waves interact. The new shock speed is determined from the Rankine-Hugoniot condition
$$
x'(t) = (x(t)/t+0)/2 \, ,
$$
with initial shock speed $x'(t^*) = s$.
Hence, the solution for $t\geq t^*$ is
$$
u(x,t) =
\left\lbrace
\begin{aligned}
& 0 &&\text{if }\; x\leq 0 \, , \\
& x/t &&\text{if }\; 0\leq x< \sqrt{2t} \, , \\
& 0 &&\text{if }\; \sqrt{2t} < x \, .
\end{aligned}\right.
$$
The calculus of the general solution of the Burgers PDE $u_t+u_x u=0$ with the method of characteristics was already shown several times on the forum. Only the initial conditions are different from one case to another.
For example :
Inviscid Burgers' Equation and Implicit Solutions
Find the breaking time in IVP for classical Burgers equation
It isn't necessary to repeat again how one comes to the general solution :
$$u=F(x-ut)$$
where $F$ is any differentiable function.
In the present case, the initial condition is :
$$F(x)=u(x,0) =
\begin{cases}
0, & \text{if } x < 0\\
nx,& \text{if } 0 \leq x \leq \frac{1}{n}\\
1, & \text{if } x > \frac{1}{n}
\end{cases}$$
This determines the function $F$ :
$$F(X)=\begin{cases}
0, & \text{if } X < 0\\
nX,& \text{if } 0 \leq X \leq \frac{1}{n}\\
1, & \text{if } X > \frac{1}{n}
\end{cases}$$
We use a dummy variable $X$ in order to avoid the confusion between $X=x$ if $t=0$ and $X=(x-ut)$ if $t\neq 0$.
Thus, the solution according to the initial condition is :
$$u(x,t) =
\begin{cases}
0, & \text{if } (x-ut) < 0\\
n(x-ut),& \text{if } 0 \leq (x-ut) \leq \frac{1}{n}\\
1, & \text{if } (x-ut) > \frac{1}{n}
\end{cases}$$
This case is very simple because $u=n(x-ut) \quad\to\quad u=\frac{nx}{1+nt}$
$$\begin{cases}
u=0, & \text{if } x < 0\\
u(x,t)=\frac{nx}{1+nt},& \text{if } 0 \leq \frac{x}{1+nt} \leq \frac{1}{n} \quad \text{ i.e. }\quad 0 \leq x \leq \frac{1}{n}+t\\
u=1, & \text{if } \frac{x}{1+nt} > \frac{1}{n} \quad \text{ i.e. }\quad x> \frac{1}{n}+t
\end{cases}$$
Best Answer
The shock wave starts at the minimal $t$ where for a given point $(x,t)$ there are two solutions to $x=x_0+tu_0(x_0)$, which happens on the line $x=-1+t$ when it is equal for infinitesimal $h$ to $-1+h+t(-1+h)^2=-1+t+h(1-2t+h)$, thus at $t=\frac12$, $x=-\frac12$.
The shock wave follows a curve $x=v(t)$, where the characteristic lines with $v(t)=x_{01}+t$, $x_{01}<-1$ and $v(t)=x_{02}+tx_{02}^2$, $x_{02}\in(-1,0)$ meet, that is,
The Rankine-Hogoniot equation for the speed of the shock now gives \begin{align} v'(t)&=\frac12(1+x_{02}(t)^2)\\ &=(1+2tx_{02})x_{02}'(t)+x_{02}(t)^2 \end{align} Solve this (numerically) for the inverse function $t_s(x)$ with $$ t_s'(x)=1/x_{02}'(t_s(x))=\frac{2(1+2t_s(x)x)}{1-x^2} $$ with initial conditions $t_s(-1)=0.5$ over the interval $[-1,0]$. This now is a linear DE with integrating factor $(1-x^2)^{2}$. Carrying out the integration ends with \begin{align} (1-x^2)^2t_s(x)&=\int 2(1-x^2)\,dx=2x-\frac23x^3+C\\ 0&=-2+\frac23+C\implies C=\frac43\\ t_s(x) &=\frac23\frac{3(x+1)-(x+1)(x^2-x+1)}{(1-x^2)^2} \\ &= \frac{2(2-x)}{3 (1-x)^2} \end{align}
At time $T=t_s(0)=\frac43$ the middle phase has collapsed and the outer phases meet in a shock wave with speed $0.5$.
Constructing the solution picture from the characteristic curves ending at the shock curves gives the plot