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.
64 lines
2.3 KiB
64 lines
2.3 KiB
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2021-01-04 21:58:54
|
||
|
% @LastEditTime: 2021-04-21 15:23:27
|
||
|
%--------------------------
|
||
|
function [uglobal, deformed_cell] = recover_full_disp_bb(ref_nodes, deform_nodes, nelx, nely, microx, lx, M, coners, bdofs, idofs, ...
|
||
|
inner, edofMat_ma, edofMat_mi, optDesign, vF, deform_nodes_full, x_offset)
|
||
|
|
||
|
[ref_nodes_full, ~, ~, ~] = GenerateMesh(nelx*lx, nely*lx, nelx*microx, nely*microx);
|
||
|
ufull = deform_nodes_full - ref_nodes_full;
|
||
|
|
||
|
U = (deform_nodes - ref_nodes)';
|
||
|
U = U(:);
|
||
|
|
||
|
globaly = nely * microx;
|
||
|
globalx = nelx * microx;
|
||
|
[~, ~, edofMat_full] = forAssemble(globalx, globaly);
|
||
|
uglobal = zeros(2 * (globalx + 1) * (globaly + 1), 1);
|
||
|
|
||
|
deformed_cell = cell(nely, nelx);
|
||
|
|
||
|
for i = 1:nelx
|
||
|
|
||
|
for j = 1:nely
|
||
|
edof = edofMat_ma(j + (i - 1) * nely, :);
|
||
|
ue = U(edof);
|
||
|
he = M{j, i} * ue;
|
||
|
|
||
|
% he(:,2) = [outer; fdofs(:); inner(:)];
|
||
|
he(:, 2) = [coners(:); bdofs(:); idofs(:); inner(:)];
|
||
|
umicro = sortrows(he, 2);
|
||
|
|
||
|
for ii = 1:microx
|
||
|
|
||
|
for jj = 1:microx
|
||
|
% which micro element in full domain
|
||
|
last_col_full = (i - 1) * microx + ii - 1;
|
||
|
this_col_full = (j - 1) * microx + jj;
|
||
|
global_ele = last_col_full * globaly + this_col_full;
|
||
|
global_edof = edofMat_full(global_ele, :);
|
||
|
|
||
|
% which micro element in this sub
|
||
|
local_ele = jj + (ii - 1) * microx;
|
||
|
edof = edofMat_mi(local_ele, :);
|
||
|
uglobal(global_edof) = umicro(edof);
|
||
|
end
|
||
|
|
||
|
end
|
||
|
deformed_cell{j,i} = reshape(uglobal, 2, [])' + ref_nodes_full;
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
[freeddofs, ~, ~] = designDomain(optDesign, globalx, globaly, vF, ref_nodes_full, microx, x_offset);
|
||
|
% err = zeros(2*(globalx+1)*(globaly+1), 1);
|
||
|
% err(freeddofs) = (ufull(freeddofs)-uglobal(freeddofs)).^2./ufull(freeddofs).^2;
|
||
|
ufull = ufull';
|
||
|
ufull = ufull(:);
|
||
|
avgerr = sum((ufull(freeddofs) - uglobal(freeddofs)).^2) ./ sum(ufull(freeddofs).^2)
|
||
|
|
||
|
deformed = reshape(uglobal, 2, [])' + ref_nodes_full;
|
||
|
% figure; scatter(deformed(:,1), deformed(:,2)); axis equal;
|
||
|
end
|