function [p, e, t]=S_shapeuniform(r) ii=1; for i=1:9 for j=1:9 p(1,ii)=0+(i-1).*0.125; p(2,ii)=0+(j-1).*0.125; ii=ii+1; end end e(1,:)=[1 2 3 4 5 6 7 8 9 18 27 36 45 54 63 72 81 80 79 78 77 76 75 74 73 64 55 46 37 28 19 10]; e(2,:)=[2 3 4 5 6 7 8 9 18 27 36 45 54 63 72 81 80 79 78 77 76 75 74 73 64 55 46 37 28 19 10 1]; e(3,:)=zeros(1,32); e(4,:)=ones(1,32); e(5,1:8)=1; e(5,9:16)=2; e(5,17:24)=3; e(5,25:32)=4; e(6,:)=ones(1,32); e(7,:)=zeros(1,32); t(1,:)=[1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72]; t(2,:)=[2 11 3 12 4 13 5 14 6 15 7 16 8 17 9 18 11 20 12 21 13 22 14 23 15 24 16 25 17 26 18 27 20 29 21 30 22 31 23 32 24 33 25 34 26 35 27 36 29 38 30 39 31 40 32 41 33 42 34 43 35 44 36 45 38 47 39 48 40 49 41 50 42 51 43 52 44 53 45 54 47 56 48 57 49 58 50 59 51 60 52 61 53 62 54 63 56 65 57 66 58 67 59 68 60 69 61 70 62 71 63 72 65 74 66 75 67 76 68 77 69 78 70 79 71 80 72 81]; t(3,:)=[10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 64 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80]; t(4,:)=ones(1,128); %ovan har jag placerat noderna i ordning från vänster till höger %och nerifrån och upp. Trianglarna har samma ordning % och "kant matrisen" går bara runt i moturs riktning %% går igenom alla trianglar T_list=[]; jjj=0; for jjj=1:r%% detta skall bli en while loop sedan, är en for sats bara för att programmet inte skall hänga sig ii=1; if jjj >= 1 for i=1:length(t(1,:))%% går igenom alla trianglarna if jjj < 100 %(p(1,t(1,i))-0.5).^2 +(p(2,t(1,i))-0.5).^2 < 0.01 || (p(1,t(2,i))-0.5).^2 +(p(2,t(2,i))-0.5).^2 < 0.01 || (p(1,t(3,i))-0.5).^2 +(p(2,t(3,i))-0.5).^2 < 0.01 %% ovan är villkoret, så länge villkoret är uppfyllt fortsätter %% programmet att förfina trianglarna T_list(:,ii)=t(1:3,i); % detta är kolumnerna ur t som skall förfinas index(ii)=i; %% detta är numret på triangeln ii=ii+1; end end end k2=0; for k=1:length(T_list(1,:)) k2=k2+1; pp2(:,k2)=(p(:,T_list(1,k))+p(:,T_list(2,k)))./2; k2=k2+1; pp2(:,k2)=(p(:,T_list(1,k))+p(:,T_list(3,k)))./2; k2=k2+1; pp2(:,k2)=(p(:,T_list(3,k))+p(:,T_list(2,k)))./2; end pp2; q=0; for k=1:length(pp2(1,:)) for k3=k:length(pp2(1,:)) if pp2(1,k)==pp2(1,k3) && pp2(2,k)==pp2(2,k3) && k3~=k q=q+1; index22(q)=k3; end end end index22; q2=0; for k=1:length(pp2) q=0; for k2=1:length(index22) if k~=index22(k2) q=q+1; if q==length(index22) q2=q2+1; pp3(:,q2)=pp2(:,k); end end end end L=length(p); L2=length(pp3); for k=1:length(pp3) for k2=1:length(T_list) if (p(1,T_list(1,k2))+p(1,T_list(2,k2)))./2 == pp3(1,k) && (p(2,T_list(1,k2))+p(2,T_list(2,k2)))./2 == pp3(2,k) Lista(1,k2)=k+L; end if (p(1,T_list(3,k2))+p(1,T_list(2,k2)))./2 == pp3(1,k) && (p(2,T_list(3,k2))+p(2,T_list(2,k2)))./2 == pp3(2,k) Lista(2,k2)=k+L; end if (p(1,T_list(1,k2))+p(1,T_list(3,k2)))./2 == pp3(1,k) && (p(2,T_list(1,k2))+p(2,T_list(3,k2)))./2 == pp3(2,k) Lista(3,k2)=k+L; end end end for k=1:length(T_list) if p(1,T_list(1,k)) == p(1,T_list(2,k)) t(:,index(k))=[T_list(1,k);Lista(1,k);Lista(3,k);1]; t(:,length(t)+1)=[Lista(1,k);T_list(2,k);Lista(2,k);1]; t(:,length(t)+1)=[Lista(1,k);Lista(2,k);Lista(3,k);1]; t(:,length(t)+1)=[Lista(3,k);Lista(2,k);T_list(3,k);1]; end if p(1,T_list(2,k)) == p(1,T_list(3,k)) t(:,index(k))=[T_list(1,k);Lista(1,k);Lista(3,k);1]; t(:,length(t)+1)=[Lista(1,k);T_list(2,k);Lista(2,k);1]; t(:,length(t)+1)=[Lista(3,k);Lista(1,k);Lista(2,k);1]; t(:,length(t)+1)=[Lista(3,k);Lista(2,k);T_list(3,k);1]; end end p(:,L+1:L+L2)=pp3; end q=0; for i=1:length(p(1,:)) if p(1,i)==0 ||p(1,i)==1 || p(2,i)==1 || p(2,i)==0 q=q+1; ee(q)=i; end end p=p; e=ee; t=t; %pdemesh(p,e,t)