8748c66added codenalhassanieh 1function plotHeatMap(u,ue,x,tn,s,figFile,order,tFinal,prechar,savePlot,solnType,logScale,dataFile)
2% PLOTHEATMAP plots a heatmap of a given solution u(x,t)
3%
4% plotHeatMap(u,ue,x,tn,figFile,order,tFinal,prechar,savePlot)
5% returns a heatmap of u with respect to x and t given discrete 'x' grid
6% and 'tn' time grid. 'figFile' is the file where the figure will be
7% saved, 'order' and 'tFinal' are needed to record the order of accuracy
8% and the final time in the file name. 'prechar' is a character used to
9% precede the file name if needed for special cases. 'savePlot' = 1 to
10% save plot in the given figFile. 'solnType' type of testing solution used
11% ms (manufactured solution), true (true scattering example).
13M = length(s);
15colormap(jet(256));
17figure(1);
18if(strcmp(solnType,'ms'))
19 if(logScale == 1)
20 U = log10(abs(u))';
21 climInt = [-12 0];
22 solTitle = 'log_{10}|u(x,t)|';
23 else
24 U = abs(u)';
25 climInt = [0 0.5];
26 solTitle = '|u(x,t)|';
27 end
28 imagesc(x,tn,U); hold on;
29 plot(s,0,'|r','MarkerSize',10); hold off;
30 axis xy; clim(climInt);
31 xlabel x; ylabel t; colorbar; title(sprintf('M = %d, order = %d, $%s$',M,order,solTitle));
32else % in this case ue = u_incident
33 if(logScale == 1)
34 U = log10(abs(u + ue))';
35 climInt = [-12 0];
36 solTitle = 'log_{10}|u_{tot}(x,t)|';
37 else
38 % U = abs(u + ue)';
39 % climInt = [0 0.05];
40 % solTitle = '|u_{tot}(x,t)|';
42 U = (u + ue)';
43 climInt = [-0.005 0.005];
44 solTitle = 'u_{tot}(x,t)';
45 end
46 imagesc(x,tn,U); hold on;
47 plot(s,0,'|r','MarkerSize',10);
48 % xline(s,'--r');
49 hold off;
50 axis xy; clim(climInt);
51 xlabel x; ylabel t; colorbar; title(sprintf('M = %d, order = %d, $%s$',M,order,solTitle));
52end
54if(savePlot == 1)
55 fileName = sprintf('%s/%sDSheatmap%d_%d_%d',figFile,prechar,order,round(tFinal),M);
56 print(fileName,'-depsc');
58 fileName2 = sprintf('%s/%sDSheatmapDATA%d_%d_%d',dataFile,prechar,order,round(tFinal),M);
59 save(fileName2);
60end
62% plot the heatmap of the error
63if(strcmp(solnType,'ms'))
64 figure(2);
65 imagesc(x,tn,log10(abs(u-ue))'); axis xy; clim([-12 0]); hold on;
66 plot(s,0,'|r','MarkerSize',10); hold off;
67 xlabel x; ylabel t; colorbar; title(sprintf('M = %d, order = %d, log_{10}|u(x,t)-u_e(x,t)|',M,order));
69 if(savePlot == 1)
70 fileName = sprintf('%s/%sDSheatmap%d_%d_%d',figFile,prechar,order,round(tFinal),M);
71 print(fileName,'-depsc');
72 end
73end
75end