I am solving the 1D advection problem given by:
$$\frac{\partial u}{\partial t}=-c\frac{\partial u}{\partial x}$$
where c is the wave speed, and u is the unknown field variable, and x and t are time and space. I am using central differencing to discretise in space. My initial $u$ profile which is being convected is a step profile given by
$u\left(x,t\right)=\left\{ \begin{array}{c} 1\; for\;0<x<1\\ 0\; for\;1<x<2 \end{array}\right.,$
My question is about the boundary conditions. A the moment at the boundaries, if c>0 I have set $u_L=u(1,t)$ (where u(1) is the value of u at the first node), but I end up with a lot of oscillations at the BC.
I have also tried setting $u_L=1$ and $u_R=0$ (R indicates right and L left) and that gives me oscillations too but more sensible ones. I know that with central differencing spurious oscillations are expected but I am not sure about the correct boundary conditions and I would appreciate some help. I searched online for a clear answer but was unsuccessful.
I have also solved the problem with upwinding and by setting $u_L=u(1)$ if c>0 which seems to have worked.
Thank you.