| 1 | function 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:
|
|---|
| 16 | if nargout~=1,
|
|---|
| 17 | help meshprocessrifts
|
|---|
| 18 | error('meshprocessrifts usage error:');
|
|---|
| 19 | end
|
|---|
| 20 |
|
|---|
| 21 | if nargin~=2,
|
|---|
| 22 | help meshprocessrifts
|
|---|
| 23 | error('meshprocessrifts usage error:');
|
|---|
| 24 | end
|
|---|
| 25 |
|
|---|
| 26 | %Call MEX file
|
|---|
| 27 | [md.elements,md.x,md.y,md.segments,md.segmentmarkers,md.rifts]=TriMeshProcessRifts(md.elements,md.x,md.y,md.segments,md.segmentmarkers);
|
|---|
| 28 |
|
|---|
| 29 | %Fill in rest of fields:
|
|---|
| 30 | md.numberofelements=length(md.elements);
|
|---|
| 31 | md.numberofnodes=length(md.x);
|
|---|
| 32 | md.z=zeros(md.numberofnodes,1);
|
|---|
| 33 | md.nodeonboundary=zeros(length(md.x),1); md.nodeonboundary(md.segments(:,1:2))=1;
|
|---|
| 34 | md.numrifts=length(md.rifts);
|
|---|
| 35 | md.elements_type=3*ones(md.numberofelements,1);
|
|---|
| 36 | md.nodeonbed=ones(md.numberofnodes,1);
|
|---|
| 37 | md.nodeonsurface=ones(md.numberofnodes,1);
|
|---|
| 38 | md.elementonbed=ones(md.numberofelements,1);
|
|---|
| 39 | md.elementonsurface=ones(md.numberofelements,1);
|
|---|
| 40 |
|
|---|
| 41 | %get coordinates of rift tips
|
|---|
| 42 | for i=1:md.numrifts,
|
|---|
| 43 | md.rifts(i).tip1coordinates=[md.x(md.rifts(i).tips(1)) md.y(md.rifts(i).tips(1))];
|
|---|
| 44 | md.rifts(i).tip2coordinates=[md.x(md.rifts(i).tips(2)) md.y(md.rifts(i).tips(2))];
|
|---|
| 45 | end
|
|---|
| 46 |
|
|---|
| 47 | %In case we have rifts that open up the domain outline, we need to open them:
|
|---|
| 48 | flags=ContourToMesh(md.elements,md.x,md.y,domainoutline,'node',0);
|
|---|
| 49 | found=0;
|
|---|
| 50 | for i=1:md.numrifts,
|
|---|
| 51 | if flags(md.rifts(i).tips(1))==0,
|
|---|
| 52 | found=1;
|
|---|
| 53 | break;
|
|---|
| 54 | end
|
|---|
| 55 | if flags(md.rifts(i).tips(2))==0,
|
|---|
| 56 | found=1;
|
|---|
| 57 | break;
|
|---|
| 58 | end
|
|---|
| 59 | end
|
|---|
| 60 | if found,
|
|---|
| 61 | md=meshprocessoutsiderifts(md,domainoutline);
|
|---|
| 62 | end
|
|---|
| 63 |
|
|---|
| 64 | %get elements that are not correctly oriented in the correct direction:
|
|---|
| 65 | aires=GetAreas(md.elements,md.x,md.y);
|
|---|
| 66 | pos=find(aires<0);
|
|---|
| 67 | md.elements(pos,:)=[md.elements(pos,2) md.elements(pos,1) md.elements(pos,3)];
|
|---|