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.
82 lines
2.4 KiB
82 lines
2.4 KiB
%--------------------------
|
|
% @Author: Jingqiao Hu
|
|
% @Date: 2021-03-31 20:20:38
|
|
% @LastEditTime: 2021-06-16 19:15:15
|
|
%--------------------------
|
|
function [regulated_matrix, dFdx, B, NH] = precomputation_3mat(eleNum_ma, microx, rho, bezier_B, ke0, ke1, ke2, iK_mi, jK_mi, ...
|
|
bdofs_num, dofid, edofMat_mi, dx, nelx, nely)
|
|
|
|
eleNum_mi = microx^2;
|
|
regulated_matrix = cell(eleNum_ma, 1);
|
|
B = cell(eleNum_ma, 1);
|
|
dFdx = cell(4, eleNum_ma);
|
|
|
|
bezier_B = sparse(bezier_B);
|
|
order1 = reshape(edofMat_mi', [], 1);
|
|
|
|
vdofs_num = size(bezier_B, 2);
|
|
|
|
% NOTE: Nh is ordered as
|
|
% 2 4
|
|
% 1 3
|
|
[dNh_ele, ~, Nh] = shape_gradient_ele(dx/2, dx/2, 4);
|
|
|
|
lx = dx * microx;
|
|
NH = cell(eleNum_ma, 1);
|
|
|
|
for ele = 1 : eleNum_ma
|
|
material = rho{ele};
|
|
|
|
% Assemble the micro global stiffness as the order of [dofid]
|
|
% i.e. [4-borders, inner], to be specific, [bottom, right, up, left, inner]
|
|
% this order is determined by bezier_B
|
|
K = multi_assemble_k3(dofid, material, ke0, ke1, ke2, iK_mi, jK_mi);
|
|
Me = build_M_simply(bdofs_num, K, bezier_B);
|
|
|
|
% [ndofs, v+p].
|
|
Re = [bezier_B; Me]; % NOTE: current order of ndofs is as of [dofid]
|
|
% R1 = Re(dofid(order1), :);
|
|
% R2 = reshape(R1, 8, []); % [8, nele*v]
|
|
|
|
% for gp = 1:4
|
|
% dNe_g = dNh_ele{gp};
|
|
% dFe = dNe_g * R2; % [4, nele*v]
|
|
% dF1 = reshape(dFe, 4, eleNum_mi, vdofs_num);
|
|
% dFe = permute(dF1, [1,3,2]);
|
|
% dFdx{gp, ele} = dFe;
|
|
% end
|
|
regulated_matrix{ele} = Re;
|
|
|
|
%% surface of NH
|
|
R3 = Re(dofid, :);
|
|
NHe = NH_alpha(microx, edofMat_mi, vdofs_num/2, Nh, R3);
|
|
NH{ele, 1} = NHe;
|
|
end
|
|
|
|
plot_NH_bezier(1, 1, lx, microx, nelx, nely, 2, NH);
|
|
|
|
end
|
|
|
|
%% utils
|
|
function K = multi_assemble_k3(dofid, material, ke0, ke1, ke2, iK, jK)
|
|
|
|
microx = size(material, 1);
|
|
sK = zeros(64, microx^2);
|
|
|
|
for i = 1 : microx^2
|
|
if material(i)==1
|
|
sK(:, i) = ke1(:);
|
|
elseif material(i)==2
|
|
sK(:, i) = ke2(:);
|
|
else
|
|
sK(:, i) = ke0(:);
|
|
end
|
|
end
|
|
|
|
new_iK = dofid(iK);
|
|
new_jK = dofid(jK);
|
|
|
|
% sK = reshape(ke(:) * (emin + material(:)' * (e0 - emin)), 64*microx^2, 1);
|
|
K = sparse(new_iK, new_jK, sK(:));
|
|
K = (K + K') / 2;
|
|
end
|