Assembling global matrix from element matrices based on location.
2 views (last 30 days)
I need to assemble a global matrix by taking the coefficients for each node from all the elements and adding them together.
These are the three element coefficient matrices.
Element 1: [a11 a12 a13; a21 a22 a23; a31 a32 a33]
Element 2: [a33 a32 a34; a23 a22 a24; a43 a42 a44]
Element 3: [a11 a13 a14; a31 a33 a34; a41 a43 a44]
This is what the global matrix needs to become...
Global: [sum(a11) sum(a12) sum(a13) sum(a14); sum(a21) sum(a22) sum(a23) sum(a24); sum(a31) sum(a32) sum(a33) sum(a34); sum(a41) sum(a42) sum(a43) sum(a44)]
As you can see I need to identify values in the element matrix based on their a(i,j) values and then find the sum of those values for the global matrix. FYI the a11 value for one element is different than the a11 value for another. This applies to all values.
Does anybody have any ideas as to how I should approach this?
Precise Simulation on 1 Nov 2017
Normally you would have a list of integer pointers between local and global degrees of freedom constructed from the mesh connectivities to help you assign the local element matrix in the global. Only in very simple cases, like perhaps for 1D linear elements, can you avoid this.