Debian Codegraph @

packages/rol/example/PDE-OPT/thermal-fluids/plotresults_ex04.m

raw
1 printFig = false;
2
3 addpath ~/research/export_fig-master
4
5 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency table, increment by 1 for 1-based indexing
6
7 nodes = load('nodes.txt'); %% load node coordinates
8
9 filenames = {'mean_uncontrolled_state.txt', 'mean_state.txt'};
10 names = {'mean_uncontrolled_','mean_'};
11
12 for i = 1:2
13
14 statefile = filenames{i};
15
16 %% UNCONTROLLED.
17 data_obj = importdata(statefile, ' ', 2); %% we need to skip the first two lines
18 state = data_obj.data;
19
20 n = length(nodes);
21 N = 4*n;
22 % Extract x-velocity
23 Ux = state(1:4:N);
24 % Extract y-velocity
25 Uy = state(2:4:N);
26 % Extract pressure
27 P = state(3:4:N);
28 % Extract temperature
29 T = state(4:4:N);
30
31 figure,
32 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
33 axis equal
34 axis tight
35 set(gca,'XTickLabelMode','manual','XTickLabel',[])
36 set(gca,'YTickLabelMode','manual','YTickLabel',[])
37 if (printFig)
38 print('-depsc2',[names{i},'velocity.eps'])
39 end
40
41 XX = reshape(nodes(:,1),sqrt(n),sqrt(n)).';
42 YY = reshape(nodes(:,2),sqrt(n),sqrt(n)).';
43 UXX = reshape(Ux,sqrt(n),sqrt(n)).';
44 UYY = reshape(Uy,sqrt(n),sqrt(n)).';
45 PP = reshape(P,sqrt(n),sqrt(n)).';
46 TT = reshape(T,sqrt(n),sqrt(n)).';
47
48 figure, streamslice(XX,YY,UXX,UYY)
49 axis equal
50 axis tight
51 set(gca,'XTickLabelMode','manual','XTickLabel',[])
52 set(gca,'YTickLabelMode','manual','YTickLabel',[])
53 if (printFig)
54 print('-depsc2',[names{i},'velocity_vort.eps'])
55 end
56
57 figure,
58 trisurf(adj, nodes(:,1), nodes(:,2), P);
59 shading interp;
60 view(0,90)
61 axis equal
62 axis tight
63 set(gca,'XTickLabelMode','manual','XTickLabel',[])
64 set(gca,'YTickLabelMode','manual','YTickLabel',[])
65 set(gcf,'color','white')
66 if (printFig)
67 export_fig([names{i},'pressure'],'-png','-painters','-m3','-a3');
68 end
69
70 figure,
71 contourf(XX,YY,PP,15)
72 axis equal
73 axis tight
74 set(gca,'XTickLabelMode','manual','XTickLabel',[])
75 set(gca,'YTickLabelMode','manual','YTickLabel',[])
76 set(gcf,'color','white')
77 if (printFig)
78 export_fig([names{i},'pressure_contour'],'-png','-painters','-m3','-a3');
79 end
80
81 figure,
82 trisurf(adj, nodes(:,1), nodes(:,2), T);
83 shading interp;
84 view(0,90)
85 axis equal
86 axis tight
87 set(gca,'XTickLabelMode','manual','XTickLabel',[])
88 set(gca,'YTickLabelMode','manual','YTickLabel',[])
89 set(gcf,'color','white')
90 if (printFig)
91 export_fig([names{i},'temperature'],'-png','-painters','-m3','-a3');
92 end
93
94 figure,
95 contourf(XX,YY,TT,15)
96 axis equal
97 axis tight
98 set(gca,'XTickLabelMode','manual','XTickLabel',[])
99 set(gca,'YTickLabelMode','manual','YTickLabel',[])
100 set(gcf,'color','white')
101 if (printFig)
102 export_fig([names{i},'temperature_contour'],'-png','-painters','-m3','-a3');
103 end
104
105 end
106
107 data_obj = importdata('control.txt', ' ', 2); %% we need to skip the first two lines
108 control = data_obj.data;
109
110 % Extract x-velocity
111 Zx = control(1:4:N);
112 % Extract y-velocity
113 Zy = control(2:4:N);
114 % Extract pressure
115 P = control(3:4:N);
116 % Extract Temperature
117 T = control(4:4:N);
118
119 Xmin = min(nodes(:,2));
120 Xmax = max(nodes(:,2));
121
122 figure,
123 idx = find(nodes(:,1) == 0.0);
124 plot(nodes(idx,2), T(idx));
125 title('Left Controls')
126 xlim([Xmin,Xmax]);
127 if (printFig)
128 print('-depsc2','left_control.txt');
129 end
130
131 figure,
132 idx = find(nodes(:,1) == 1.0);
133 plot(nodes(idx,2), T(idx));
134 title('Right Controls')
135 xlim([Xmin,Xmax]);
136 if (printFig)
137 print('-depsc2','right_control.txt');
138 end