# Creating a linear FEM method for the one-dimensional advection equation.

Some help on this question is greatly appreciated.

Consider the PDE $u_t + a u_x=0$ for $a>0$. Suppose the problem is on the interval $[ \alpha , \beta]$ with $u(0,x)=u_0(x)$. Suppose further that $u(\alpha) = u(\beta)=0$. Derive a FEM approximation on a uniform h-spaced mesh.

First, multiply the PDE by a test function $v$ and use integration by parts to obtain

$$\int_\alpha ^\beta v (u_t + au_x) dx = \int_\alpha ^ \beta vu_t + auv \Big\vert_\alpha^\beta - \int_\alpha ^\beta a uv_x dx =0$$

The boundary conditions allow us to write this as

$$\int_\alpha ^ \beta vu_t - \int_\alpha ^\beta a uv_x dx =0.$$

Consider a basis for our approximation $\phi_j \left(t\right)$

$${\varphi _j}\left( x \right) = \left\{ {\begin{array}{*{20}{c}}{\frac{{x - {x_{j - 1}}}}{h}}&{,x \in [{x_{j - 1}},{x_j}]}\\{\frac{{{x_{j + 1}} - x}}{h}}&{,x \in [{x_j},{x_{j + 1}}]}\\0&{,x \notin [{x_{j - 1}},{x_{j + 1}}]}\end{array}} \right. , j=2,\cdots ,N-1$$.

Then, the approximation $U(x) = c_{j-1}(t) \phi_{j-1}(x) + c_j(t) \phi_j(x)$ for $x \in [x_{j-1},x_j]$.

I'm not really sure how to proceed from here. The question asks to show the scheme is given by

$$\dfrac{d}{dt} \left( c_{j-1} + 4 c_j + c_{j+1} \right) + \dfrac{3}{h} \left( c_{j+1} - c_{j-1} \right)=0$$.

Taking the test fuction as the basi function $\varphi_j(x)$, we have: $$\int_\alpha^\beta {\varphi_j \, U_t} \, dx -\int_\alpha^\beta {a \, U \, \frac{d\varphi_j}{dx} } \, dx = 0.$$ Note that $\text{supp}(\varphi_j) = [x_{j-1}, \, x_{j+1}]$. Thus, $$\int_\alpha^\beta {\varphi_j \, U_t} \, dx -\int_\alpha^\beta {a \, U \, \frac{d\varphi_j}{dx} } \, dx = \int_{x_{j-1}}^{x_{j+1}} {\varphi_j \, U_t} \, dx -\int_{x_{j-1}}^{x_{j+1}} {a \, U \, \frac{d\varphi_j}{dx} } \, dx.$$ We can split the integrations, $$\int_{x_{j-1}}^{x_{j}} {\varphi_j \, U_t} \, dx + \int_{x_{j}}^{x_{j+1}} {\varphi_j \, U_t} \, dx -\int_{x_{j-1}}^{x_{j}} {a \, U \, \frac{d\varphi_j}{dx} } \, dx -\int_{x_{j}}^{x_{j+1}} {a \, U \, \frac{d\varphi_j}{dx} } \, dx = 0,$$ and write the approximation $U(x,t)$ into each interval, $$\int_{x_{j-1}}^{x_{j}} {\varphi_j \, \frac{d}{dt} \bigg( c_{j-1}(t)\varphi_{j-1}(x) + c_{j}(t)\varphi_{j}(x)\bigg)} \, dx + \int_{x_{j}}^{x_{j+1}} {\varphi_j \, \frac{d}{dt} \bigg( c_{j}(t)\varphi_{j}(x) + c_{j+1}(t)\varphi_{j+1}(x)\bigg)} \, dx -\int_{x_{j-1}}^{x_{j}} {a \, \bigg( c_{j-1}(t)\varphi_{j-1}(x) + c_{j}(t)\varphi_{j}(x)\bigg) \, \frac{d\varphi_j}{dx} } \, dx -\int_{x_{j}}^{x_{j+1}} {a \, \bigg( c_{j}(t)\varphi_{j}(x) + c_{j+1}(t)\varphi_{j+1}(x)\bigg) \, \frac{d\varphi_j}{dx} } \, dx = 0.$$ Then, by solving the integrations, we obtain: $$\frac{h}{6}\frac{d}{dt}(c_{j-1}+4c_j+c_{j+1}) - \frac{a}{2}(c_{j-1}-c_{j+1}) = 0,$$ or, equivalently, $$\frac{d}{dt}(c_{j-1}+4c_j+c_{j+1}) + \frac{3a}{h}(c_{j+1}-c_{j-1}) = 0.$$