source: issm/trunk/src/m/model/mesh/rifts/meshprocessrifts.m@ 9733

Last change on this file since 9733 was 9733, checked in by seroussi, 14 years ago

keep building mesh

File size: 2.4 KB
Line 
1function md=meshprocessrifts(md,domainoutline)
2%MESHPROCESSRIFTS - process mesh when rifts are present
3%
4% split rifts inside mesh (rifts are defined by presence of
5% segments inside the domain outline)
6% if domain outline is provided, check for rifts that could touch it, and open them up.
7%
8% Usage:
9% md=meshprocessrifts(md,domainoutline)
10%
11% Ex:
12% md=meshprocessrifts(md,'DomainOutline.exp');
13%
14
15%some checks on arguments:
16if nargout~=1,
17 help meshprocessrifts
18 error('meshprocessrifts usage error:');
19end
20
21if nargin~=2,
22 help meshprocessrifts
23 error('meshprocessrifts usage error:');
24end
25
26%Call MEX file
27[md.mesh.elements,md.x,md.y,md.mesh.segments,md.mesh.segmentmarkers,md.rifts.riftstruct]=TriMeshProcessRifts(md.mesh.elements,md.x,md.y,md.mesh.segments,md.mesh.segmentmarkers);
28md.rifts
29md.rifts.riftstruct
30if ~isstruct(md.rifts.riftstruct),
31 error('TriMeshProcessRifts did not find any rift');
32end
33
34%Fill in rest of fields:
35md.mesh.numberofelements=length(md.mesh.elements);
36md.mesh.numberofvertices=length(md.x);
37md.z=zeros(md.mesh.numberofvertices,1);
38md.mesh.vertexonboundary=zeros(length(md.x),1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
39md.rifts.numrifts=length(md.rifts.riftstruct);
40md.flowequation.element_equation=3*ones(md.mesh.numberofelements,1);
41md.mesh.vertexonbed=ones(md.mesh.numberofvertices,1);
42md.mesh.vertexonsurface=ones(md.mesh.numberofvertices,1);
43md.mesh.elementonbed=ones(md.mesh.numberofelements,1);
44md.mesh.elementonsurface=ones(md.mesh.numberofelements,1);
45
46%get coordinates of rift tips
47for i=1:md.rifts.numrifts,
48 md.rifts.riftstruct(i).tip1coordinates=[md.x(md.rifts.riftstruct(i).tips(1)) md.y(md.rifts.riftstruct(i).tips(1))];
49 md.rifts.riftstruct(i).tip2coordinates=[md.x(md.rifts.riftstruct(i).tips(2)) md.y(md.rifts.riftstruct(i).tips(2))];
50end
51
52%In case we have rifts that open up the domain outline, we need to open them:
53flags=ContourToMesh(md.mesh.elements,md.x,md.y,domainoutline,'node',0);
54found=0;
55for i=1:md.rifts.numrifts,
56 if flags(md.rifts.riftstruct(i).tips(1))==0,
57 found=1;
58 break;
59 end
60 if flags(md.rifts.riftstruct(i).tips(2))==0,
61 found=1;
62 break;
63 end
64end
65if found,
66 md=meshprocessoutsiderifts(md,domainoutline);
67end
68
69%get elements that are not correctly oriented in the correct direction:
70aires=GetAreas(md.mesh.elements,md.x,md.y);
71pos=find(aires<0);
72md.mesh.elements(pos,:)=[md.mesh.elements(pos,2) md.mesh.elements(pos,1) md.mesh.elements(pos,3)];
Note: See TracBrowser for help on using the repository browser.