Calculate and Assembly Stiffness Matrix in Parfor Loop
조회 수: 7 (최근 30일)
이전 댓글 표시
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!