


MESHEXPREFINE - refine mesh from a model
This routine refines a mesh for a given area using an Argus domain outline
and a new resolution for this domain.
Appending ~ at the beginning of domainname will make this routine refine
the elements which are not in the domain outline.
newresolution is the resolution to which the flagged elements must be refined.
Usage:
md=meshexprefine(md,domainname,newresolution)
Example:
md=meshexprefine(md,'RefineAreas.exp',1000)

0001 function md=meshexprefine(md,domainname,newresolution) 0002 %MESHEXPREFINE - refine mesh from a model 0003 % 0004 % This routine refines a mesh for a given area using an Argus domain outline 0005 % and a new resolution for this domain. 0006 % Appending ~ at the beginning of domainname will make this routine refine 0007 % the elements which are not in the domain outline. 0008 % newresolution is the resolution to which the flagged elements must be refined. 0009 % 0010 % Usage: 0011 % md=meshexprefine(md,domainname,newresolution) 0012 % 0013 % Example: 0014 % md=meshexprefine(md,'RefineAreas.exp',1000) 0015 0016 %some checks on list of arguments 0017 if ((nargin~=3) | (nargout~=1)), 0018 meshexprefineusage(); 0019 error('meshexprefine error message'); 0020 end 0021 0022 if ~ischar(domainname) 0023 meshexprefineusage(); 0024 error('meshexprefine error message'); 0025 end 0026 0027 if (md.counter<1) 0028 error('meshexprefine error message: you need to run mesh.m first on this model'); 0029 end 0030 0031 %Check the first letter of domainname, if it is ~, then we need to strip it away from 0032 %domainname. The subsequent refinement will be done on the mask of the domain outline. 0033 if strcmpi(domainname(1),'~'), 0034 mask=1; 0035 domainname=domainname(2:length(domainname)); 0036 else 0037 mask=0; 0038 end 0039 0040 %Read domainname file into a matlab array (x,y): 0041 refinearea=ArgusContourToMesh(md.elements,md.x,md.y,expread(domainname,1),'element',1); 0042 aires=area(md); 0043 0044 %flags areas within the domain 0045 if mask==1, 0046 pos=find(~refinearea); 0047 else 0048 pos=find(refinearea); 0049 end 0050 aires(pos)=newresolution*newresolution/2; %triangle area 0051 0052 pos=find(refinearea); 0053 aires(pos)=2*aires(pos); %be sure this does not get refined. 0054 0055 %refine using the new area vector 0056 md=meshrefine(md,aires); 0057 0058 %return model 0059 end