smoothfield2.m 1.88 KB
Newer Older
1
function [field]  = smoothfield2(fieldin,Mobj,nLoops,SmoothPts)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

% Smooth a vertex-based field using minimum value of surrounding nodes 
%
% [field] = function smoothfield(fieldin,Mobj,nLoops,SmoothPts)  
%
% DESCRIPTION:
%    Smooth a vertex based field 
%
% INPUT
%    Mobj         = Matlab mesh object
%    fielin       = vertex based field
%    nLoops       = number of smoothing iterations
%    SmoothPts    = list of vertices to smooth [optional, default = all]
%
% OUTPUT:
%    field = smoothed, vertex-based field
%
% EXAMPLE USAGE
%    Mobj.h = smoothfield(Mobj.h,Mobj,0.5,4)
%
% Author(s):  
%    Geoff Cowles (University of Massachusetts Dartmouth)
%
% Revision history
%   
%==============================================================================
28
global ftbverbose
29 30 31 32
[~, subname] = fileparts(mfilename('fullpath'));
if ftbverbose
    fprintf('\nbegin : %s\n', subname)
end
33 34 35 36 37 38 39 40 41 42 43 44

%------------------------------------------------------------------------------
% Parse input
%------------------------------------------------------------------------------

if(exist('fieldin')*exist('Mobj')*exist('nLoops') == 0)
	error('arguments to smoothfield are missing')
end;

if(exist('SmoothPts'))
	nPts = length(SmoothPts);
else
45 46
	nPts       = Mobj.nElems;
	SmoothPts  = 1:Mobj.nElems;
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
end;

if(~Mobj.have_mets)
	error('cannot smooth field, need mesh metrics for smoothing, use setup_metrics')
end;

%------------------------------------------------------------------------------
% Smoothing Loops
%------------------------------------------------------------------------------

% initialize iteration
field = fieldin;

%iterate
for ll=1:nLoops;
	field = fieldin;
	for ii=1:nPts;
  		i = SmoothPts(ii);
  		for k=1:Mobj.ntsn(i); 
    		  node = Mobj.nbsn(i,k);
                  if(abs(field(node)) < abs(field(i))); fieldin(i) = field(node); end;
  		end;
	end;
end;
field = fieldin; 


%fprintf(['end   : ' subname '\n'])