Changeset 1223
- Timestamp:
- 07/02/09 15:50:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/geography2.m
r1126 r1223 1 1 function md=geography2(md,landname,iceshelfname,icesheetname) 2 2 3 %Get assigned fields 3 4 x=md.x; … … 8 9 [gridonland,elementonland]=ContourToMesh(elements,x,y,expread(landname,1),'element and node',2); 9 10 10 %use segments to make sure gridonland is correct at the boundary: 11 pos=find(md.segmentmarkers==2); 12 gridonland(md.segments(pos,1))=1; 13 gridonland(md.segments(pos,2))=1; 14 %now, any elements with 3 grids on land should be on land: 11 %any element with 3 grids on land should be on land: 15 12 elementsonwater=find(~elementonland); 16 13 wrongelements=elementsonwater(find(( gridonland(md.elements(elementsonwater,1)) + gridonland(md.elements(elementsonwater,2)) + gridonland(md.elements(elementsonwater,3)) ... … … 18 15 elementonland(wrongelements)=1; 19 16 20 %finally, any element with its barycentre in the water should be in the water! 21 xelem=x(md.elements)*[1;1;1]/3; yelem=y(md.elements)*[1;1;1]/3; 17 %any element with its barycentre on land should be on land: 18 weights={[1;1;1],[2;1;1],[1;2;1],[1;1;2]}; 19 for i=1:length(weights), 20 xelem=x(md.elements)*weights{i}/sum(weights{i}); 21 yelem=y(md.elements)*weights{i}/sum(weights{i}); 22 end 22 23 baryonland=ContourToNodes(xelem,yelem,expread(landname,1),1); 23 24 pos=find(~baryonland); elementonland(pos)=0; 25 pos=find(baryonland); elementonland(pos)=1; 24 26 25 27 %figure out which elements on land are actually in the middle of the ocean! … … 29 31 connectedtolandsum=sum(connectedtoland,2); 30 32 waterelements=pos1(find(connectedtolandsum==3)); 33 elementonland(waterelements)=0; 31 34 32 %now use waterelements to correct elementonland: 33 elementonland(waterelements)=0; 35 %figure out which elements on water are actually in the middle of the land! 36 pos1=find(~elementonland); 37 connectedtowater=md.elementconnectivity(pos1,:); 38 pos=find(connectedtowater); connectedtowater(pos)=elementonland(connectedtowater(pos)); 39 connectedtowatersum=sum(connectedtowater,2); 40 landelements=pos1(find(connectedtowatersum==3)); 41 elementonland(landelements)=1; 34 42 35 43 %recover arrays of ice shelf grids and elements, and ice sheet grids and elements. … … 74 82 elementonicesheet=double(~elementoniceshelf & ~elementonwater); 75 83 84 85 86 %Deal with segments on neumann: 87 elementconnectivity=md.elementconnectivity; 88 pos=find(elementconnectivity); 89 elementconnectivity(pos)=elementonwater(elementconnectivity(pos)); 90 91 pos=find(elementonwater); 92 elementconnectivity(pos,:)=0; 93 94 num_segments=sum(sum(elementconnectivity)); 95 segments=zeros(num_segments,3); 96 97 icefrontelementsonland=find(sum(elementconnectivity,2)); 98 99 count=1; 100 for i=1:numel(icefrontelementsonland), 101 el1=icefrontelementsonland(i); 102 els2=md.elementconnectivity(el1,find(elementconnectivity(el1,:))); 103 for j=1:numel(els2), 104 el2=els2(j); 105 %we have a segment between land el1 and water el2: 106 segments(count,:)=[intersect(md.elements(el1,:),md.elements(el2,:)) el1]; 107 108 ord1=find(segments(count,1)==md.elements(el1,:)); 109 ord2=find(segments(count,2)==md.elements(el1,:)); 110 111 %swap segment grids if necessary 112 if ( (ord1==1 & ord2==2) | (ord1==2 & ord2==3) | (ord1==3 & ord2==1) ), 113 temp=segments(count,1); 114 segments(count,1)=segments(count,2); 115 segments(count,2)=temp; 116 end 117 segments(count,1:2)=fliplr(segments(count,1:2)); 118 119 count=count+1; 120 end 121 end 122 76 123 %Return: 77 124 md.gridoniceshelf=gridoniceshelf; … … 84 131 md.elementonicesheet=elementonicesheet; 85 132 86 %Deal with segments on neumann:87 pos=find(md.segmentmarkers==2); %internal segments.88 segments=md.segments(pos,:);89 90 %swap segments so they are all oriented the same way91 maxcon=size(md.nodeconnectivity,2);92 for i=1:length(segments),93 94 pair=intersect(md.nodeconnectivity(segments(i,1),1:md.nodeconnectivity(segments(i,1),maxcon)),md.nodeconnectivity(segments(i,2),1:md.nodeconnectivity(segments(i,2),maxcon)));95 96 if md.elementonwater(pair(1)),97 segments(i,3)=pair(2);98 else99 segments(i,3)=pair(1);100 end101 102 ord1=find(segments(i,1)==md.elements(segments(i,3),:));103 ord2=find(segments(i,2)==md.elements(segments(i,3),:));104 105 %swap segment grids if necessary106 if ( (ord1==1 & ord2==2) | (ord1==2 & ord2==3) | (ord1==3 & ord2==1) ),107 temp=segments(i,1);108 segments(i,1)=segments(i,2);109 segments(i,2)=temp;110 end111 segments(i,1:2)=fliplr(segments(i,1:2));112 113 end114 133 md.segmentonneumann_diag=segments; 115 134 md.counter=2;
Note:
See TracChangeset
for help on using the changeset viewer.