Calculate and Assembly Stiffness Matrix in Parfor Loop

7 visualizaciones (últimos 30 días)
Alessandro
Alessandro el 11 de Feb. de 2015
Respondida: Alessandro el 16 de Feb. de 2015
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 comentario
Alessandro
Alessandro el 12 de Feb. de 2015
Idea #2: what if I calculate all the values used to indicize the K matrix outside the parfor loop?

Iniciar sesión para comentar.

Respuestas (1)

Alessandro
Alessandro el 16 de Feb. de 2015
Up

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by