


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
==============================================================================

0001 function [field] = smoothfield2(fieldin,Mobj,nLoops,SmoothPts) 0002 0003 % Smooth a vertex-based field using minimum value of surrounding nodes 0004 % 0005 % [field] = function smoothfield(fieldin,Mobj,nLoops,SmoothPts) 0006 % 0007 % DESCRIPTION: 0008 % Smooth a vertex based field 0009 % 0010 % INPUT 0011 % Mobj = Matlab mesh object 0012 % fielin = vertex based field 0013 % nLoops = number of smoothing iterations 0014 % SmoothPts = list of vertices to smooth [optional, default = all] 0015 % 0016 % OUTPUT: 0017 % field = smoothed, vertex-based field 0018 % 0019 % EXAMPLE USAGE 0020 % Mobj.h = smoothfield(Mobj.h,Mobj,0.5,4) 0021 % 0022 % Author(s): 0023 % Geoff Cowles (University of Massachusetts Dartmouth) 0024 % 0025 % Revision history 0026 % 0027 %============================================================================== 0028 global ftbverbose 0029 [~, subname] = fileparts(mfilename('fullpath')); 0030 if ftbverbose 0031 fprintf('\nbegin : %s\n', subname) 0032 end 0033 0034 %------------------------------------------------------------------------------ 0035 % Parse input 0036 %------------------------------------------------------------------------------ 0037 0038 if(exist('fieldin')*exist('Mobj')*exist('nLoops') == 0) 0039 error('arguments to smoothfield are missing') 0040 end; 0041 0042 if(exist('SmoothPts')) 0043 nPts = length(SmoothPts); 0044 else 0045 nPts = Mobj.nElems; 0046 SmoothPts = 1:Mobj.nElems; 0047 end; 0048 0049 if(~Mobj.have_mets) 0050 error('cannot smooth field, need mesh metrics for smoothing, use setup_metrics') 0051 end; 0052 0053 %------------------------------------------------------------------------------ 0054 % Smoothing Loops 0055 %------------------------------------------------------------------------------ 0056 0057 % initialize iteration 0058 field = fieldin; 0059 0060 %iterate 0061 for ll=1:nLoops; 0062 field = fieldin; 0063 for ii=1:nPts; 0064 i = SmoothPts(ii); 0065 for k=1:Mobj.ntsn(i); 0066 node = Mobj.nbsn(i,k); 0067 if(abs(field(node)) < abs(field(i))); fieldin(i) = field(node); end; 0068 end; 0069 end; 0070 end; 0071 field = fieldin; 0072 0073 0074 %fprintf(['end : ' subname '\n']) 0075