Home > vbmeg > external > iso2mesh > surfdiffuse.m

surfdiffuse

PURPOSE ^

SYNOPSIS ^

function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)

DESCRIPTION ^

 valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)

 apply a smoothing/diffusion process on a surface

 author: Qianqian Fang, <q.fang at neu.edu>

 input:
     node: list of nodes of the surface mesh
     tri: triangular element list of the surface
     val: vector, scalar value for each node
     ddt: diffusion coefficient multiplied by delta t
     iter: iterations for applying the smoothing
     type1: indices of the nodes which will not be updated
     opt: method, 'grad' for gradient based, and 'simple' for simple average

 output:
     valnew: nodal value vector after the smoothing

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
0002 %
0003 % valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
0004 %
0005 % apply a smoothing/diffusion process on a surface
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 %
0009 % input:
0010 %     node: list of nodes of the surface mesh
0011 %     tri: triangular element list of the surface
0012 %     val: vector, scalar value for each node
0013 %     ddt: diffusion coefficient multiplied by delta t
0014 %     iter: iterations for applying the smoothing
0015 %     type1: indices of the nodes which will not be updated
0016 %     opt: method, 'grad' for gradient based, and 'simple' for simple average
0017 %
0018 % output:
0019 %     valnew: nodal value vector after the smoothing
0020 %
0021 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0022 %
0023 
0024 if(iscell(tri))
0025     conn=tri;
0026 else
0027     conn=meshconn(tri,size(node,1));
0028 end
0029 valnew=val;
0030 nn=size(node,1);
0031 
0032 nontype1=1:nn;
0033 nontype1(type1)=[];
0034 ninner=length(nontype1);
0035 updateflag=zeros(ninner,1);
0036 
0037 if(strcmp(opt,'grad'))
0038     for i=1:iter
0039        for j=1:ninner
0040            jj=nontype1(j);
0041            neighbors=conn{jj};
0042            dist=node(neighbors,:);
0043            dist(:,1)=dist(:,1)-node(jj,1);
0044            dist(:,2)=dist(:,2)-node(jj,2);
0045            dist(:,3)=dist(:,3)-node(jj,3);
0046            c0=sqrt(sum((dist.*dist)'));
0047            neighbors(find(c0==0))=[];
0048            valnew(jj)=val(jj)+ddt*sum((val(neighbors)'-val(jj))./c0);
0049        end
0050        val=valnew;
0051     end
0052 elseif(strcmp(opt,'simple'))
0053     for i=1:iter
0054        for j=1:ninner
0055            jj=nontype1(j);
0056            if(~isempty(conn{jj}))
0057                valnew(jj)=(1-ddt)*val(jj)+ddt*mean((val(conn{jj})'));
0058            end
0059        end
0060        val=valnew;
0061     end
0062 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005