Changeset 3260
- Timestamp:
- 03/11/10 13:33:00 (15 years ago)
- Location:
- issm/trunk/src/m/classes/public
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/mesh/meshyams.m
r2955 r3260 55 55 else 56 56 md=mesh(md,domainoutline,riftoutline,resolution); 57 md=meshprocessrifts(md );57 md=meshprocessrifts(md,domainoutline); 58 58 end 59 59 disp(['Initial mesh, number of elements: ' num2str(md.numberofelements)]); -
issm/trunk/src/m/classes/public/mesh/rifts/meshprocessrifts.m
r2737 r3260 1 function md=meshprocessrifts(md )1 function md=meshprocessrifts(md,domainoutline) 2 2 %MESHPROCESSRIFTS - process mesh when rifts are present 3 3 % 4 4 % split rifts inside mesh (rifts are defined by presence of 5 5 % segments inside the domain outline) 6 % if domain outline is provided, check for rifts that could touch it, and open them up. 6 7 % 7 8 % Usage: 8 9 % md=meshprocessrifts(md) 10 % 11 % Ex: 12 % md=meshprocessrifts(md); 13 % md=meshprocessrifts(md,'DomainOutline.exp'); 14 % 9 15 10 %some checks on list of arguments 11 if ((nargin~=1) | (nargout~=1)), 12 help meshprocessrifts 13 error('meshprocessrifts error messagei: bad usage'); 16 %some checks on arguments: 17 if nargout~=1, 18 error('meshprocessrifts usage error:'); 14 19 end 20 21 if nargin~=2, 22 error('meshprocessrifts usage error:'); 23 end 24 15 25 16 26 [md.elements,md.x,md.y,md.segments,md.segmentmarkers,md.rifts]=TriMeshProcessRifts(md.elements,md.x,md.y,md.segments,md.segmentmarkers); … … 33 43 md.rifts(i).tip2coordinates=[md.x(md.rifts(i).tips(2)) md.y(md.rifts(i).tips(2))]; 34 44 end 45 46 %In case we have rifts that open up the domain outline, we need to open them: 47 flags=ContourToMesh(md.elements,md.x,md.y,expread(domainoutline,1),'node',0); 48 found=0; 49 for i=1:md.numrifts, 50 if flags(md.rifts(i).tips(1))==0, 51 found=1; 52 break; 53 end 54 if flags(md.rifts(i).tips(2))==0, 55 found=1; 56 break; 57 end 58 end 59 if found, 60 md=meshprocessoutsiderifts(md,domainoutline); 61 end 62 63 %get elements that are not correctly oriented in the correct direction: 64 aires=GetAreas(md.elements,md.x,md.y); 65 pos=find(aires<0); 66 md.elements(pos,:)=[md.elements(pos,2) md.elements(pos,1) md.elements(pos,3)]; -
issm/trunk/src/m/classes/public/mesh/rifts/meshyamsrecreateriftsegments.m
r2737 r3260 7 7 rift=md.rifts(i); 8 8 9 %find tip1 and tip2 for this rift, in the new mesh created by yams. 10 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip1coordinates(1),rift.tip1coordinates(2)); 11 tip1=md.segments(pos,1); 12 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip2coordinates(1),rift.tip2coordinates(2)); 13 tip2=md.segments(pos,1); 9 %closed rifts first: 10 if length(rift.tips)==2, 14 11 15 %start from tip1, and build segments of this rift. 16 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip1coordinates(1),rift.tip1coordinates(2)); 17 pos_record=[pos_record; pos]; 18 riftsegs=md.segments(pos,:); 19 while 1, 20 A=riftsegs(end,1); B=riftsegs(end,2); el=riftsegs(end,3); 21 %find other segment that holds B. 22 pos=find(md.segments(:,1)==B); 12 %find tip1 and tip2 for this rift, in the new mesh created by yams. 13 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip1coordinates(1),rift.tip1coordinates(2)); 14 tip1=md.segments(pos,1); 15 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip2coordinates(1),rift.tip2coordinates(2)); 16 tip2=md.segments(pos,1); 17 18 %start from tip1, and build segments of this rift. 19 pos=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip1coordinates(1),rift.tip1coordinates(2)); 20 pos_record=[pos_record; pos]; 21 riftsegs=md.segments(pos,:); 22 while 1, 23 A=riftsegs(end,1); B=riftsegs(end,2); el=riftsegs(end,3); 24 %find other segment that holds B. 25 pos=find(md.segments(:,1)==B); 26 pos_record=[pos_record; pos]; 27 riftsegs=[riftsegs; md.segments(pos,:)]; 28 if riftsegs(end,2)==tip1, 29 break; 30 end 31 end 32 md.rifts(i).segments=riftsegs; 33 md.rifts(i).tips=[tip1 tip2]; 34 35 else 36 %ok, this is a rift that opens up to the domain outline. One tip is going to be 37 %double, the other one, single. We are going to start from the single tip, towards the two 38 %other doubles 39 40 %find tip1 and tip2 for this rift, in the new mesh created by yams. 41 pos1=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip1coordinates(1),rift.tip1coordinates(2)); 42 tip1=md.segments(pos1,1); 43 pos2=find_point(md.x(md.segments(:,1)),md.y(md.segments(:,1)),rift.tip2coordinates(1),rift.tip2coordinates(2)); 44 tip2=md.segments(pos2,1); 45 if length(tip1)==2, 46 %swap. 47 temp=tip1; tip1=tip2; tip2=temp; 48 temp=pos1; pos1=pos2; pos2=temp; 49 pos=pos1; 50 else 51 pos=pos1; 52 end 53 54 pos_record=[pos_record; pos]; 55 riftsegs=md.segments(pos,:); 56 while 1, 57 A=riftsegs(end,1); B=riftsegs(end,2); el=riftsegs(end,3); 58 %find other segment that holds B. 59 pos=find(md.segments(:,1)==B); 60 pos_record=[pos_record; pos]; 61 riftsegs=[riftsegs; md.segments(pos,:)]; 62 if ((riftsegs(end,2)==tip2(1)) | (riftsegs(end,2)==tip2(2))), 63 %figure out which tip we reached 64 if riftsegs(end,2)==tip2(1), index=2; else index=1; end 65 break; 66 end 67 end 68 69 %ok, now, we start from the other tip2, towards tip1 70 pos=pos2(index); 23 71 pos_record=[pos_record; pos]; 24 72 riftsegs=[riftsegs; md.segments(pos,:)]; 25 if riftsegs(end,2)==tip1, 26 break; 73 while 1, 74 A=riftsegs(end,1); B=riftsegs(end,2); el=riftsegs(end,3); 75 %find other segment that holds B. 76 pos=find(md.segments(:,1)==B); 77 pos_record=[pos_record; pos]; 78 riftsegs=[riftsegs; md.segments(pos,:)]; 79 if riftsegs(end,2)==tip1, 80 break; 81 end 27 82 end 83 md.rifts(i).segments=riftsegs; 84 md.rifts(i).tips=[tip1 tip2(1) tip2(2)]; 85 28 86 end 29 md.rifts(i).segments=riftsegs;30 md.rifts(i).tips=[tip1 tip2];31 87 end 32 88 end -
issm/trunk/src/m/classes/public/plot/plot_rifts.m
r3202 r3260 17 17 if isstruct(md.rifts), 18 18 19 for i=1: size(md.rifts,1),19 for i=1:md.numrifts, 20 20 penaltypairs=md.rifts(i).penaltypairs; 21 21 … … 26 26 x(penaltypairs(j,1))=x(penaltypairs(j,1))-normal(1)*offset; 27 27 y(penaltypairs(j,1))=y(penaltypairs(j,1))-normal(2)*offset; 28 end 29 if length(md.rifts(i).tips)==3, 30 tip=md.rifts(i).tips(3); 31 %who is tip connected to? 32 if isconnected(md.elements,penaltypairs(1,1),tip), 33 normal(1)=penaltypairs(1,5); 34 normal(2)=penaltypairs(1,6); 35 x(tip)=x(tip)-normal(1)*offset; 36 y(tip)=y(tip)-normal(2)*offset; 37 end 38 39 if isconnected(md.elements,penaltypairs(1,2),tip), 40 normal(1)=penaltypairs(1,5); 41 normal(2)=penaltypairs(1,6); 42 x(tip)=x(tip)+normal(1)*offset; 43 y(tip)=y(tip)+normal(2)*offset; 44 end 45 if isconnected(md.elements,penaltypairs(end,1),tip), 46 normal(1)=penaltypairs(end,5); 47 normal(2)=penaltypairs(end,6); 48 x(tip)=x(tip)-normal(1)*offset; 49 y(tip)=y(tip)-normal(2)*offset; 50 end 51 if isconnected(md.elements,penaltypairs(end,2),tip), 52 normal(1)=penaltypairs(end,5); 53 normal(2)=penaltypairs(end,6); 54 x(tip)=x(tip)+normal(1)*offset; 55 y(tip)=y(tip)+normal(2)*offset; 56 end 28 57 end 29 58 end
Note:
See TracChangeset
for help on using the changeset viewer.