You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.2 KiB

%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-03-30 14:04:30
% @LastEditTime: 2021-09-28 12:51:21
% re-divide rho based on subdomain because subdomain != macro ele
%--------------------------
function [rho] = redivide_rho(global_rho, nelx, nely, microx, opt_order)
switch opt_order
case 'global'
[rho] = redivide_rho1(global_rho, nelx, nely, microx);
case 'cell'
[rho] = redivide_rho2(global_rho, nelx, nely, microx)
end
end
% global_rho is ordered as global-order
function [rho] = redivide_rho1(global_rho, nelx, nely, microx)
global_rho = reshape(global_rho, nely*microx, nelx*microx);
rho = cell(nely, nelx);
for i = 1:nelx
for j = 1:nely
rho{j, i} = global_rho((j-1)*microx+1 : j*microx, (i-1)*microx+1 : i*microx);
end
end
end
% global_rho is ordered as each macro-cell
function [rho] = redivide_rho2(global_rho, nelx, nely, microx)
rho = cell(nely, nelx);
nele_micro = microx^2;
for i = 1:nelx
for j = 1:nely
ele = (i-1) * nely + j;
rho{j, i} = global_rho((ele-1)*nele_micro+1 : ele*nele_micro);
end
end
end