r: right hand side of inviscid Burgers equation
function rhs(nx,dx,u,r)
f = Array{Float64}(undef,nx) # flux at the nodal points
fP = Array{Float64}(undef,nx) # positive part of flux at the nodal points
fN = Array{Float64}(undef,nx) # negative part of flux at the nodal~points
ps = Array{Float64}(undef,nx) # wave speed at nodal~points
fL = Array{Float64}(undef,nx+1) # left side flux at the interface
fR = Array{Float64}(undef,nx+1) # right side flux at the~interface
for i = 1:nx
f[i] = 0.5*u[i]*u[i] # compute flux
end
wavespeed(nx,u,ps) # call function to compute the~Jacobian
for i = 1:nx
fP[i] = 0.5*(f[i] + ps[i]*u[i]) # split the flux
fN[i] = 0.5*(f[i] - ps[i]*u[i])
end