a 2D version
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.

57 lines
1.8 KiB

4 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-09-13 19:51:36
% @LastEditTime: 2021-09-18 16:46:18
% input:
% rho: density cell with size of [nele_ma ,1], nele_ma = nelx * nely
% lx: the length of the coarse element
% D0 & D1: the elastic tensors of two materials
% output:
% harm_u is the harmonic solutions for the optimization of NH
%--------------------------
function harm_u = prepare_h(rho, lx, D0, D1)
%% init
nele_ma = length(rho(:));
microx = size(rho{1}, 1);
% nele_mi = microx^2;
dx = lx / microx;
opt_PBC = 0; % opt_PBC is 1 => adopts PBC conditions, 0 => adopts second-order conditions
harm_u = cell(nele_ma,1); % [nnodes, 6 or 9]
optKE = 2;
ke0 = intKE(dx/2, dx/2, D0, optKE);
ke1 = intKE(dx/2, dx/2, D1, optKE);
[iK_mi, jK_mi, edofMat_mi, ~] = forAssemble(microx, microx);
%% boundary conditions
if opt_PBC == 1
[wfixed, ufixed,d1,d2,d3,d4] = microPBC(microx, microx, lx, lx);
else
[coorx_nodes,coory_nodes] = meshgrid(-lx/2:dx:lx/2, -lx/2:dx:lx/2);
coory_nodes = flipud(coory_nodes);
[ufixed, fixeddofs_mi, freedofs_mi] = microQBC(microx, microx, coorx_nodes, coory_nodes);
end
%% computation
optBodyF = 1; % 'zero';
% optBodyF = 2; % 'effectivity';
% optBodyF = 3; % 'point-wise';
for ele_ma = 1:nele_ma
material = rho{ele_ma};
if opt_PBC == 1
harm_u{ele_ma} = microFEAsimp(microx, microx, iK_mi, jK_mi, d1, d2, d3, d4, ufixed, wfixed, ...
material, ke0, ke1);
else
harm_u{ele_ma} = microFEA_QBC_2mat(D0, D1, ke0, ke1, iK_mi, jK_mi, edofMat_mi, dx, dx, ...
optBodyF, ufixed, freedofs_mi, fixeddofs_mi, material, coorx_nodes, coory_nodes);
end
end
end