Ignore:
Timestamp:
08/25/20 00:32:13 (5 years ago)
Author:
jdquinn
Message:

CHG: Saving chnages so that Basile has access to potential fix to solidearthmodel class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/mesh/bamg.m

    r24865 r25455  
    8080                        domain=shpread(domainfile);
    8181                else
    82                         error(['bamg error message: file ' domainfile ' format not supported (.shp or .exp)']);
     82                        error(['bamg error message: file ' domainfile ' format not supported (.exp or .shp)']);
    8383                end
    8484        elseif isstruct(domainfile),
     
    140140                end
    141141
    142                 %Checks that all holes are INSIDE the principle domain outline
     142                %Check that all holes are INSIDE the principle domain outline
    143143                if i>1,
    144144                        flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0);
     
    149149
    150150                %Check orientation
    151                 nods=domain(i).nods-1; %the domain are closed 1=end;
     151                nods=domain(i).nods-1; %the domain is closed (domain[1] = domain[end])
    152152                test = sum([(domain(i).x(2:nods+1) - domain(i).x(1:nods)).*(domain(i).y(2:nods+1) + domain(i).y(1:nods))]);
    153153                if (i==1 && test>0) || (i>1 && test<0),
     
    163163                bamg_geometry.Edges   =[bamg_geometry.Edges;    [transpose(count+1:count+nods) transpose([count+2:count+nods count+1])  1*ones(nods,1)]];
    164164
    165                 %Flag how many edges we have now, that way we know which edges belong to the domain, will
    166                 %be used later for required edges when NoBoundaryRefinement is one:
     165                % Flag how many edges we have now, that way we know which edges belong
     166                % to the domain. Will be used later for required edges if
     167                % NoBoundaryRefinement equals 1.
    167168                new_edge_length=length(bamg_geometry.Edges);
    168169                edges_required=(edge_length+1):new_edge_length;
    169170
    170171                if i>1,
    171                         bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 -subdomain_ref]; subdomain_ref = subdomain_ref+1;
     172                        bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 -subdomain_ref];
     173                        subdomain_ref = subdomain_ref+1;
    172174                else
    173175                        bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 0];
     
    179181        for i=1:length(holes),
    180182
    181                 %Check that the subdomains is closed
     183                %Check that the hole is closed
    182184                if (holes(i).x(1)~=holes(i).x(end) | holes(i).y(1)~=holes(i).y(end)),
    183185                        error('bamg error message: all contours provided in ''holes'' should be closed');
    184186                end
    185187
    186                 %Checks that all holes are INSIDE the principle domain outline
     188                %Check that all holes are INSIDE the principal domain (principal domain should be index 0)
    187189                flags=ContourToNodes(holes(i).x,holes(i).y,domain(1),0);
    188190                if any(~flags), error('bamg error message: All holes should be strictly inside the principal domain'); end
    189191
    190192                %Check that hole is correctly oriented
    191                 nods=holes(i).nods-1; %the holes are closed 1=end;
     193                nods=holes(i).nods-1; %the hole is closed (hole[1] = hole[end])
    192194                if(sum([(holes(i).x(2:nods+1) - holes(i).x(1:nods)).*(holes(i).y(2:nods+1) + holes(i).y(1:nods))]))<0
    193195                        disp('At least one hole was not correctly oriented and has been re-oriented');
     
    205207        for i=1:length(subdomains),
    206208
    207                 %Check that the subdomains is closed
     209                %Check that the subdomain is closed
    208210                if (subdomains(i).x(1)~=subdomains(i).x(end) | subdomains(i).y(1)~=subdomains(i).y(end)),
    209211                        error('bamg error message: all contours provided in ''subdomains'' should be closed');
    210212                end
    211213
    212                 %Checks that all holes are INSIDE the principle domain outline
     214                %Checks that all subdomains are INSIDE the principal domain (principal domain should be index 0)
    213215                flags=ContourToNodes(subdomains(i).x,subdomains(i).y,domain(1),0);
    214216                if any(~flags),
    215                         error('bamg error message: All holes should be strictly inside the principal domain');
    216                 end
    217 
    218                 %Check that hole is correctly oriented
    219                 nods=subdomains(i).nods-1; %the subdomains are closed 1=end;
     217                        error('bamg error message: All subdomains should be strictly inside the principal domain');
     218                end
     219
     220                %Check that subdomain is correctly oriented
     221                nods=subdomains(i).nods-1; % the subdomains are closed (subdomains[1] = subdomains[end])
    220222                if(sum([(subdomains(i).x(2:nods+1) - subdomains(i).x(1:nods)).*(subdomains(i).y(2:nods+1) + subdomains(i).y(1:nods))]))>0
    221223                        disp('At least one subdomain was not correctly oriented and has been re-oriented');
    222                         subdomains(i).x = flipud(subdomains(i).x); subdomains(i).y = flipud(subdomains(i).y);
     224                        subdomains(i).x = flipud(subdomains(i).x);
     225                        subdomains(i).y = flipud(subdomains(i).y);
    223226                end
    224227
     
    227230                bamg_geometry.Edges   =[bamg_geometry.Edges;    [transpose(count+1:count+nods) transpose([count+2:count+nods count+1])  1.*ones(nods,1)]];
    228231               
    229                 bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 subdomain_ref]; subdomain_ref = subdomain_ref+1;
     232                bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 subdomain_ref];
     233                subdomain_ref = subdomain_ref+1;
    230234               
    231235                %update counter
    232236                count=count+nods;
    233237        end
     238
    234239        if getfieldvalue(options,'vertical',0),
    235240                if numel(getfieldvalue(options,'Markers',[]))~=size(bamg_geometry.Edges,1),
     
    243248        %take care of rifts
    244249        if exist(options,'rifts'),
    245 
    246                 %Check that file exists
     250                %read rift file according to its extension:
    247251                riftfile=getfieldvalue(options,'rifts');
    248                 [pathr,namer,extr]=fileparts(riftfile);
    249                 if ~exist(riftfile,'file')
    250                         error(['bamg error message: file ' riftfile ' not found ']);
    251                 elseif strcmp(extr,'.exp'),
    252                         rift=expread(riftfile);
    253                 elseif strcmp(extr,'.shp'),
    254                         rift=shpread(riftfile);
    255                 end
    256                 %read rift file according to its extension:
    257252                [path,name,ext]=fileparts(riftfile);
    258253                if strcmp(ext,'.exp'),
     
    261256                        rift=shpread(riftfile);
    262257                else
    263                         error(['bamg error message: file ' riftfile ' format not supported (.shp or .exp)']);
     258                        error(['bamg error message: file ' riftfile ' format not supported (.exp or .shp)']);
    264259                end
    265260
     
    272267
    273268                        elseif any(~flags),
    274                                 %We LOTS of work to do
     269                                %We have LOTS of work to do
    275270                                disp('Rift tip outside of or on the domain has been detected and is being processed...');
    276271
    277272                                %check that only one point is outside (for now)
    278273                                if sum(~flags)~=1,
    279                                         error('bamg error message: only one point outside of the domain is supported yet');
     274                                        error('bamg error message: only one point outside of the domain is supported at this time');
    280275                                end
    281276
     
    290285                                end
    291286
    292                                 %Get cordinate of intersection point
    293                                 x1=rift(i).x(1); y1=rift(i).y(1);
    294                                 x2=rift(i).x(2); y2=rift(i).y(2);
     287                                %Get coordinate of intersection point
     288                                x1=rift(i).x(1);
     289                                y1=rift(i).y(1);
     290                                x2=rift(i).x(2);
     291                                y2=rift(i).y(2);
    295292                                for j=1:length(domain(1).x)-1;
    296293                                        if SegIntersect([x1 y1; x2 y2],[domain(1).x(j) domain(1).y(j); domain(1).x(j+1) domain(1).y(j+1)]),
     
    489486        md.mesh.numberofvertices=length(md.mesh.x);
    490487        md.mesh.numberofedges=size(md.mesh.edges,1);
    491         md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
    492 
    493         %Now, build the connectivity tables for this mesh.
    494         md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
     488        md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1);
     489        md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
    495490
    496491elseif getfieldvalue(options,'3dsurface',0),
     
    509504        md.mesh.numberofvertices=length(md.mesh.x);
    510505        md.mesh.numberofedges=size(md.mesh.edges,1);
    511         md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
     506        md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1);
     507        md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
    512508
    513509else
     
    524520        md.mesh.numberofvertices=length(md.mesh.x);
    525521        md.mesh.numberofedges=size(md.mesh.edges,1);
    526         md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
     522        md.mesh.vertexonboundary=zeros(md.mesh.numberofvertices,1);
     523        md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
    527524end
    528525
Note: See TracChangeset for help on using the changeset viewer.