Changeset 3260


Ignore:
Timestamp:
03/11/10 13:33:00 (15 years ago)
Author:
Eric.Larour
Message:

read modis image

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  
    5555else
    5656        md=mesh(md,domainoutline,riftoutline,resolution);
    57         md=meshprocessrifts(md);
     57        md=meshprocessrifts(md,domainoutline);
    5858end
    5959disp(['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)
     1function md=meshprocessrifts(md,domainoutline)
    22%MESHPROCESSRIFTS - process mesh when rifts are present
    33%
    44%   split rifts inside mesh (rifts are defined by presence of
    55%   segments inside the domain outline)
     6%   if domain outline is provided, check for rifts that could touch it, and open them up.
    67%
    78%   Usage:
    89%      md=meshprocessrifts(md)
     10%
     11%   Ex:
     12%      md=meshprocessrifts(md);
     13%      md=meshprocessrifts(md,'DomainOutline.exp');
     14%
    915
    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:
     17if nargout~=1,
     18        error('meshprocessrifts usage error:');
    1419end
     20
     21if nargin~=2,
     22        error('meshprocessrifts usage error:');
     23end
     24
    1525
    1626[md.elements,md.x,md.y,md.segments,md.segmentmarkers,md.rifts]=TriMeshProcessRifts(md.elements,md.x,md.y,md.segments,md.segmentmarkers);
     
    3343        md.rifts(i).tip2coordinates=[md.x(md.rifts(i).tips(2)) md.y(md.rifts(i).tips(2))];
    3444end
     45
     46%In case we have rifts that open up the domain outline, we need to open them:
     47flags=ContourToMesh(md.elements,md.x,md.y,expread(domainoutline,1),'node',0);
     48found=0;
     49for 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
     58end
     59if found,
     60        md=meshprocessoutsiderifts(md,domainoutline);
     61end
     62
     63%get elements that are not correctly oriented in the correct direction:
     64aires=GetAreas(md.elements,md.x,md.y);
     65pos=find(aires<0);
     66md.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  
    77                        rift=md.rifts(i);
    88
    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,
    1411
    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);
    2371                                pos_record=[pos_record; pos];
    2472                                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
    2782                                end
     83                                md.rifts(i).segments=riftsegs;
     84                                md.rifts(i).tips=[tip1 tip2(1) tip2(2)];
     85
    2886                        end
    29                         md.rifts(i).segments=riftsegs;
    30                         md.rifts(i).tips=[tip1 tip2];
    3187                end
    3288        end
  • issm/trunk/src/m/classes/public/plot/plot_rifts.m

    r3202 r3260  
    1717if isstruct(md.rifts),
    1818       
    19         for i=1:size(md.rifts,1),
     19        for i=1:md.numrifts,
    2020                penaltypairs=md.rifts(i).penaltypairs;
    2121
     
    2626                        x(penaltypairs(j,1))=x(penaltypairs(j,1))-normal(1)*offset;
    2727                        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
    2857                end
    2958        end
Note: See TracChangeset for help on using the changeset viewer.