mesh2

PURPOSE ^

MESH - create model mesh

SYNOPSIS ^

function md2=mesh2(md,domainname,varargin)

DESCRIPTION ^

MESH - create model mesh

   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
   where md is a @model object, domainname is the name of an Argus domain outline file, 
   and resolution is a characteristic length for the mesh (same unit as the domain outline
   unit). Riftname is an optional argument (Argus domain outline) describing rifts.

   Usage:
      md2=mesh2(md,domainname,resolution)
   or md2=mesh2(md,domainname,riftname, resolution)

   Examples:
      md2=mesh2(md,'DOmainOutline.exp',1000);
      md2=mesh2(md,'DOmainOutline.exp','Rifts.exp',1500);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function md2=mesh2(md,domainname,varargin)
0002 %MESH - create model mesh
0003 %
0004 %   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
0005 %   where md is a @model object, domainname is the name of an Argus domain outline file,
0006 %   and resolution is a characteristic length for the mesh (same unit as the domain outline
0007 %   unit). Riftname is an optional argument (Argus domain outline) describing rifts.
0008 %
0009 %   Usage:
0010 %      md2=mesh2(md,domainname,resolution)
0011 %   or md2=mesh2(md,domainname,riftname, resolution)
0012 %
0013 %   Examples:
0014 %      md2=mesh2(md,'DOmainOutline.exp',1000);
0015 %      md2=mesh2(md,'DOmainOutline.exp','Rifts.exp',1500);
0016 
0017 %Figure out a characteristic area. Resolution is a grid oriented concept (ex a 1000m  resolution grid would
0018 %be made of 1000*1000 area squares).
0019 if (nargin==3),
0020     resolution=varargin{1};
0021     riftname='';
0022 end
0023 if (nargin==4),
0024     riftname=varargin{1};
0025     resolution=varargin{2};
0026 end
0027 
0028 %Check that mesh was not already run, and warn user:
0029 if subsref(md,struct('type','.','subs','counter'))>=1,
0030     choice=input('This model already has a mesh. Are you sure you want to go ahead? (y/n)','s');
0031     if ~strcmp(choice,'y')
0032         error('no meshing done ... exiting');
0033     end
0034 end
0035 
0036 area=resolution^2;
0037 %Initialize return model;
0038 md2=model;
0039 
0040 %Mesh using TriMesh
0041 if strcmp(riftname,''),
0042     [elements,x,y,segments,segmentmarkers]=TriMesh(domainname,area,'yes');
0043 else
0044     [elements,x,y,segments,segmentmarkers]=TriMesh(domainname,riftname,area,'yes');
0045 end
0046 
0047 md2=subsasgn(md2,struct('type','.','subs','elements'),elements); 
0048 md2=subsasgn(md2,struct('type','.','subs','segmentmarkers'),segmentmarkers); 
0049 md2=subsasgn(md2,struct('type','.','subs','segments'),segments); 
0050 md2=subsasgn(md2,struct('type','.','subs','y'),y);
0051 md2=subsasgn(md2,struct('type','.','subs','x'),x); 
0052 
0053 %Fill in rest of fields:
0054 md2=subsasgn(md2,struct('type','.','subs','numberofelements'),length(elements));
0055 md2=subsasgn(md2,struct('type','.','subs','numberofgrids'),length(x));
0056 md2=subsasgn(md2,struct('type','.','subs','z'),zeros(length(x),1));
0057 gridonboundary=zeros(length(x),1); gridonboundary(segments(:,1:2))=1;
0058 md2=subsasgn(md2,struct('type','.','subs','gridonboundary'),gridonboundary);
0059 md2=subsasgn(md2,struct('type','.','subs','elements_type'),3*ones(md2.numberofelements,1)); % type determined by number of grids per element
0060 
0061 %outline names
0062 md2=subsasgn(md2,struct('type','.','subs','domainoutline'),readfile(domainname));
0063 if strcmp(riftname,''),
0064     md2=subsasgn(md2,struct('type','.','subs','riftoutline'),'');
0065 else
0066     md2=subsasgn(md2,struct('type','.','subs','riftoutline'),readfile(riftname));
0067 end
0068 
0069 %type of model
0070 md2=subsasgn(md2,struct('type','.','subs','type'),'2d');
0071     
0072 %augment counter  keeping track of what has been done to this model
0073 md2=subsasgn(md2,struct('type','.','subs','counter'),1);

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003