U:\FE.m
1 of 13
10/31/14 4:12 PM
% handles
% varargin
U:\FE.m
% --- Outputs from this function are returned to the command line.
function varargout = FE_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
2 of 13
10/31/14 4:12 PM
U:\FE.m
3 of 13
10/31/14 4:12 PM
U:\FE.m
Y1=arb_cor_t(2,1);
X2=arb_cor_t(1,2);
Y2=arb_cor_t(2,2);
X3=arb_cor_t(1,3);
Y3=arb_cor_t(2,3);
Ma=zeros(3,3);
Ma(1,1)=Y2-Y3;
Ma(1,2)=X3-X2;
Ma(1,3)=X2*Y3-X3*Y2;
Ma(2,1)=Y3-Y1;
Ma(2,2)=X1-X3;
Ma(2,3)=X3*Y1-X1*Y3;
Ma(3,1)=Y1-Y2;
Ma(3,2)=X2-X1;
Ma(3,3)=X1*Y2-X2*Y1;
4 of 13
10/31/14 4:12 PM
U:\FE.m
B_Voigt(1,4)=0;
B_Voigt(1,5)=(Y1-Y2)/(2*A0);
B_Voigt(1,6)=0;
B_Voigt(2,1)=0;
B_Voigt(2,2)=(X3-X2)/(2*A0);
B_Voigt(2,3)=0;
B_Voigt(2,4)=(X1-X3)/(2*A0);
B_Voigt(2,5)=0;
B_Voigt(2,6)=(X2-X1)/(2*A0);
B_Voigt(3,1)=(X3-X2)/(2*A0);
B_Voigt(3,2)=(Y2-Y3)/(2*A0);
B_Voigt(3,3)=(X1-X3)/(2*A0);
B_Voigt(3,4)=(Y3-Y1)/(2*A0);
B_Voigt(3,5)=(X2-X1)/(2*A0);
B_Voigt(3,6)=(Y1-Y2)/(2*A0);
disp('B matrix in voigt notation')
B_Voigt
5 of 13
10/31/14 4:12 PM
U:\FE.m
6 of 13
nodal_v=zeros(6,1);
arb_stress_v= zeros(3,1);
arb_stress_v(1,1)=arb_streses_t(1,1);
arb_stress_v(2,1)=arb_streses_t(2,2);
arb_stress_v(3,1)=arb_streses_t(1,2);
arb_stress_v;
nodal_v= transpose(B_Voigt)*arb_stress_v
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif (status_1==0 & status_2==1 & status_3==0)
clear all
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Quadrilateral Element Selected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Arbitary coordinates')
filename_1 = 'arbitary_coordinates.dat';
arb_cor=csvread(filename_1);
disp('Arbitary coordinates')
arb_cor_t=zeros(2,4);
for i=1:2
for j=1:4
arb_cor_t(i,j)=arb_cor(i,j);
end
end
arb_cor_t
filename_2 = 'arbitary_velocities.dat';
arb_velo=csvread(filename_2);
disp('Arbitary velocities')
arb_velo_t=zeros(2,4);
for i=1:2
for j=1:4
arb_velo_t(i,j)=arb_velo(i,j);
end
end
arb_velo_t
filename_3 = 'arbitary_stresses.dat';
arb_stress=csvread(filename_3);
disp('Arbitary stresses')
10/31/14 4:12 PM
U:\FE.m
arb_streses_t=zeros(2,2);
for i=1:2
for j=1:2
arb_streses_t(i,j)=arb_stress(i,j);
end
end
arb_streses_t
X1=arb_cor_t(1,1);
Y1=arb_cor_t(2,1);
X2=arb_cor_t(1,2);
Y2=arb_cor_t(2,2);
X3=arb_cor_t(1,3);
Y3=arb_cor_t(2,3);
X4=arb_cor_t(1,4);
Y4=arb_cor_t(2,4);
syms z n X Y ;
N1=(1-z)*(1-n)/4;
dN1z= diff(N1, z, 1);
dN1n= diff(N1, n, 1);
N2=(1+z)*(1-n)/4;
dN2z= diff(N2, z, 1);
dN2n= diff(N2, n, 1);
N3=(1+z)*(1+n)/4;
dN3z= diff(N3, z, 1);
dN3n= diff(N3, n, 1);
N4=(1-z)*(1+n)/4;
dN4z= diff(N4, z, 1);
dN4n= diff(N4, n, 1);
%zeta and eta in local coordinates
X=N1*X1+N2*X2+N3*X3+N4*X4;
Y=N1*Y1+N2*Y2+N3*Y3+N4*Y4;
J=zeros(2,2);
J=[diff(X, z, 1),diff(X, n, 1);diff(Y, z, 1),diff(Y, n, 1)];
J_inv=inv(J);
detJ=det(J);
syms z n
B_Matrix = J_inv*[dN1z,dN2z,dN3z,dN4z;dN1n,dN2n,dN3n,dN4n];
Lij= B_Matrix*transpose(arb_velo_t);
7 of 13
10/31/14 4:12 PM
U:\FE.m
%vogit notation
%arbitary velocity
arb_velo_v=zeros(8,1);
for i=1:4
arb_velo_v(2*i-1,1)=arb_velo_t(1,i);
arb_velo_v(2*i,1)=arb_velo_t(2,i);
end
for i=1:4
B_Voigt(1,2*i-1)=B_Matrix(1,i);
B_Voigt(1,2*i)= 0;
B_Voigt(2,2*i)=B_Matrix(2,i);
B_Voigt(2,2*i-1)= 0;
B_Voigt(3,2*i-1)=B_Matrix(2,i);
B_Voigt(3,2*i)= 0;
end
B_Voigt;
8 of 13
10/31/14 4:12 PM
U:\FE.m
9 of 13
z=0;
n=0;
B_matrix_in_Voigt_notation_at_center_of_element=eval(B_Voigt)
Li_voigt=B_Voigt*arb_velo_v;
z=0;
n=0;
Rate_of_deformation_matrix_at_center_voigt_form=eval(Li_voigt)
%nodal forces in voigt form
Nodal_forces_v=zeros(8,1);
for i=1:4
Nodal_forces_v(2*i-1,1)=Nodal_forces_m(i,1);
Nodal_forces_v(2*i,1)=Nodal_forces_m(i,2);
end
Nodal_forces_in_Quadilateral_element_in_voigt_form=Nodal_forces_v
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of Quadrilateral Element calculation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif (status_1==0 & status_2==0 & status_3==1)
clear all
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 Nodal Brick Element Selected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Arbitary coordinates')
filename_1 = 'arbitary_coordinates.dat';
arb_cor=csvread(filename_1)
disp('Arbitary velocities')
filename_2 = 'arbitary_velocities.dat';
arb_velo=csvread(filename_2);
disp('Arbitary stresses')
filename_3 = 'arbitary_stresses.dat';
arb_stress=csvread(filename_3);
X1=arb_cor(1,1);
Y1=arb_cor(2,1);
Z1=arb_cor(3,1);
X2=arb_cor(1,2);
Y2=arb_cor(2,2);
Z2=arb_cor(3,2);
10/31/14 4:12 PM
U:\FE.m
X3=arb_cor(1,3);
Y3=arb_cor(2,3);
Z3=arb_cor(3,3);
X4=arb_cor(1,4);
Y4=arb_cor(2,4);
Z4=arb_cor(3,4);
X5=arb_cor(1,5);
Y5=arb_cor(2,5);
Z5=arb_cor(3,5);
X6=arb_cor(1,6);
Y6=arb_cor(2,6);
Z6=arb_cor(3,6);
X7=arb_cor(1,7);
Y7=arb_cor(2,7);
Z7=arb_cor(3,7);
X8=arb_cor(1,8);
Y8=arb_cor(2,8);
Z8=arb_cor(3,8);
arb_velo=zeros(3,8);
arb_velo = [1,2,3,6,8,12,16,5;5,6,8,10,5,6,7,8;14,12,26,19,18,36,14,10];
arb_stress=zeros(3,3);
arb_stress = [1000,5000,2500;5000,4500,6000;2500,6000,7000];
syms z n s X Y Z;
N1=(1-z)*(1-n)*(1-s)/8;
dN1z= diff(N1, z, 1)/8;
dN1n= diff(N1, n, 1)/8;
dN1s= diff(N1, s, 1)/8;
N2=(1+z)*(1-n)*(1-s)/8;
dN2z= diff(N2, z, 1)/8;
dN2n= diff(N2, n, 1)/8;
dN2s= diff(N2, s, 1)/8;
N3=(1+z)*(1+n)*(1-s)/8;
dN3z= diff(N3, z, 1)/8;
dN3n= diff(N3, n, 1)/8;
dN3s= diff(N3, s, 1)/8;
N4=(1-z)*(1+n)*(1-s)/8;
dN4z= diff(N4, z, 1)/8;
dN4n= diff(N4, n, 1)/8;
dN4s= diff(N4, s, 1)/8;
10 of 13
10/31/14 4:12 PM
U:\FE.m
11 of 13
N5=(1-z)*(1-n)*(1+s)/8;
dN5z= diff(N5, z, 1)/8;
dN5n= diff(N5, n, 1)/8;
dN5s= diff(N5, s, 1)/8;
N6=(1+z)*(1-n)*(1+s)/8;
dN6z= diff(N6, z, 1)/8;
dN6n= diff(N6, n, 1)/8;
dN6s= diff(N6, s, 1)/8;
N7=(1+z)*(1+n)*(1+s)/8;
dN7z= diff(N7, z, 1)/8;
dN7n= diff(N7, n, 1)/8;
dN7s= diff(N7, s, 1)/8;
N8=(1-z)*(1+n)*(1+s)/8;
dN8z= diff(N8, z, 1)/8;
dN8n= diff(N8, n, 1)/8;
dN8s= diff(N8, s, 1)/8;
10/31/14 4:12 PM
U:\FE.m
end
nodalf=Int_B*arb_stress;
z=0;
n=0;
s=0;
Nodal_forces_in_brick_element_in_matrix_form=eval(nodalf)
%Voigt form
arb_velo_v=zeros(24,1);
for i=1:8
arb_velo_v(3*i-2,1)=arb_velo(1,i);
arb_velo_v(3*i-1,1)=arb_velo(2,i);
arb_velo_v(3*i,1)=arb_velo(3,i);
end
for i=1:8
B_Voigt(1,3*i-2)=B_Matrix(1,i);
B_Voigt(1,3*i-1)= 0;
B_Voigt(1,3*i)= 0;
B_Voigt(2,3*i-1)=B_Matrix(2,i);
B_Voigt(2,3*i-2)= 0;
B_Voigt(2,3*i)= 0;
B_Voigt(3,3*i)=B_Matrix(3,i);
B_Voigt(2,3*i-2)= 0;
B_Voigt(1,3*i-1)= 0;
B_Voigt(4,3*i)=B_Matrix(2,i);
B_Voigt(4,3*i-2)= 0;
B_Voigt(4,3*i-1)= 0;
B_Voigt(5,3*i-1)=B_Matrix(1,i);
B_Voigt(5,3*i-2)= 0;
B_Voigt(5,3*i)= 0;
B_Voigt(6,3*i-1)=B_Matrix(1,i);
B_Voigt(6,3*i-2)= 0;
B_Voigt(6,3*i)= 0;
end
B_Voigt;
Li_voigt=B_Voigt*arb_velo_v;
z=0;
n=0;
s=0;
B_voigt_form_at_center_of_parent_element=eval(B_Voigt)
Rate_of_deformation_matrix_at_center_voigt_form=eval(Li_voigt)
12 of 13
10/31/14 4:12 PM
U:\FE.m
13 of 13