Changeset 25455 for issm/trunk-jpl/src/m/mesh/bamg.m
- Timestamp:
- 08/25/20 00:32:13 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/mesh/bamg.m
r24865 r25455 80 80 domain=shpread(domainfile); 81 81 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)']); 83 83 end 84 84 elseif isstruct(domainfile), … … 140 140 end 141 141 142 %Check sthat all holes are INSIDE the principle domain outline142 %Check that all holes are INSIDE the principle domain outline 143 143 if i>1, 144 144 flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0); … … 149 149 150 150 %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]) 152 152 test = sum([(domain(i).x(2:nods+1) - domain(i).x(1:nods)).*(domain(i).y(2:nods+1) + domain(i).y(1:nods))]); 153 153 if (i==1 && test>0) || (i>1 && test<0), … … 163 163 bamg_geometry.Edges =[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose([count+2:count+nods count+1]) 1*ones(nods,1)]]; 164 164 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. 167 168 new_edge_length=length(bamg_geometry.Edges); 168 169 edges_required=(edge_length+1):new_edge_length; 169 170 170 171 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; 172 174 else 173 175 bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 0]; … … 179 181 for i=1:length(holes), 180 182 181 %Check that the subdomainsis closed183 %Check that the hole is closed 182 184 if (holes(i).x(1)~=holes(i).x(end) | holes(i).y(1)~=holes(i).y(end)), 183 185 error('bamg error message: all contours provided in ''holes'' should be closed'); 184 186 end 185 187 186 %Check s that all holes are INSIDE the principle domain outline188 %Check that all holes are INSIDE the principal domain (principal domain should be index 0) 187 189 flags=ContourToNodes(holes(i).x,holes(i).y,domain(1),0); 188 190 if any(~flags), error('bamg error message: All holes should be strictly inside the principal domain'); end 189 191 190 192 %Check that hole is correctly oriented 191 nods=holes(i).nods-1; %the hole s are closed 1=end;193 nods=holes(i).nods-1; %the hole is closed (hole[1] = hole[end]) 192 194 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 193 195 disp('At least one hole was not correctly oriented and has been re-oriented'); … … 205 207 for i=1:length(subdomains), 206 208 207 %Check that the subdomain sis closed209 %Check that the subdomain is closed 208 210 if (subdomains(i).x(1)~=subdomains(i).x(end) | subdomains(i).y(1)~=subdomains(i).y(end)), 209 211 error('bamg error message: all contours provided in ''subdomains'' should be closed'); 210 212 end 211 213 212 %Checks that all holes are INSIDE the principle domain outline214 %Checks that all subdomains are INSIDE the principal domain (principal domain should be index 0) 213 215 flags=ContourToNodes(subdomains(i).x,subdomains(i).y,domain(1),0); 214 216 if any(~flags), 215 error('bamg error message: All holes should be strictly inside the principal domain');216 end 217 218 %Check that holeis correctly oriented219 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]) 220 222 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 221 223 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); 223 226 end 224 227 … … 227 230 bamg_geometry.Edges =[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose([count+2:count+nods count+1]) 1.*ones(nods,1)]]; 228 231 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; 230 234 231 235 %update counter 232 236 count=count+nods; 233 237 end 238 234 239 if getfieldvalue(options,'vertical',0), 235 240 if numel(getfieldvalue(options,'Markers',[]))~=size(bamg_geometry.Edges,1), … … 243 248 %take care of rifts 244 249 if exist(options,'rifts'), 245 246 %Check that file exists 250 %read rift file according to its extension: 247 251 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 end256 %read rift file according to its extension:257 252 [path,name,ext]=fileparts(riftfile); 258 253 if strcmp(ext,'.exp'), … … 261 256 rift=shpread(riftfile); 262 257 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)']); 264 259 end 265 260 … … 272 267 273 268 elseif any(~flags), 274 %We LOTS of work to do269 %We have LOTS of work to do 275 270 disp('Rift tip outside of or on the domain has been detected and is being processed...'); 276 271 277 272 %check that only one point is outside (for now) 278 273 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'); 280 275 end 281 276 … … 290 285 end 291 286 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); 295 292 for j=1:length(domain(1).x)-1; 296 293 if SegIntersect([x1 y1; x2 y2],[domain(1).x(j) domain(1).y(j); domain(1).x(j+1) domain(1).y(j+1)]), … … 489 486 md.mesh.numberofvertices=length(md.mesh.x); 490 487 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; 495 490 496 491 elseif getfieldvalue(options,'3dsurface',0), … … 509 504 md.mesh.numberofvertices=length(md.mesh.x); 510 505 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; 512 508 513 509 else … … 524 520 md.mesh.numberofvertices=length(md.mesh.x); 525 521 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; 527 524 end 528 525
Note:
See TracChangeset
for help on using the changeset viewer.