Calculate and Assembly Stiffness Matrix in Parfor Loop

8 visualizzazioni (ultimi 30 giorni)
Hello,
I am working on extensive lattice networks, so I need to deal with very big stiffness matrices and enormous numbers of degrees of freedom. For this reason I am trying to parallelize the calculation of the stiffness matrix and the sectional response in order to speed the process up. Anyways, I couldn't make it work. My code looks like this
for i=1:number_steps
iterations = 0; % Initialize Iterations counter
K = zeros(dof,dof); % Initialize Stiffness Matrix
for ii=1:number_elements
id_i = Connectivity_Matrix(ii,1); % Retreive 1st node id
id_j = Connectivity_Matrix(ii,2); % Retreive 2nd node id
displacement = retreive_displacement(id_i,id_j,disp);
K_e = k_matrix(id_i,id_j,parameters,displacement);
K(gdl_n*id_1-(gdl_n-1):gdl_n*id_1,gdl_n*id_1-(gdl_n-1):gdl_n*id_1) = K(gdl_n*id_1-(gdl_n-1):gdl_n*id_1,gdl_n*id_1-(gdl_n-1):gdl_n*id_1) + K_e(1:gdl_n,1:gdl_n); % Direct Stiffness Assembly
end
end
The code runs smoothly up to the calculation of the element stiffness matrix (K_e). The error comes up when trying to assembly the global stiffness matrix by adding the single elements contribution in the proper position. The problem arises because the K matrix is indexed through a variable that changes inside the loop, which is of course inevitable because the id of the nodes of the bar needs to be updated for every element. I thought I could just store all the element stiffness matrices in a cell and then add them up outside the parfoor loop, but this is clearly not very efficient, since I will need an extra for loop. Any ideas?
Thanks.
  1 Commento
Alessandro
Alessandro il 12 Feb 2015
Idea #2: what if I calculate all the values used to indicize the K matrix outside the parfor loop?

Accedi per commentare.

Risposte (1)

Alessandro
Alessandro il 16 Feb 2015
Up

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by