Debian Codegraph @

packages/rol/example/PDE-OPT/dynamic/thermal-fluids/plotFlow.m

raw
1
2 function plotFlow(name)
3
4 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency, increment by 1 for 1-based indexing
5 nodes = load('nodes.txt'); %% load node coordinates
6 N = 4*length(nodes); %% determine number of nodes
7 nt = numel(dir([name,'.*.txt'])); %% determine number of time steps
8
9 %% Read in state
10 Ux = cell(nt,1);
11 Uy = cell(nt,1);
12 Um = cell(nt,1);
13 P = cell(nt,1);
14 T = cell(nt,1);
15 for i = 0:nt-1
16 data_obj = importdata([name,'.',int2str(i),'.txt'], ' ', 2); %% we need to skip the first two lines
17 state = data_obj.data;
18 data_obj = importdata(['map_',name,'.',int2str(i),'.txt'], ' ', 9); %% we need to skip the first 9 lines
19 map_state = data_obj.data;
20 map_state = map_state(1:2:end)+1;
21 [tmp, state_permute] = sort(map_state);
22 state = state(state_permute); %% we need to permute the state according to parallel maps
23
24 Ux{i+1} = state(1:4:N); %% Extract x-velocity
25 Uy{i+1} = state(2:4:N); %% Extract y-velocity
26 Um{i+1} = sqrt(Ux{i+1}.^2+Uy{i+1}.^2);
27 P{i+1} = state(3:4:N); %% Extract pressure
28 T{i+1} = state(4:4:N); %% Extract temperature
29 end
30
31 minUx = min(min([Ux{:}])); maxUx = max(max([Ux{:}]));
32 minUy = min(min([Uy{:}])); maxUy = max(max([Uy{:}]));
33 minUm = min(min([Um{:}])); maxUm = max(max([Um{:}]));
34 minP = min(min([P{:}])); maxP = max(max([P{:}]));
35 minT = min(min([T{:}])); maxT = max(max([T{:}]));
36
37 axsize = 400;
38 figure('Position', [100 100 4*axsize 4*axsize]);
39 for i=1:nt-1
40 subplot(3,2,1)
41 quiver(nodes(:,1), nodes(:,2), Ux{i+1}, Uy{i+1});
42 axis('equal','tight');
43 xlabel('x');
44 ylabel('y');
45 title(['Time/T = ',num2str(i/(nt-1))],'fontsize',16);
46 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
47
48 subplot(3,2,2)
49 trisurf(adj, nodes(:,1), nodes(:,2), Um{i+1});
50 shading interp;
51 view(0,90)
52 axis('equal','tight');
53 xlabel('x');
54 ylabel('y');
55 caxis([minUm,maxUm])
56 title('Velocity Magnitude','fontsize',16);
57 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
58
59 subplot(3,2,3)
60 trisurf(adj, nodes(:,1), nodes(:,2), Ux{i+1});
61 shading interp;
62 view(0,90)
63 axis('equal','tight');
64 xlabel('x');
65 ylabel('y');
66 caxis([minUx,maxUx])
67 title('x-Velocity','fontsize',16);
68 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
69
70 subplot(3,2,4)
71 trisurf(adj, nodes(:,1), nodes(:,2), T{i+1});
72 shading interp;
73 view(0,90)
74 axis('equal','tight');
75 xlabel('x');
76 ylabel('y');
77 caxis([minT,maxT])
78 title('Temperature','fontsize',16);
79 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
80
81 subplot(3,2,5)
82 trisurf(adj, nodes(:,1), nodes(:,2), Uy{i+1});
83 shading interp;
84 view(0,90)
85 axis('equal','tight');
86 xlabel('x');
87 ylabel('y');
88 caxis([minUy,maxUy])
89 title('y-Velocity','fontsize',16);
90 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
91
92 subplot(3,2,6)
93 trisurf(adj, nodes(:,1), nodes(:,2), P{i+1});
94 shading interp;
95 view(0,90)
96 axis('equal','tight');
97 xlabel('x');
98 ylabel('y');
99 %caxis([minP,maxP])
100 title('Pressure','fontsize',16);
101 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
102
103 drawnow
104 end