removeholes

PURPOSE ^

REMOVEHOLES - interpolate a field on the a mesh without any hole

SYNOPSIS ^

function md2=removeholes(md,field)

DESCRIPTION ^

REMOVEHOLES - interpolate a field on the a mesh without any hole

   as its name indicates, this routine takes a model, a field (value of some 
   physical quantity evaluated at the mesh grids) of the model, and interpolates this field 
   on the model mesh, without any hole.

   Usage:
      md=removeholes(md,field)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function md2=removeholes(md,field)
0002 %REMOVEHOLES - interpolate a field on the a mesh without any hole
0003 %
0004 %   as its name indicates, this routine takes a model, a field (value of some
0005 %   physical quantity evaluated at the mesh grids) of the model, and interpolates this field
0006 %   on the model mesh, without any hole.
0007 %
0008 %   Usage:
0009 %      md=removeholes(md,field)
0010 
0011 %Check that model is complete
0012 if md.counter<3,
0013     error('removeholes error message: model is incomplete ... exiting');
0014 end
0015 
0016 if nargin~=2,
0017     removeholesusage;
0018     error('removeholes error message');
0019 end
0020 
0021 if ~ischar(field), 
0022     removeholesusage;
0023     error('removeholes error message');
0024 end
0025 
0026 
0027 %Ok, retrieve and write domain outline without holes, to disk.
0028 domainoutline_string=md.domainoutline;
0029 name_slots=findstr(domainoutline_string,'## Name');
0030 domainoutline_string=domainoutline_string(1:(name_slots(2)-1)); %only keep first outline
0031 writefile('DomainOutlineTemp.exp',domainoutline_string);
0032 
0033 %Now create new model with mesh based on DomainOutlineTemp:
0034 %get average resolution
0035 resolution=mean(sqrt(2*area(md)));
0036 md2=model;
0037 md2=mesh(md2,'DomainOutlineTemp.exp',resolution);
0038 
0039 %Ok, now interpolate field onto this new mesh
0040 fieldvalue=getfield(md,field);
0041 md2=setfield(md2,field,griddata(md.x,md.y,fieldvalue,md2.x,md2.y));
0042 
0043 end %end of function
0044 
0045 function removeholesusage(),
0046 disp('usage: md2=removeholes(md,field)');
0047 end

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