Debian Codegraph @

packages/rol/example/PDE-OPT/topo-opt/navier-stokes/plotresults.m

raw
1 saveplot = false;
2
3 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency table, increment by 1 for 1-based indexing
4
5 nodes = load('nodes.txt'); %% load node coordinates
6
7 data_obj = importdata('state.txt', ' ', 2); %% we need to skip the first two lines
8 state = data_obj.data;
9 data_obj = importdata('map_state.txt', ' ', 9); %% we need to skip the first 9 lines
10 map_state = data_obj.data;
11 map_state = map_state(1:2:end)+1;
12 [tmp, state_permute] = sort(map_state);
13 state = state(state_permute); %% we need to permute the state according to parallel maps
14
15 N = 3*length(nodes);
16 % Extract x-velocity
17 Ux = state(1:3:N);
18 % Extract y-velocity
19 Uy = state(2:3:N);
20 % Extract pressure
21 P = state(3:3:N);
22
23 figure,
24 trisurf(adj, nodes(:,1), nodes(:,2), Ux);
25 shading interp;
26 title('X-Velocity')
27 view(0,90)
28 axis equal
29 axis tight
30 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
31 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
32 %set(gca,'Visible','off')
33 set(gcf,'color','white')
34 colormap(jet), colorbar
35 if saveplot, export_fig('velocity_x','-png','-painters','-m3','-a3'), end;
36
37 figure,
38 trisurf(adj, nodes(:,1), nodes(:,2), Uy);
39 shading interp;
40 title('Y-Velocity')
41 view(0,90)
42 axis equal
43 axis tight
44 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
45 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
46 %set(gca,'Visible','off')
47 set(gcf,'color','white')
48 colormap(jet), colorbar
49 if saveplot, export_fig('velocity_y','-png','-painters','-m3','-a3'), end;
50
51 figure,
52 trisurf(adj, nodes(:,1), nodes(:,2), sqrt(Ux.^2 + Uy.^2));
53 shading interp;
54 title('Speed')
55 view(0,90)
56 axis equal
57 axis tight
58 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
59 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
60 %set(gca,'Visible','off')
61 set(gcf,'color','white')
62 colormap(jet), colorbar
63 if saveplot, export_fig('speed','-png','-painters','-m3','-a3'), end;
64
65 figure,
66 trisurf(adj, nodes(:,1), nodes(:,2), P);
67 shading interp;
68 title('Pressure')
69 view(0,90)
70 axis equal
71 axis tight
72 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
73 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
74 %set(gca,'Visible','off')
75 set(gcf,'color','white')
76 colormap(jet), colorbar
77 if saveplot, export_fig('pressure','-png','-painters','-m3','-a3'), end;
78
79 figure,
80 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
81 title('Velocity Quiver Plot')
82 axis equal
83 axis tight
84 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
85 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
86 %set(gca,'Visible','off')
87 set(gcf,'color','white')
88 if saveplot, print('-depsc2','velocity.eps'), end
89
90 ztol = 1e-8;
91 ind =( (nodes(:,2)>-ztol) & (nodes(:,2)<ztol) );
92 [X,ord] = sort(nodes(ind,1),'ascend');
93 UX = Ux(ind);
94 UX = UX(ord);
95 UY = Uy(ind);
96 UY = UY(ord);
97 figure, plot(X,UX,'linewidth',2)
98 title('X-Velocity at Target Surface')
99 axis('tight')
100 set(gcf,'color','white')
101 pbaspect([3 1 1])
102 if saveplot, print('-depsc2','velocity_x_out.eps'), end
103
104 figure, plot(X,UY,'linewidth',2)
105 title('Y-Velocity at Target Surface')
106 axis('tight')
107 set(gcf,'color','white')
108 pbaspect([3 1 1])
109 if saveplot, print('-depsc2','velocity_y_out.eps'), end
110
111 data_obj = importdata('control.txt', ' ', 2); %% we need to skip the first two lines
112 control = data_obj.data;
113 data_obj = importdata('map_control.txt', ' ', 9); %% we need to skip the first 9 lines
114 map_control = data_obj.data;
115 map_control = map_control(1:2:end)+1;
116 [tmp, control_permute] = sort(map_control);
117 control = control(control_permute); %% we need to permute the control according to parallel maps
118
119 % Extract x-velocity
120 Zx = control(1:3:N);
121 % Extract y-velocity
122 Zy = control(2:3:N);
123 % Extract pressure
124 P = control(3:3:N);
125
126 figure,
127 trisurf(adj, nodes(:,1), nodes(:,2), P);
128 shading interp;
129 title('Porosity')
130 view(0,90)
131 axis equal
132 axis tight
133 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
134 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
135 %set(gca,'Visible','off')
136 set(gcf,'color','white')
137 colormap(flipud(jet)), colorbar
138 if saveplot, export_fig('density','-png','-painters','-m3','-a3'), end;
139
140 a0 = 0;
141 a1 = 750;
142 q = 10;
143 figure,
144 trisurf(adj, nodes(:,1), nodes(:,2), a0 + (a1-a0)*q*(1-P)./(q+P));
145 shading interp;
146 title('Impermeability')
147 view(0,90)
148 axis equal
149 axis tight
150 %set(gca,'XTickLabelMode','manual','XTickLabel',[])
151 %set(gca,'YTickLabelMode','manual','YTickLabel',[])
152 %set(gca,'Visible','off')
153 set(gcf,'color','white')
154 colormap(jet), colorbar