Gravity dominated flow in porous medium I have the following equation modelling flow in a porous medium modeled by
$$
(u^2)_x+u_t=0, \hspace{15pt}x>0,\hspace{5pt}t>0
$$
I have the initial condition:
$$
u(x,0)=\frac{1}{2}, \hspace{15pt}x>0
$$
And a boundary condition
$$
u(0,t) = g(t) = \begin{cases}
                  1,&0<t<1\\
                  \frac{1}{2},&t>1
                \end{cases}
$$
I know that I need to use the method of characteristics here, but the two conditions have me confused, as I'm not sure how to consider the initial condition. I end up getting base characteristics of $t=\xi + \tau$, and $x=2g(\tau)\xi$ from the boundary condition, which give me something like,
$$
u(x,t) = g(t) = \begin{cases}
                  1,&\frac{1}{2}x<t<1+\frac{1}{2}x\\
                  \frac{1}{2},&t>1+x
                \end{cases}
$$
But this can't possibly be right because I haven't even considered the initial condition! Starting from the initial condition, I get, $t=\tau$ and $x=2f(\xi)\tau + \xi$, but then I don't know how to consider the boundary data.
 A: You are almost there.  The two pieces $t=0$ and $x=0$ made up our Cauchy boundary conditions in this case, so you really need to use both to get (almost) the entire domain $x>0,t>0$.
By method of characteristic, the parametric equation for the characteristic curve is
$$
(t,x,u)(\tau)=(t_0+\tau,x_0+2u_0\tau,u_0).
$$
Now we impose the initial (in $\tau$) condition
$$
u_0=u(x_0,t_0)
=\begin{cases}
\frac12 & t_0=0\\
g(t_0) & x_0=0
\end{cases}
$$
and so
$$
u(x,t)=\begin{cases}
1 & \frac12x<t<1+\frac12x\\
\frac12 & t>1+x \text{ or }t<\frac12x.
\end{cases}
$$
A: Let us use the method of characteristics and draw the base characteristic lines in the $x$-$t$ plane:

The base characteristics issued from the initial condition $t=0$ and from the boundary $x=0$ intersect in the vicinity of $(x,t)=(0,0)$: a shock wave is generated. The speed of shock $s$ is given by the Rankine-Hugoniot condition
$s = 1 + \frac12 = \frac{3}{2}$.
In the vicinity of $(0,1)$, characteristics separate: a rarefaction wave is generated. According to the characteristic speed $2u$, its shape is $\tfrac12 x/t$.
The rest of the solution is deduced from the characteristics. For small positive times and positive positions, the admissible solution is
$$
u(x,t) = \left\lbrace
\begin{aligned}
&\tfrac12 &&\text{if}\quad x > \tfrac32 t \\
&1 &&\text{if}\quad x < \tfrac32 t
\end{aligned}\right.
$$
for $0\leq t<1$, and
$$
u(x,t) = \left\lbrace
\begin{aligned}
&\tfrac12 &&\text{if}\quad x\leq t-1 \quad\text{or}\quad x > \tfrac32 t \\
&\tfrac12 \tfrac{x}{t-1} &&\text{if}\quad t-1 < x\leq 2(t-1) \\
&1 &&\text{if}\quad 2(t-1) \leq x < \tfrac32 t
\end{aligned}\right.
$$
for times $t$ larger than one.
One notes that this solution is valid until $\tfrac32 t = 2(t-1)$, i.e. $t=4$. At $(x,t)=(6,4)$, one must compute the interaction of the rarefaction and the shock. On the left, we have $u = \tfrac12 x/(t-1)$, while we have $u = \tfrac12$ on the right. The Rankine-Hugoniot condition gives the shock trajectory $t\mapsto x_s(t)$ as
$$
x'_s(t) = \frac12 \left( \frac{x_s(t)}{t-1} + 1\right) ,
$$
with the initial condition $x_s(4) = 6$. Hence, the shock path is
$
x_s(t) =  t-1 + \sqrt{3(t-1)}
$,
and the entropy solution for $t\geq 4$ is
$$
u(x,t) = \left\lbrace
\begin{aligned}
&\tfrac12 &&\text{if}\quad x\leq t-1 \quad\text{or}\quad x > x_s(t) \\
&\tfrac12 \tfrac{x}{t-1} &&\text{if}\quad t-1\leq x < x_s(t) \, .
\end{aligned}\right.
$$
