Debian Codegraph @

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

raw
1 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency table, increment by 1 for 1-based indexing
2
3 nodes = load('nodes.txt'); %% load node coordinates
4
5 data_obj = importdata('state.txt', ' ', 2); %% we need to skip the first two lines
6 state = data_obj.data;
7 data_obj = importdata('map_state.txt', ' ', 9); %% we need to skip the first 9 lines
8 map_state = data_obj.data;
9 map_state = map_state(1:2:end)+1;
10 [tmp, state_permute] = sort(map_state);
11 state = state(state_permute); %% we need to permute the state according to parallel maps
12
13 N = 3*length(nodes);
14 % Extract x-velocity
15 Ux = state(1:3:N);
16 % Extract y-velocity
17 Uy = state(2:3:N);
18 % Extract pressure
19 P = state(3:3:N);
20
21 figure,
22 trisurf(adj, nodes(:,1), nodes(:,2), Ux);
23 shading interp;
24 view(0,90)
25 axis equal
26 axis tight
27
28 figure,
29 trisurf(adj, nodes(:,1), nodes(:,2), Uy);
30 shading interp;
31 view(0,90)
32 axis equal
33 axis tight
34
35 figure,
36 trisurf(adj, nodes(:,1), nodes(:,2), sqrt(Ux.^2 + Uy.^2));
37 shading interp;
38 view(0,90)
39 axis equal
40 axis tight
41
42 figure,
43 trisurf(adj, nodes(:,1), nodes(:,2), P);
44 shading interp;
45 view(0,90)
46 axis equal
47 axis tight
48
49 figure,
50 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
51 axis equal
52 axis tight
53
54 data_obj = importdata('control.txt', ' ', 2); %% we need to skip the first two lines
55 control = data_obj.data;
56 data_obj = importdata('map_control.txt', ' ', 9); %% we need to skip the first 9 lines
57 map_control = data_obj.data;
58 map_control = map_control(1:2:end)+1;
59 [tmp, control_permute] = sort(map_control);
60 control = control(control_permute); %% we need to permute the control according to parallel maps
61
62 % Extract x-velocity
63 Zx = control(1:3:N);
64 % Extract y-velocity
65 Zy = control(2:3:N);
66 % Extract pressure
67 P = control(3:3:N);
68
69 figure,
70 trisurf(adj, nodes(:,1), nodes(:,2), Zx);
71 shading interp;
72 view(0,90)
73 axis equal
74 axis tight
75
76 figure,
77 trisurf(adj, nodes(:,1), nodes(:,2), Zy);
78 shading interp;
79 view(0,90)
80 axis equal
81 axis tight
82
83 figure,
84 trisurf(adj, nodes(:,1), nodes(:,2), P);
85 shading interp;
86 view(0,90)
87 axis equal
88 axis tight
89
90 figure,
91 quiver(nodes(:,1), nodes(:,2), Zx, Zy);
92 axis equal
93 axis tight
94
95 figure,
96 idx = find((nodes(:,1) == 1) .* (nodes(:,2) <= 0.5));
97 ZX = zeros(size(Zx)); ZX(idx) = Zx(idx);
98 ZY = zeros(size(Zy)); ZY(idx) = Zy(idx);
99 quiver(nodes(:,1), nodes(:,2), ZX, ZY);
100 axis equal
101 axis tight
102 xlim([0.6,1.2]);
103 ylim([-0.2,0.7]);
104
105 figure,
106 idx = find((nodes(:,1) == 1) .* (nodes(:,2) <= 0.5));
107 UX = zeros(size(Ux)); UX(idx) = Ux(idx);
108 UY = zeros(size(Uy)); UY(idx) = Uy(idx);
109 quiver(nodes(:,1), nodes(:,2), UX, UY);
110 axis equal
111 axis tight
112 xlim([0.6,1.2]);
113 ylim([-0.2,0.7]);