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.
 
 
 
 

35 lines
1.4 KiB

%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-09-27 17:08:44
% @LastEditTime: 2021-09-27 18:18:12
%--------------------------
function [coorx, coory] = prepare_coordinates(lx, microx, nelx, nely)
dx = lx / microx;
globalx = nelx * microx;
globaly = nely * microx;
[coorx_nodes, coory_nodes] = meshgrid(-lx/2:dx:lx/2, -lx/2:dx:lx/2);
coory_nodes = flipud(coory_nodes);
[coorx_eles,coory_eles] = meshgrid(-lx/2+dx/2:dx:lx/2-dx/2, -lx/2+dx/2:dx:lx/2-dx/2);
coory_eles = flipud(coory_eles);
[nodes, eles, eleNum, nodeNum] = GenerateMesh(nelx, nely, nelx, nely);
[elesOffsetx, elesOffsety, nodesOffsetx, nodesOffsety] = offsetSIMP(eles, nodes, microx, microx, nelx, nely);
[coorx_full, coory_full] = meshgrid(0:dx:globalx*dx, 0:dx:globaly*dx);
coory_full = flipud(coory_full);
[coorx, coory] = prepareCoord(nodesOffsetx, nodesOffsety, nelx, nely, coorx_full, coory_full);
end
function [coorx, coory] = prepareCoord(nodesOffsetx, nodesOffsety, sub_nelx, sub_nely, coorx_full, coory_full)
coorx = cell(sub_nely, sub_nelx);
coory = cell(sub_nely, sub_nelx);
for i = 1:sub_nelx
for j = 1:sub_nely
coorx{j,i} = coorx_full(squeeze(nodesOffsety(j,i,:)), squeeze(nodesOffsetx(j,i,:)));
coory{j,i} = coory_full(squeeze(nodesOffsety(j,i,:)), squeeze(nodesOffsetx(j,i,:)));
end
end
end