pde2=function(t,u,parms){ # # Function pde2 computes the t derivative vector for # the linear advection equation # # BC # # Positive v if(v>0){u[1]=ua2(xl,t,v);} # # Negative v if(v<0){u[n]=ua2(xu,t,v);} # # Spatial differentiator for ux if(ncase==1){ux=dss004(xl,xu,n,u);} if(ncase==2){ux=dss008(xl,xu,n,u);} if(ncase==3){ux=dss012(xl,xu,n,u,v);} if(ncase==4){ux=dss020(xl,xu,n,u,v);} if(ncase==5){ux= vanl(xl,xu,n,u,v);} if(ncase==6){ux=super(xl,xu,n,u,v);} if(ncase==7){ux=smart(xl,xu,n,u,v);} # # PDE ut=rep(0,n); # # Positive v if(v>0){ ut[1]=0; for(i in 2:n){ ut[i]=-v*ux[i]; } } # # Negative v if(v<0){ ut[n]=0; for(i in 1:(n-1)){ ut[i]=-v*ux[i]; } } # # Increment calls to pde_2 ncall<<-ncall+1; # # Return derivative vector return(list(c(ut))); }