Debian Codegraph @

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

raw
1
2 function plotControl()
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 = 3*length(nodes); %% determine number of nodes
7 nt = numel(dir('control.*.txt')); %% determine number of time steps
8
9 %% Read in state
10 Ux = cell(nt,1);
11 Uy = cell(nt,1);
12 for i = 0:nt-1
13 data_obj = importdata(['control.',int2str(i),'.txt'], ' ', 2); %% we need to skip the first two lines
14 state = data_obj.data;
15 data_obj = importdata(['map_control.',int2str(i),'.txt'], ' ', 9); %% we need to skip the first 9 lines
16 map_state = data_obj.data;
17 map_state = map_state(1:2:end)+1;
18 [tmp, state_permute] = sort(map_state);
19 state = state(state_permute); %% we need to permute the state according to parallel maps
20
21 Ux{i+1} = state(1:3:N); %% Extract x-velocity
22 Uy{i+1} = state(2:3:N); %% Extract y-velocity
23 end
24
25 axsize = 400;
26 figure('Position', [100 100 4*axsize 4*axsize]);
27 for i=1:nt-1
28 quiver(nodes(:,1), nodes(:,2), Ux{i+1}, Uy{i+1});
29 axis('equal','tight');
30 xlim([-5,-3]);
31 xlabel('x');
32 ylabel('y');
33 title(['Time/T = ',num2str(i/(nt-1))],'fontsize',16);
34 set(gca, 'FontSize', 16); set(gcf, 'Color', 'White');% tightfig;
35
36 drawnow
37 end