source: issm/trunk/src/m/model/mesh/meshnodensity.m@ 9703

Last change on this file since 9703 was 9703, checked in by Mathieu Morlighem, 14 years ago

renamed mesh setmesh for mesh class

File size: 2.2 KB
Line 
1function md=meshnodensity(md,domainname,varargin)
2%MESH - create model mesh
3%
4% This routine creates a model mesh using TriMeshNoDensity and a domain outline
5% where md is a @model object, domainname is the name of an Argus domain outline file,
6% Riftname is an optional argument (Argus domain outline) describing rifts.
7% The difference with mesh.m is that the resolution of the mesh follows that of the domain
8% outline and the riftoutline
9%
10% Usage:
11% md=setmesh(md,domainname)
12% or md=setmesh(md,domainname,riftname);
13%
14% Examples:
15% md=setmesh(md,'DomainOutline.exp');
16% md=setmesh(md,'DomainOutline.exp','Rifts.exp');
17
18if (nargin==2),
19 riftname='';
20end
21if (nargin==3),
22 riftname=varargin{1};
23end
24
25%Mesh using TriMeshNoDensity
26if strcmp(riftname,''),
27 [md.elements,md.x,md.y,md.segments,md.segmentmarkers]=TriMeshNoDensity(domainname);
28else
29 [elements,x,y,segments,segmentmarkers]=TriMeshNoDensity(domainname,riftname);
30
31 %check that all the created nodes belong to at least one element
32 orphan=find(~ismember([1:length(x)],sort(unique(elements(:)))));
33 for i=1:length(orphan),
34 %get rid of the orphan node i
35 %update x and y
36 x=[x(1:orphan(i)-(i-1)-1); x(orphan(i)-(i-1)+1:end)];
37 y=[y(1:orphan(i)-(i-1)-1); y(orphan(i)-(i-1)+1:end)];
38 %update elements
39 pos=find(elements>orphan(i)-(i-1));
40 elements(pos)=elements(pos)-1;
41 %update segments
42 pos1=find(segments(:,1)>orphan(i)-(i-1));
43 pos2=find(segments(:,2)>orphan(i)-(i-1));
44 segments(pos1,1)=segments(pos1,1)-1;
45 segments(pos2,2)=segments(pos2,2)-1;
46 end
47
48 %plug into md
49 md.x=x;
50 md.y=y;
51 md.elements=elements;
52 md.segments=segments;
53 md.segmentmarkers=segmentmarkers;
54end
55
56%Fill in rest of fields:
57md.numberofelements=length(md.elements);
58md.numberofnodes=length(md.x);
59md.z=zeros(md.numberofnodes,1);
60md.nodeonboundary=zeros(md.numberofnodes,1); md.nodeonboundary(md.segments(:,1:2))=1;
61md.nodeonbed=ones(md.numberofnodes,1);
62md.nodeonsurface=ones(md.numberofnodes,1);
63md.elementonbed=ones(md.numberofelements,1);
64md.elementonsurface=ones(md.numberofelements,1);
65
66%Now, build the connectivity tables for this mesh.
67md.nodeconnectivity=NodeConnectivity(md.elements,md.numberofnodes);
68md.elementconnectivity=ElementConnectivity(md.elements,md.nodeconnectivity);
69
70%type of model
71md.dim=2;
Note: See TracBrowser for help on using the repository browser.