November 9, 2012

I was wondering what the technique is called that you used on the K matrix before solving for U? The one where it takes the BC and makes 0 rows and columns, and then makes the K(i,i)=1 at the BC – GoPDemon

I first convert the boundary matrix into a vector so that it is easier to deal with. The code just creates an empty vector the correct size, then fills it with the rows and columns of the user defined boundary points.

%First boundarys must be convertered to vector
%Create empty boundary vector
BC(1:(size(nodes,1)*n_multi),1) = 0;
%Zero column increment
h = 1;

%Convert boundary matrix to vector
for node_r = 1:size(nodal_boundary,1)
%For each row get the column force
for node_c = 1:size(nodal_boundary,2)
%Put the force into the vector F
BC(h) = nodal_boundary(node_r, node_c);
h = h+1;
end
end


Then, to apply to boundary conditions to the stiffness matrix, I scan the new vector BC for fixed points (1). At these points, the row and column of K is zero’d and the diagonal set to 1.

%Loop to zero forces at boundaries
for i = 1:size(BC,1)
%If statement to set lines and columns coresponding to constrained
%point to zero
if BC(i) == 1
K(i,:) = 0;
K(:,i) = 0;
%Set diagonal term to 1
K(i,i) = 1;
%Zero force at boundary
F(i) = 0;
end
end


Hope that was the explanation you meant.