Home > fvcom_prepro > smoothfield2.m

smoothfield2

PURPOSE ^

Smooth a vertex-based field using minimum value of surrounding nodes

SYNOPSIS ^

function [field] = smoothfield(fieldin,Mobj,nLoops,SmoothPts)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [field]  = smoothfield(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 subname = 'smoothfield';
0029 %fprintf('\n')
0030 %fprintf(['begin : ' subname '\n'])
0031 
0032 %------------------------------------------------------------------------------
0033 % Parse input
0034 %------------------------------------------------------------------------------
0035 
0036 if(exist('fieldin')*exist('Mobj')*exist('nLoops') == 0)
0037     error('arguments to smoothfield are missing')
0038 end;
0039 
0040 if(exist('SmoothPts'))
0041     nPts = length(SmoothPts);
0042 else
0043     nPts       = Mobj.nVerts;
0044     SmoothPts  = 1:Mobj.nVerts;
0045 end;
0046 
0047 if(~Mobj.have_mets)
0048     error('cannot smooth field, need mesh metrics for smoothing, use setup_metrics')
0049 end;
0050 
0051 %------------------------------------------------------------------------------
0052 % Smoothing Loops
0053 %------------------------------------------------------------------------------
0054 
0055 % initialize iteration
0056 field = fieldin;
0057 
0058 %iterate
0059 for ll=1:nLoops;
0060     field = fieldin;
0061     for ii=1:nPts;
0062           i = SmoothPts(ii);
0063           for k=1:Mobj.ntsn(i); 
0064               node = Mobj.nbsn(i,k);
0065                   if(abs(field(node)) < abs(field(i))); fieldin(i) = field(node); end;
0066           end;
0067     end;
0068 end;
0069 field = fieldin; 
0070 
0071 
0072 %fprintf(['end   : ' subname '\n'])
0073

Generated on Tue 18-Dec-2012 12:37:31 by m2html © 2005