slope

PURPOSE ^

SLOPE - compute the surface slope

SYNOPSIS ^

function [sx,sy,s]=slope(md)

DESCRIPTION ^

SLOPE - compute the surface slope

   Usage:
      [sx,sy,s]=slope(md)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sx,sy,s]=slope(md)
0002 %SLOPE - compute the surface slope
0003 %
0004 %   Usage:
0005 %      [sx,sy,s]=slope(md)
0006 
0007 %load some variables (it is much faster if the variab;es are loaded from md once for all)
0008 if strcmpi(md.type,'2d'),
0009     numberofelements=md.numberofelements;
0010     numberofgrids=md.numberofgrids;
0011     index=md.elements;
0012     x=md.x; y=md.y; z=md.z;
0013 else
0014     numberofelements=md.numberofelements2d;
0015     numberofgrids=md.numberofgrids2d;
0016     index=md.elements2d;
0017     x=md.x2d; y=md.y2d; z=md.z2d;
0018 end
0019 
0020 %initialization
0021 alpha=zeros(numberofelements,3);
0022 beta=zeros(numberofelements,3);
0023 
0024 %build some usefull variables
0025 summation=1/3*ones(3,1);
0026 x1=x(index(:,1)); x2=x(index(:,2)); x3=x(index(:,3)); y1=y(index(:,1)); y2=y(index(:,2)); y3=y(index(:,3));
0027 
0028 %compute nodal functions coefficients N(x,y)=alpha x + beta y + gamma
0029 invdet=1./(x1.*(y2-y3)-x2.*(y1-y3)+x3.*(y1-y2));
0030 alpha=[invdet.*(y2-y3) invdet.*(y3-y1) invdet.*(y1-y2)];
0031 beta=[invdet.*(x3-x2) invdet.*(x1-x3) invdet.*(x2-x1)];
0032 
0033 summation=[1;1;1];
0034 sx=(md.surface(index).*alpha)*summation;
0035 sy=(md.surface(index).*beta)*summation;
0036 s=sqrt(sx.^2+sy.^2);
0037 
0038 if strcmpi(md.type,'3d'),
0039     sx=project3d(md,sx,'element');
0040     sy=project3d(md,sy,'element');
0041     s=sqrt(sx.^2+sy.^2);
0042 end

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