From 5a4a5d2dbf5057dc442be675126f88cb384d6a02 Mon Sep 17 00:00:00 2001 From: treecity Date: Thu, 20 Oct 2011 20:06:17 +0000 Subject: [PATCH] =?utf8?q?[src]=20refineQuad=20zur=C3=BCck=20gesetzt=20(oh?= =?utf8?q?ne=20Nachbarn)=20[src]=20nMesh/refineQuad=20umstruckturiert=20f?= =?utf8?q?=C3=BCr=20Nachbarschafts=20relationen=20[src]=20kleine=20kopien?= =?utf8?q?=20nach=20nMesh?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://drops.fb12.tu-berlin.de/svn/bacc/trunk@55 26120e32-c555-405d-b3e1-1f783fb42516 --- src/A_stepIso.m | 4 +- src/exmpl_2DLShape.mat | Bin 319 -> 264 bytes src/nMesh/exmpl_2DLShape.mat | Bin 0 -> 319 bytes src/nMesh/exmpl_2DQuad.mat | Bin 0 -> 279 bytes src/nMesh/exmpl_3DCube.mat | Bin 0 -> 271 bytes src/nMesh/exmpl_3DFichCube.mat | Bin 0 -> 322 bytes src/nMesh/plotShape.m | 82 ++++++++++++++++++++ src/nMesh/refineQuad.m | 138 +++++++++++++++++++++++++++++++++ src/refineQuad.m | 47 ++--------- 9 files changed, 229 insertions(+), 42 deletions(-) create mode 100644 src/nMesh/exmpl_2DLShape.mat create mode 100644 src/nMesh/exmpl_2DQuad.mat create mode 100644 src/nMesh/exmpl_3DCube.mat create mode 100644 src/nMesh/exmpl_3DFichCube.mat create mode 100644 src/nMesh/plotShape.m create mode 100644 src/nMesh/refineQuad.m diff --git a/src/A_stepIso.m b/src/A_stepIso.m index 264f245..5175ffb 100644 --- a/src/A_stepIso.m +++ b/src/A_stepIso.m @@ -8,7 +8,7 @@ if (isempty(G_E) || isempty(G_C)) return end - [coordinates_fine,elements_fine, f2s]=refineQuad(G_C,G_E,2*ones(1,size(G_E,1))); + [coordinates_fine,elements_fine, f2s]=refineQuad(G_C,G_E,2); A_fine = mex_build_AU(coordinates_fine,elements_fine,mu,type); @@ -21,7 +21,7 @@ end ind = computeEstSlpMuTilde(x_fine,G_C,G_E,f2s); dataIso = [size(G_E,1) sqrt(sum(ind)) xe_fine]; - [G_C, G_E] = refineQuad(G_C,G_E,2*ones(1,size(G_E,1))); + [G_C, G_E] = refineQuad(G_C,G_E,2); end diff --git a/src/exmpl_2DLShape.mat b/src/exmpl_2DLShape.mat index 5a82bf5d89e9e1537dd679fa801d3eac7e96bc7c..9c9f86097cb660f6456cc5604866caa0ad92b34f 100644 GIT binary patch delta 36 qcmdnb)WI~tLc~A0M8U{F!N}0cz{1MJ49GS#oEWG*F@berO%DLF$O;(% delta 92 zcmeBR+Rrq>LL@k~K*7*d!O+;s*wD(@Ou@*&&~Rd)_QV9%i8Vdu{0s~X`aoPU=W%jE w0tZ8qnZmP%O9}_Lo*Fx6x~+(a%Sx+an~=to#3^w0#ECNvtPBh_Uzqj+0L|eYlmGw# diff --git a/src/nMesh/exmpl_2DLShape.mat b/src/nMesh/exmpl_2DLShape.mat new file mode 100644 index 0000000000000000000000000000000000000000..5a82bf5d89e9e1537dd679fa801d3eac7e96bc7c GIT binary patch literal 319 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NS#k5il@%`tma{FxUfe#hk~<2?-qxNoESq z8ZIdu;Ck9@U@TzFWN0p+{`|T4(v)Ya)0T)eUo~Xh$if`KC@jG!+2hmW6Ob&y@K1p? z31o~V+?WqY#uzgjatjzc{ak6ea_7oQ)uTQRX8ay=I%jsaPMtcpd8X(ZQHFMP7B!Fo o`fvj{kPUFobXyS-mz7qnj?q4JdZvnJ1)Ju5uu3`+`k b!x4)}Nz0ovB5p?Bu$Xz%(vqR$D@zmrbaYkW literal 0 HcmV?d00001 diff --git a/src/nMesh/exmpl_3DCube.mat b/src/nMesh/exmpl_3DCube.mat new file mode 100644 index 0000000000000000000000000000000000000000..d2e82344d2a377bd00f5c8a196cb38fe44ee98e0 GIT binary patch literal 271 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NSER4_EP0wPm$1tSAPLj@861EZ%eKLZ1UEf81Cd7PY((7}*ortqxc zlEMM5r_Bb&0>(^+<^t-^pNlU|d8RsTiCFVhL&l9P%n^(%Mg~rX9Vsa+41X`NCV&ia zf*ZmCH>B%GI%ATXhP|n}sk!O;B{MirOk?OYHZn5YY-GG~(}v9(H*72}C@|P)1Y|KY JtbM{#1^~|_PICYN literal 0 HcmV?d00001 diff --git a/src/nMesh/exmpl_3DFichCube.mat b/src/nMesh/exmpl_3DFichCube.mat new file mode 100644 index 0000000000000000000000000000000000000000..3c5c502061df8d68352be66b8e2f9629e9783250 GIT binary patch literal 322 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NS8$o zrH&1vr^FeP(iGBIlJXS%&YjoyI(f!h$5WSWHS@{PhRFYo4UFfSK1e(iP&&mit-Z71 zh{4qZUyKx1x{A4n@-r}Q)#C>loCr2px5t~WL4n6*;gqI7j(v|yZ>*G#t*G%nq@w>h z(nrXthR3k%=ae{G;}a*Y9=BXqxSzkk?wOvdhKp~?fp2^sr+&^T%H7TFn)$fKW9OE; YZC55F9A2?f>PFSf@<;3&F0#!804FPKH2?qr literal 0 HcmV?d00001 diff --git a/src/nMesh/plotShape.m b/src/nMesh/plotShape.m new file mode 100644 index 0000000..cf5f42e --- /dev/null +++ b/src/nMesh/plotShape.m @@ -0,0 +1,82 @@ +function plotShape(coordinates, elements, varargin) +% +% plotShape(coordinates,elements) +% plotShape(coordinates,elements,'FLAG') +% +% Diese Funktion Zeichnet alle Vierecke mit ausgefuellten Flaechen. +% FLAG: +% c -> Koordinaten als rote Kreise darstellen +% b -> nur Kanten der Elemente einzeichnen +% n -> Normen auf ein Element einzeichnen (mit Laenge 1) +% a -> Normen auf ein Element einzeichnen (Laenge durch Flaecheninhalt) +% +% P.Schaefer + +%% Parameterueberpruefung +c = 0; +e = 1; +n = 0; +optargin = size(varargin,2); +if(optargin>1) + error('Zu viele Argumente'); +elseif(optargin==1) + if(ismember('b',varargin{1})) + e = 0; + end + if(ismember('c',varargin{1})) + c = 1; + end + if(ismember('a',varargin{1})) + n = 2; + elseif(ismember('n',varargin{1})) + n = 1; + end +end + +%% Koordinaten einzeichnen +if(c) + scatter3(coordinates(:,1),coordinates(:,2),coordinates(:,3),'r'); + hold on +end + +%% Flächen +eles = size(elements,1); +if(e) + for idx = 1:eles + current = coordinates(elements(idx,[1:4,1])',:); +% current(3,:) = current(3,:)-current(1,:)+current(2,:); + fill3(current(:,1),current(:,2),current(:,3),'b'); % Zeichnet Oberflaeche + hold on + end +else + for idx = 1:eles + current = coordinates(elements(idx,[1:4,1])',:); +% current(3,:) = current(3,:)-current(1,:)+current(2,:); + plot3(current(:,1),current(:,2),current(:,3),'b'); % Zeichnet nur Kanten + hold on + end +end + +if(n) + if(n==2) + anorm = quadNorm(coordinates,elements,'w'); + else + anorm = quadNorm(coordinates,elements); + end + for idx = 1:eles + current = sum(coordinates(elements(idx,[2,4])',:),1)/2; + current = [current ; current+anorm(idx,:);coordinates(elements(idx,1)',:)]; + plot3(current(:,1),current(:,2),current(:,3),'r'); % Zeichnet Oberflaeche + scatter3(current(2,1),current(2,2),current(2,3),'xr'); + hold on + end +end + +xlabel 'x' +ylabel 'y' +zlabel 'z' + +hold off + +end + diff --git a/src/nMesh/refineQuad.m b/src/nMesh/refineQuad.m new file mode 100644 index 0000000..8bc9d88 --- /dev/null +++ b/src/nMesh/refineQuad.m @@ -0,0 +1,138 @@ +function [coo,ele,f2s] = refineQuad(coordinates,elements,type) +% +% [coordinates,elements,fa2so] = refineQuad(coordinates,elements,type) +% +% Verfeinert die markierten Elemente mit dem entsprechenden TYP und gibt +% auch die F2S Beziehungen zurück. type muss von der Länge der Anzahl der +% Elemente entsprechen oder genau 1 und die Einträge können 1,2,3,4 sein. +% +% der Typ zu jedem Element entspricht dabei: +% 1- keine Verfeinerung +% 2- 4 neue Elemente +% 3- 2 neue Elemente, übereinander +% 4- 2 neue Elemente, nebeneinander +% +% P. Schaefer + +if([1 1] == size(type)) + type = repmat(type, size(elements,1),1); +end + +global G_ref_E; +global G_ref_C; +global G_ref_N; +global G_ref_f2s; +global G_ref_t; + +c_loop = size(elements,1); + + +G_ref_E = elements; +G_ref_C = coordinates; +G_ref_t = type; +G_ref_f2s = repmat([1:c_loop]',1,4); + +for i = 1:c_loop + refine(i); +end + +coo = G_ref_C; +ele = G_ref_E; +f2s = G_ref_f2s; + +%igitigit + [coo l pos] = unique(coo,'rows'); + ele = pos(ele); + +clear G_ref_E G_ref_C G_ref_N G_ref_f2s G_ref_t +end + + +function refine(ele) +% global G_ref_E; +% global G_ref_C; +% global G_ref_N; +% global G_ref_f2s; +global G_ref_t; + +if(G_ref_t(ele)==1) + return; +end + +% Ueberpruefe Nachbarn + + +% wenn ungueltig verfeinere sie (link auf Soll verfeinert werden?) +% G_ref_M(k) = +% refine(k); + +% verfeinere dieses element +refineE(ele); + +% setze Nachbarschafts relationen +updateN(ele); + +end + +function refineE(ele) +% Element wird gnadenlos Verfeinert +global G_ref_E; +global G_ref_C; +%global G_ref_N; +global G_ref_f2s; +global G_ref_t; + + c_ele = size(G_ref_E,1); + c_coo = size(G_ref_C,1); + + + el = G_ref_E(ele,:); + if(G_ref_t(ele)==1) + disp 'Warning: Type = 1'; + return; + elseif(G_ref_t(ele)==2) + G_ref_C(c_coo+1,:) = (G_ref_C(el(1),:)+G_ref_C(el(2),:))/2; + G_ref_C(c_coo+2,:) = (G_ref_C(el(2),:)+G_ref_C(el(3),:))/2; + G_ref_C(c_coo+3,:) = (G_ref_C(el(3),:)+G_ref_C(el(4),:))/2; + G_ref_C(c_coo+4,:) = (G_ref_C(el(1),:)+G_ref_C(el(4),:))/2; + G_ref_C(c_coo+5,:) = (G_ref_C(el(1),:)+G_ref_C(el(3),:))/2; + + G_ref_E(ele,:) = [c_coo+4,c_coo+5,c_coo+3,el(4)]; + G_ref_E(c_ele+1,:) = [c_coo+5,c_coo+2,el(3),c_coo+3]; + G_ref_E(c_ele+2,:) = [c_coo+1,el(2),c_coo+2,c_coo+5]; + G_ref_E(c_ele+3,:) = [el(1),c_coo+1,c_coo+5,c_coo+4]; + + G_ref_f2s(ele,2:4)=c_ele+1:c_ele+3; + elseif(G_ref_t(ele)==3) + G_ref_C(c_coo+1,:) = (G_ref_C(el(1),:)+G_ref_C(el(4),:))/2; + G_ref_C(c_coo+2,:) = (G_ref_C(el(2),:)+G_ref_C(el(3),:))/2; + + G_ref_E(ele,1) = c_coo+1; + G_ref_E(ele,2) = c_coo+2; + + G_ref_E(c_ele+1,:) = [el(1),el(2),c_coo+2,c_coo+1]; + G_ref_f2s(ele,[3 4])=c_ele+1; + elseif(G_ref_t(ele)==4) + G_ref_C(c_coo+1,:) = (G_ref_C(el(1),:)+G_ref_C(el(2),:))/2; + G_ref_C(c_coo+2,:) = (G_ref_C(el(4),:)+G_ref_C(el(3),:))/2; + + G_ref_E(ele,2) = c_coo+1; + G_ref_E(ele,3) = c_coo+2; + + G_ref_E(c_ele+1,:) = [c_coo+1,el(2),el(3),c_coo+2]; + G_ref_f2s(ele,[2 4])=c_ele+1; + end + + G_ref_t(ele) = 1; + +end + +function updateN(ele) +% Nachbarschaften werden neu gesetzt (nach N und f2s) +% global G_ref_E; +% global G_ref_C; +% global G_ref_N; +% global G_ref_f2s; + +end + diff --git a/src/refineQuad.m b/src/refineQuad.m index c65140f..666acf3 100644 --- a/src/refineQuad.m +++ b/src/refineQuad.m @@ -1,4 +1,4 @@ -function [coo,ele,fa2so] = refineQuad(coordinates,elements,type) +function [coordinates,elements,fa2so] = refineQuad(coordinates,elements,type) % % [coordinates,elements,fa2so] = refineQuad(coordinates,elements,type) % @@ -14,25 +14,13 @@ function [coo,ele,fa2so] = refineQuad(coordinates,elements,type) % % P. Schaefer -% globale Struktur aufbauen -global E; -global C; -global N; -global F2S; - -E=elements; -C=coordinates; - -% Typ aufbauen if([1 1] == size(type)) - type = repmat(type, size(E,1),1); + type = repmat(type, size(elements,1),1); end -c_loop = size(E,1); +c_loop = size(elements,1); -F2S = repmat([1:c_loop]',1,4); - -type = check(neigh,type); +fa2so = repmat([1:c_loop]',1,4); for i = 1:c_loop c_ele = size(elements,1); @@ -77,29 +65,8 @@ for i = 1:c_loop end %igitigit - [coo l pos] = unique(coordinates,'rows'); - ele = pos(elements); - - -end - -function splitH(elem) -global E -global C -global N - + [G_ref_C l pos] = unique(G_ref_C,'rows'); + G_ref_E = pos(G_ref_E); + end -function splitV(elem) -global E -global C -global N - -end - - -function check(elem) - - - -end -- 2.47.3