StressCompute

PURPOSE ^

STRESSCOMPUTE - compute the stress field

SYNOPSIS ^

function stress=StressCompute(m,inputs,type);

DESCRIPTION ^

STRESSCOMPUTE - compute the stress field

   return a vector of size (numberofelements,1), holding the stress for 
   every element.

   Usage:
      stress=StressCompute(m,inputs,type)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function stress=StressCompute(m,inputs,type);
0002 %STRESSCOMPUTE - compute the stress field
0003 %
0004 %   return a vector of size (numberofelements,1), holding the stress for
0005 %   every element.
0006 %
0007 %   Usage:
0008 %      stress=StressCompute(m,inputs,type)
0009 
0010 %global variables
0011 global cluster gridset
0012 
0013 %recover fem model fields
0014 elements=m.elements;
0015 grids=m.grids;
0016 materials=m.materials;
0017 loads=m.loads;
0018 gridset=m.gridset;
0019 
0020 %figure out active elements that will take part in the stiffness and load generation
0021 [n1,n2]=GetNumberOfActiveElements(elements);
0022 if strcmpi(type,'2d')
0023 
0024     %initialize vectors
0025     stress=struct('xx',[],'yy',[],'xy',[],'principalvalue1',[],'principalaxis1',[],'principalvalue2',[],'principalaxis2',[]);
0026     stress1=zeros((n2-n1)+1,3);
0027     A1=zeros((n2-n1)+1,1); Vx1=zeros((n2-n1)+1,1); Vy1=zeros((n2-n1)+1,1); Vz1=zeros((n2-n1)+1,1);
0028     A2=zeros((n2-n1)+1,1); Vx2=zeros((n2-n1)+1,1); Vy2=zeros((n2-n1)+1,1); Vz2=zeros((n2-n1)+1,1);
0029 
0030     %Go through all elements and call the stress routine, then compute eigen values and vector
0031     for n=n1:n2,
0032         if ~isempty(elements(n).element),
0033             stressvector=Stress(elements(n).element,grids,materials,inputs)';
0034 
0035             stressmatrix=[stressvector(1) stressvector(3)
0036                       stressvector(3)  stressvector(2)];
0037 
0038             %eigen values and vectors
0039             [directions,value]=eig(stressmatrix);
0040 
0041                         %Plug into global vectors
0042             stress1(n,:)=stressvector;
0043                         A1(n,1)=value(1,1); A2(n,1)=value(2,2);
0044                         Vx1(n,1)=directions(1,1); Vx2(n,1)=directions(1,2);
0045                         Vy1(n,1)=directions(2,1); Vy2(n,1)=directions(2,2);
0046         end
0047     end
0048 
0049     %plug results into outputs
0050     %NB: Matlab sorts the eigen value in increasing order, we want the reverse
0051     %components
0052     stress.xx=stress1(:,1);
0053     stress.yy=stress1(:,2);
0054     stress.xy=stress1(:,3);
0055     %principal axis
0056     stress.principalvalue2=A1;
0057     stress.principalaxis2=[Vx1 Vy1];
0058     stress.principalvalue1=A2;
0059     stress.principalaxis1=[Vx2 Vy2];
0060     %norm or effective value
0061     stress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+2*stress.xy.^2);
0062 
0063 else
0064     %initialize vectors
0065     stress=struct('xx',[],'yy',[],'zz',[],'xy',[],'xz',[],'yz',[],'principalvalue1',[],'principalaxis1',[],'principalvalue2',[],'principalaxis2',[],'principalvalue3',[],'principalaxis3',[]);
0066     stress1=zeros((n2-n1)+1,6);
0067     A1=zeros((n2-n1)+1,1); Vx1=zeros((n2-n1)+1,1); Vy1=zeros((n2-n1)+1,1); Vz1=zeros((n2-n1)+1,1);
0068     A2=zeros((n2-n1)+1,1); Vx2=zeros((n2-n1)+1,1); Vy2=zeros((n2-n1)+1,1); Vz2=zeros((n2-n1)+1,1);
0069     A3=zeros((n2-n1)+1,1); Vx3=zeros((n2-n1)+1,1); Vy3=zeros((n2-n1)+1,1); Vz3=zeros((n2-n1)+1,1);
0070 
0071     %Go through all elements and call the stress routine, then compute eigen values and vector
0072     for n=n1:n2,
0073         if ~isempty(elements(n).element),
0074             stressvector=Stress(elements(n).element,grids,materials,inputs)';
0075 
0076             stressmatrix=[stressvector(1) stressvector(4) stressvector(5)
0077                       stressvector(4)  stressvector(2)  stressvector(6)
0078                       stressvector(5)  stressvector(6)  stressvector(3)];
0079 
0080             %eigen values and vectors
0081             [directions,value]=eig(stressmatrix);
0082 
0083                         %Plug into global vectors
0084             stress1(n,:)=stressvector;
0085                         A1(n,1)=value(1,1); A2(n,1)=value(2,2); A3(n,1)=value(3,3);
0086                         Vx1(n,1)=directions(1,1); Vx2(n,1)=directions(1,2); Vx3(n,1)=directions(1,3);
0087                         Vy1(n,1)=directions(2,1); Vy2(n,1)=directions(2,2); Vy3(n,1)=directions(2,3);
0088                         Vz1(n,1)=directions(3,1); Vz2(n,1)=directions(3,2); Vz3(n,1)=directions(3,3);
0089         end
0090     end
0091 
0092     %plug results into outputs
0093     %NB: Matlab sorts the eigen value in increasing order, we want the reverse
0094     %components
0095     stress.xx=stress1(:,1);
0096     stress.yy=stress1(:,2);
0097     stress.zz=stress1(:,3);
0098     stress.xy=stress1(:,4);
0099     stress.xz=stress1(:,5);
0100     stress.yz=stress1(:,6);
0101     %principal axis
0102     stress.principalvalue3=A1;
0103     stress.principalaxis3=[Vx1 Vy1 Vz1];
0104     stress.principalvalue2=A2;
0105     stress.principalaxis2=[Vx2 Vy2 Vz2];
0106     stress.principalvalue1=A3;
0107     stress.principalaxis1=[Vx3 Vy3 Vz3];
0108     %norm or effective value
0109     stress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+stress.zz.^2+2*stress.xy.^2+2*stress.xz.^2+2*stress.yz.^2);
0110 end

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