| 1 |
function plotresults(nx,ny) |
| 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 |
|
| 7 |
data_obj = importdata('density.txt', ' ', 2); %% we need to skip the first two lines |
| 8 |
dens = data_obj.data(1:2:end,:); |
| 9 |
figure |
| 10 |
patch('Faces',adj,'Vertices',nodes,'FaceVertexCData',dens,'FaceColor','interp','EdgeColor','none'); |
| 11 |
colormap(flipud(gray)) |
| 12 |
axis equal; |
| 13 |
axis tight; |
| 14 |
box on; |
| 15 |
xlabel('x');, |
| 16 |
ylabel('y'); |
| 17 |
title('Interpolated nodal density'); |
| 18 |
|
| 19 |
figure |
| 20 |
xnodes = nodes(:,1); |
| 21 |
ynodes = nodes(:,2); |
| 22 |
celldens = dens(adj); |
| 23 |
avgcelldens = sum(celldens,2)/4; |
| 24 |
%maxcelldens = max(celldens,[],2); |
| 25 |
patch(xnodes(adj)',ynodes(adj)',ones(size(xnodes(adj)')),'CData',avgcelldens,'FaceColor','flat','EdgeColor','none'); |
| 26 |
colormap(flipud(gray)) |
| 27 |
axis equal; |
| 28 |
axis tight; |
| 29 |
box on; |
| 30 |
xlabel('x'); |
| 31 |
ylabel('y'); |
| 32 |
title('Averaged nodal density'); |
| 33 |
|
| 34 |
figure |
| 35 |
scatter(xnodes,ynodes,40*dens,'o','filled','k') |
| 36 |
axis equal; |
| 37 |
axis tight; |
| 38 |
box on; |
| 39 |
xlabel('x'); |
| 40 |
ylabel('y'); |
| 41 |
title('Bubble plot nodal density'); |
| 42 |
|
| 43 |
figure |
| 44 |
v1 = 0.1; |
| 45 |
v2 = 1.0; |
| 46 |
V = [v1,v2]; |
| 47 |
contourf(reshape(nodes(:,1),nx+1,ny+1), reshape(nodes(:,2),nx+1,ny+1), reshape(dens,nx+1,ny+1), V); |
| 48 |
colormap([0 0 0]); |
| 49 |
axis equal; |
| 50 |
axis tight; |
| 51 |
box on |
| 52 |
xlabel('x'); |
| 53 |
ylabel('y'); |
| 54 |
title('Contoured nodal density'); |
| 55 |
|
| 56 |
data_obj = importdata('state.txt', ' ', 2); %% we need to skip the first two lines |
| 57 |
state = data_obj.data; |
| 58 |
|
| 59 |
N = 2*length(nodes); |
| 60 |
% Extract x-displacement |
| 61 |
Ux = state(1:2:N); |
| 62 |
% Extract y-displacement |
| 63 |
Uy = state(2:2:N); |
| 64 |
|
| 65 |
% Mask, depending on density. |
| 66 |
mask = dens > min(dens)*1e2; |
| 67 |
UxPlot = Ux.*mask; |
| 68 |
UyPlot = Uy.*mask; |
| 69 |
|
| 70 |
figure, |
| 71 |
trisurf(adj, nodes(:,1), nodes(:,2), UxPlot); |
| 72 |
shading interp; |
| 73 |
view(0,90) |
| 74 |
axis equal |
| 75 |
axis tight |
| 76 |
box on |
| 77 |
caxis(gca, max(abs(caxis(gca))) * [-1 1]); |
| 78 |
newmap = bwr; |
| 79 |
colormap(newmap) |
| 80 |
colorbar |
| 81 |
|
| 82 |
figure, |
| 83 |
trisurf(adj, nodes(:,1), nodes(:,2), UyPlot); |
| 84 |
shading interp; |
| 85 |
view(0,90) |
| 86 |
axis equal |
| 87 |
axis tight |
| 88 |
box on |
| 89 |
caxis(gca, max(abs(caxis(gca))) * [-1 1]); |
| 90 |
newmap = bwr; |
| 91 |
colormap(newmap) |
| 92 |
colorbar |
| 93 |
|
| 94 |
figure |
| 95 |
xnodes = nodes(:,1)+Ux; |
| 96 |
ynodes = nodes(:,2)+Uy; |
| 97 |
celldens = dens(adj); |
| 98 |
avgcelldens = sum(celldens,2)/4; |
| 99 |
%maxcelldens = max(celldens,[],2); |
| 100 |
patch(xnodes(adj)',ynodes(adj)',ones(size(xnodes(adj)')),'CData',avgcelldens,'FaceColor','flat','EdgeColor','none'); |
| 101 |
colormap(flipud(gray)) |
| 102 |
axis equal; |
| 103 |
axis tight; |
| 104 |
box on; |
| 105 |
xlabel('x'); |
| 106 |
ylabel('y'); |
| 107 |
title('Deformed density'); |