Debian Codegraph @

packages/intrepid/matlab/intrelab/mesh/RectGridDD.m

raw
1
2 function [mesh] = RectGridDD(nsdx, nsdy, t, p, e)
3 %
4 % AUTHOR: Matthias Heinkenschloss and Denis Ridzal
5 % Department of Computational and Applied Mathematics
6 % Rice University
7 % November 23, 2005
8
9 xmin = min(p(:,1));
10 xmax = max(p(:,1));
11 ymin = min(p(:,2));
12 ymax = max(p(:,2));
13
14 elempart = zeros(size(t,1),1);
15
16 for k = 1:size(t,1)
17 x = p(t(k,:),1); % x coordinates of all vertives in triangle k
18 y = p(t(k,:),2); % y coordinates of all vertives in triangle k
19 isd = 0; % subdomain number
20 for i = 1:nsdx
21 for j = 1:nsdy
22 isd = isd+1;
23 if( all( x >= xmin+(i-1)*(xmax-xmin)/nsdx-1.e-10 ) ...
24 & all( x <= xmin+i*(xmax-xmin)/nsdx+1.e-10 ) ...
25 & all( y >= ymin+(j-1)*(ymax-ymin)/nsdy-1.e-10 ) ...
26 & all( y <= ymin+j*(ymax-ymin)/nsdy+1.e-10 ) )
27 % all vertices of triangle k are inside subdomain k,
28 % i.e. triangke k is inside subdomain k
29 elempart(k) = isd-1;
30 end
31 end
32 end
33 end
34
35 [mesh] = meshpart(t, p, e, elempart);
36
37
38 % plot the partition
39 color = ['w','r','g','b','c','m','y'];
40 nc = length(color);
41
42 if 0
43 hold on;
44 axis('equal','tight');
45 for i = 1:size(t,1) % plot each element
46 x = p(t(i,1:3),1);
47 y = p(t(i,1:3),2);
48 c = mod(elempart(i),nc) + 1;
49 fill(x,y,color(c));
50 plot(x, y, '-k');
51 end
52 hold off;
53 end