' First multiply k_local * T
Dim i As Integer, j As Integer, k As Integer
For i = 1 To 6
For j = 1 To 6
temp(i, j) = 0
For k = 1 To 6
temp(i, j) = temp(i, j) + k_local(i, k) * T(k, j)
Next k
Next j
Next i
' Then multiply T' * (k_local * T)
For i = 1 To 6
For j = 1 To 6
k_global_elem(i, j) = 0
For k = 1 To 6
k_global_elem(i, j) = k_global_elem(i, j) + T(k, i) *
temp(k, j)
Next k
Next j
Next i
' Get global DOF indices
Dim dof_indices(1 To 6) As Integer
dof_indices(1) = 3 * (e.node1 - 1) + 1 ' ux1
dof_indices(2) = 3 * (e.node1 - 1) + 2 ' uy1
dof_indices(3) = 3 * (e.node1 - 1) + 3 ' θz1
dof_indices(4) = 3 * (e.node2 - 1) + 1 ' ux2
dof_indices(5) = 3 * (e.node2 - 1) + 2 ' uy2
dof_indices(6) = 3 * (e.node2 - 1) + 3 ' θz2
' Add to global stiffness matrix
For i = 1 To 6
For j = 1 To 6
K_global(dof_indices(i), dof_indices(j)) =
K_global(dof_indices(i), dof_indices(j)) + k_global_elem(i, j)
Next j
Next i
Next elemId
' Apply boundary conditions
Dim fixed_dofs() As Integer
ReDim fixed_dofs(1 To totalDof) ' Will be resized later
Dim num_fixed As Integer
num_fixed = 0
Dim nodeId As Integer
For nodeId = 1 To nodes.Count
On Error Resume Next
Dim s As Support
Set s = supports("S" & nodeId)
If Not s Is Nothing Then
Select Case s.supportType
Case "fixed"
' Fix all DOFs
fixed_dofs(num_fixed + 1) = 3 * (nodeId - 1) + 1 ' ux
P a g e 44 | 62