I am trying to solve the 1D wave equation. When I am trying to plot the approximated solution I am getting a straight line. Can anyone please check what is wrong with the plot command.
As I am unable to attach the edp file, I am pasting the code here.
// Problem definition
//1d pde on the boundary term u_t=u_{xx} 0<x<1, 0<t<1
// u(x,0)=sin(pi*x)
// u(0,t)=0,u(1,t)=0
verbosity=0;
macro uex(t) (sin(pi*x)exp(t))// Exact Solution
macro f(t) (sin(pix)exp(t)(pi^2+1))//Source Function
int nref=2;
real[int] L2error(nref); // initialize the L2 error array
real[int] Dx(nref); // initialize the space discretization array
real[int] DT(nref); // initialize the time discretization array
for(int n=0; n<nref;n++) {
int R=2^(n+3);// grid points on x-interval [0,1]
real h=1./R;
Dx[n]=h;
real dt=h^2;
DT[n]=dt;
real t, T=1;
// Technical data to recreate OX and OY axis
border OX(t=0,1){x=t;y=0;}
border OY(t=0,1){x=0;y=t;}
meshL Th=segment(R);
plot(Th, cmm="NO ADAPTED MESH ",wait=0);//,ps=“reactiondiffusionnoadapted2dmesh.eps”);
fespace Uh(Th,P1);
Uh u, v, uold;
u=sin(pi*x);// initial condition
problem Wave(u,v)=int1d(Th)(u*v/dt+dx(u)dx(v))
-int1d(Th)(uoldv/dt)
-int1d(Th)(f(t+dt/2.)*v)
+on(1,2,u=0);
// time loop
int m, M = T/dt;
for (m = 0; m < M; m++) {
uold=u;
Wave;
t+=dt;
plot(u,cmm=“Wave Equation Appox soln. u at time t=”+t,wait=0,value=1);
}// end of time loop
L2error[n]=sqrt(int1d(Th)(abs(u-uex(t))^2));
cout << "L2 error " << L2error[n] << endl;
}// end of loop on n<nref