rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
porsche_plot.m
1 function p = porsche_plot(model,model_data,sim_data,step)
2 %
3 %
4 %function plot_porsche_mit_sim_data(model,model_data,sim_data,step)
5 %
6 % function plotting the solution of the PDE on the reference or the original
7 % porsche domain or plotting gradient and pressure on the porsche domain
8 % by interpolating the given gradients on a regular grid and cutting out
9 % those parts, that ly inside the porsche. This depends on the value of
10 % step:
11 % 1: plotting the solution on the reference domain
12 % 2: plotting the solution on the reshaped/original domain
13 % 3: plotting velocity and pressure on the reference domain
14 % 4: plotting velocity and pressure on the reshaped/original domain
15 %
16 %
17 % input:
18 % model
19 % model_data
20 % sim_data
21 %
22 % needed fields of model:
23 % - xrange, yrange: defining the box
24 % - cp: list of the car points
25 %
26 % needed fields of model_data:
27 % - model_data.microgrid
28 % - pdetoolbox_mesh.p
29 % - model_data.pdetoolbox_mesh.e
30 % - model_data.pdetoolbox_mesh.t
31 % --> p, e, t exported from pdetoolbox, containing the grid information
32 %
33 % needed fields of sim_data (only for step 3 and 4)
34 % - gradx: n-by-1 vector with the x component of the gradient of
35 % the solution of the potential flow equation
36 % n must be the number of vertices in the grid
37 % - grady: see gradx
38 % - pressure: n-by-1-vector with the values of the pressure correspnding to
39 % the vertices in the grid
40 %
41 % Oliver Zeeb, 16.02.11
42 
43 
44 
45 
46 switch step
47  case 1 %plot the solution on the reference domain
48  lin_stat_plot_sim_data(model,model_data,sim_data);
49  axis equal;
50  title('solution on the reference domain');
51 
52 
53  case 2
54  sim_data_work=sim_data;
55  sim_data_work.uh=copy(sim_data.uh);
56  sim_data_work.uh.grid=grid_reshape(model, sim_data_work.uh.grid);
57  lin_stat_plot_sim_data(model,model_data,sim_data_work);
58  title('solution on the original domain');
59  axis equal;
60 
61 
62 
63  case 3
64  %%% Interpolate to a regular grid %%%
65  xi = linspace(model.xrange(1),model.xrange(2),17); % Interpolation points x
66  yi = linspace(model.yrange(1),model.yrange(2),20); % Interpolation points y
67  [XI,YI] = meshgrid(xi,yi);
68  gradxI = griddata(model_data.grid.X, model_data.grid.Y, sim_data.gradx, XI, YI);
69  gradyI = griddata(model_data.grid.X, model_data.grid.Y, sim_data.grady, XI, YI);
70 
71  %check, which points are in the car, do not plot velocity arrows there!
72  IN=inpolygon(XI,YI,model.cp(:,1),model.cp(:,2));
73  XI(IN)=[];
74  YI(IN)=[];
75  gradxI(IN)=[];
76  gradyI(IN)=[];
77 
78  % plot with pdeplot
79  p = model_data.pdetoolbox_mesh.p;
80  e = model_data.pdetoolbox_mesh.e;
81  t = model_data.pdetoolbox_mesh.t;
82  figure
83  pdeplot(p,e,t,'xydata',sim_data.pressure,'mesh','off')
84  axis equal
85  hold on
86  quiver(XI,YI,gradxI,gradyI)
87  colormap(jet)
88  title('pressure and velocity, reference domain')
89 
90 
91  case 4
92  %%% Interpolate to a regular grid %%%
93  xi = linspace(model.xrange(1),model.xrange(2),17); % Interpolation points x
94  yi = linspace(model.yrange(1),model.yrange(2),20); % Interpolation points y
95  [XI,YI] = meshgrid(xi,yi);
96  gradxI = griddata(model_data.grid.X, model_data.grid.Y, sim_data.gradx, XI, YI);
97  gradyI = griddata(model_data.grid.X, model_data.grid.Y, sim_data.grady, XI, YI);
98 
99  %transform the ppoints before checking which velocity arrows to
100  %plot
101  cp_trafo=points_trafo(model,model.cp);
102 
103  %check, which points are in the car, do not plot velocity arrows there!
104  IN=inpolygon(XI,YI,cp_trafo(:,1),cp_trafo(:,2));
105  %IN=inpolygon(XI,YI,model.cp(:,1),model.cp(:,2));
106  XI(IN)=[];
107  YI(IN)=[];
108  gradxI(IN)=[];
109  gradyI(IN)=[];
110 
111  % plot with pdeplot
112  p = model_data.pdetoolbox_mesh.p;
113  e = model_data.pdetoolbox_mesh.e;
114  t = model_data.pdetoolbox_mesh.t;
115  pts_transformed = points_trafo(model,p')';
116  figure
117  pdeplot(pts_transformed,e,t,'xydata',sim_data.pressure,'mesh','off')
118  axis equal
119  hold on
120  quiver(XI,YI,gradxI,gradyI)
121  colormap(jet)
122  title('pressure and velocity, reshaped domain')
123 
124  otherwise
125  error('unknown step!');
126 end
127 p='dummy';