% exA.m - matlab example for frame3dd Example A 
% linear static analysis of a 2D truss with support settlement
% Matlab results are written to IOdata_m.m

%         x       y       z       r		node coordinates
XYZ = [ 0.0	0.0	0.0	0.0 ;
 	12.0	0.0	0.0	0.0 ;
 	24.0	0.0	0.0	0.0 ;
 	36.0	0.0	0.0	0.0 ;
 	48.0	0.0	0.0	0.0 ;
 	60.0	0.0	0.0	0.0 ;
 	72.0	0.0	0.0	0.0 ;
 	12.0	12.0	0.0	0.0 ;
 	24.0	12.0	0.0	0.0 ;
  	36.0	12.0	0.0	0.0 ;
  	48.0	12.0	0.0	0.0 ;
  	60.0	12.0	0.0	0.0 ]';

[x,J] = size(XYZ);

RCT = zeros(6,J);			% reactions

%   J         x y z xx yy zz	1= fixed, 0=free
RCT(:, 1) = [ 1 1 1  1  1  0 ]';
RCT(:, 2) = [ 0 0 1  1  1  0 ]';
RCT(:, 3) = [ 0 0 1  1  1  0 ]';
RCT(:, 4) = [ 0 0 1  1  1  0 ]';
RCT(:, 5) = [ 0 0 1  1  1  0 ]';
RCT(:, 6) = [ 0 0 1  1  1  0 ]';
RCT(:, 7) = [ 0 1 1  1  1  0 ]';
RCT(:, 8) = [ 1 0 1  1  1  0 ]';
RCT(:, 9) = [ 0 0 1  1  1  0 ]';
RCT(:,10) = [ 0 0 1  1  1  0 ]';
RCT(:,11) = [ 0 0 1  1  1  0 ]';
RCT(:,12) = [ 0 0 1  1  1  0 ]';

ELTS = [ 1  2  3  4  5  6  1  2  2  3  4  4  4  5  6  6  7  8  9 10 11 ;
         2  3  4  5  6  7  8  8  9  9  9 10 11 11 11 12 12  9 10 11 12 ];

[x,B] = size(ELTS);

%         Ax    Asy     Asz     Jxx     Iyy     Izz          E     G  p dens.

EAIJ=[	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001;
	30.0	1.0	1.0	1.0	1.0	0.01	10000.0 500.0 0 0.001]';

P= zeros(6,J);			% point forces

%   J      Fx     Fy     Fz     Mxx     Myy     Mzz
P(:,2) = [ 0.0	-20.0	0.0	0.0	0.0	0.0 ]';
P(:,3) = [ 0.0	-40.0	0.0	0.0	0.0	0.0 ]';
P(:,4) = [ 0.0	-30.0  	0.0	0.0	0.0	0.0 ]';
P(:,5) = [ 0.0	-10.0  	0.0	0.0	0.0	0.0 ]';
P(:,6) = [ 0.0	-30.0  	0.0	0.0	0.0	0.0 ]';

W = zeros(3,B);

D = zeros(6,J);			% prescribed displacements
%    J         Dx     Dy      Dz      Dxx     Dyy     Dzz
D(:, 8) = [  0.01    0.0      0.0	0.0	0.0	0.0 ]';

[D,R,F,L,Ks] = frame_3dd ( XYZ,ELTS,RCT,EAIJ,P,W,D );  % analyze it!

