Debian Codegraph @

packages/rol/example/PDE-OPT/flow-opt/3dim/models/darcy/plotDarcy.m

raw
1 function plotDarcy(numprocs)
2
3 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency table, increment by 1 for 1-based indexing
4
5 nodes = load('nodes.txt'); %% load node coordinates
6 N = length(nodes);
7
8 %% PLOT PRESSURE
9 data_obj = importdata('state.txt', ' ', 2); %% we need to skip the first two lines
10 state = data_obj.data;
11 data_obj = importdata('map_state.txt', ' ', 9); %% we need to skip the first 9 lines
12 map_state = data_obj.data;
13 map_state = map_state(1:2:end)+1;
14 [tmp, state_permute] = sort(map_state);
15 state = state(state_permute); %% we need to permute the state according to parallel maps
16
17 state = state(1:N); %% nodal values only
18
19 vtkwrite('state', ...
20 adj, ...
21 nodes, ...
22 state, ...
23 'Tetrahedron', ...
24 'state');
25
26 if (numprocs>1)
27 for i=1:numprocs
28 cid_files{i} = "cellid_" + num2str(i-1) + "_" + num2str(numprocs) + ".txt";
29 per_files{i} = "permeability_" + num2str(i-1) + "_" + num2str(numprocs) + ".txt";
30 vel_files{i} = "velocity_" + num2str(i-1) + "_" + num2str(numprocs) + ".txt";
31 end
32 else
33 cid_files{1} = "cellid.txt";
34 per_files{1} = "permeability.txt";
35 vel_files{1} = "velocity.txt";
36 end
37
38 cids = [];
39 pers = [];
40 vels = [];
41
42 for i=1:length(cid_files)
43 data_obj = importdata(cid_files{i}, ' ');
44 cids = [cids; data_obj];
45 data_obj = importdata(per_files{i}, ' ');
46 pers = [pers; data_obj];
47 data_obj = importdata(vel_files{i}, ' ');
48 vels = [vels; data_obj];
49 end
50
51 cids = cids + 1;
52 vtk_pers = pers(cids);
53 vtk_vels = vels(cids, :);
54
55 vtkwritecell('permeability', ...
56 adj, ...
57 nodes, ...
58 vtk_pers, ...
59 'Tetrahedron', ...
60 'permeability');
61
62 vtkwritecell('velocity', ...
63 adj, ...
64 nodes, ...
65 vtk_vels, ...
66 'Tetrahedron', ...
67 'velocity');