xref: /petsc/src/ts/tutorials/power_grid/ex7.m (revision 0e03b746557e2551025fde0294144c0532d12f68)
1%
2%  Loads the output from ex7 (option -ts_monitor_solution_binary) and puts it into a useful
3%  format for visualizing. Removes the first 49 y grid lines since they have noise from the initial
4%  conditions. For example:
5%
6%    contourf(A{49})   and contourf(B{49})
7%
8AA = PetscBinaryRead('binaryoutput','cell',10000);
9l = size(AA); l = l(2);
10A = cell(1,l-80-1);
11for i=1:l-80-1; A{1,i} = AA{i+79}; end;
12l = size(A); l = l(2);
13n = size(A{1}); n = sqrt(n(1));
14for i=1:l; A{i} = reshape(A{i},n,n); end
15B = A;
16
17for i=1:l
18        for j=1:n; A{i}(:,j) = min(A{i}(:,j)); end
19        for j=1:n; B{i}(:,j) = B{i}(:,j) - min(B{i}(:,j)); end
20end
21
22for i=1:l
23        A{i} = A{i}(:,50:n);
24        B{i} = B{i}(:,50:n);
25end
26
27a = zeros(l-1,1);
28for i=1:l-1; a(i) = max(max(A{i+1}))/max(max(A{i})); end
29b = zeros(l-1,1);
30for i=1:l-1; b(i) = max(max(B{i+1}))/max(max(B{i})); end
31