DeviatoricStressCompute

PURPOSE ^

DEVIATORICSTRESSCOMPUTE - compute the deviatoric stress components

SYNOPSIS ^

function deviatoricstress=DeviatoricStressCompute(m,inputs,type);

DESCRIPTION ^

DEVIATORICSTRESSCOMPUTE - compute the deviatoric stress components

   Usage:
      deviatoricstress=DeviatoricStressCompute(m,inputs,type)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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