Debian Codegraph @

packages/rol/example/PDE-OPT/navier-stokes/plotexample02.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 filenames = {'mean_state.txt', 'state_m1_m1.txt', 'state_m1_p1.txt', 'state_p1_m1.txt', 'state_p1_p1.txt'};
6
7 for i=1:5
8
9 statefile = filenames{i};
10
11 data_obj = importdata(statefile, ' ', 2); %% we need to skip the first two lines
12 state = data_obj.data;
13
14 N = 3*length(nodes);
15 % Extract x-velocity
16 Ux = state(1:3:N);
17 % Extract y-velocity
18 Uy = state(2:3:N);
19 % Extract pressure
20 P = state(3:3:N);
21
22 figure,
23 trisurf(adj, nodes(:,1), nodes(:,2), P);
24 shading interp;
25 view(0,90)
26 axis equal
27 axis tight
28
29 figure,
30 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
31 axis equal
32 axis tight
33
34 end
35
36 data_obj = importdata('control.txt', ' ', 2); %% we need to skip the first two lines
37 control = data_obj.data;
38
39 % Extract x-velocity
40 Zx = control(1:3:N);
41 % Extract y-velocity
42 Zy = control(2:3:N);
43 % Extract pressure
44 P = control(3:3:N);
45
46 figure,
47 idx = find((nodes(:,1) == 1) .* (nodes(:,2) <= 0.5));
48 ZX = zeros(size(Zx)); ZX(idx) = Zx(idx);
49 ZY = zeros(size(Zy)); ZY(idx) = Zy(idx);
50 quiver(nodes(:,1), nodes(:,2), ZX, ZY);
51 axis equal
52 axis tight
53 xlim([0.6,1.2]);
54 ylim([-0.2,0.7]);
55
56 obj_samples = load('obj_samples.txt');
57
58 Nint = 100;
59 uval = obj_samples(:,3);
60 zval = obj_samples(:,4);
61 t = linspace(min(uval), max(uval), Nint);
62 dist = [];
63 for i=1:Nint
64 val = sum(uval<=t(i))/length(uval);
65 dist = [dist; val];
66 end
67 figure
68 plot(t, dist, 'LineWidth', 3)
69