I need to solve the following problem analytically and numerically. Just checking if I have the correct exact solution before I implement my FDM.
I need to solve, $$u_t+u_x=0$$ where $ -1\leq x \leq 3$ $, 0 \leq t \leq 2.4$ and $$u(0,x)= \begin{cases} \cos^2(\pi x), & |x|\leq \frac{1}{2} \\ 0, & \text{otherwise } \end{cases} $$ and $$u(t,-1)=0$$
I used charaeristics to get the general solution as $u(t,x)=f(x-t)$, thus the initial condition provides a particular solution of: $$u(t,x)= \begin{cases} \cos^2(\pi (x-t)), & |x-t|\leq \frac{1}{2} \\ 0, & \text{otherwise } \end{cases} $$
Is this ok? Does the BC impose some other constraint on the solution?