%-------------------------- % @Author: Jingqiao Hu % @Date: 2021-01-26 15:51:34 % @LastEditTime: 2021-01-27 11:21:56 % boundarys: [bottom, right, up, left] %-------------------------- function [boundarys, inner] = micro_boundary(nelx) nodenrs = reshape(1:(1 + nelx) * (1 + nelx), 1 + nelx, 1 + nelx); alldofs = 1:2 * (nelx + 1) * (nelx + 1); nbottom = nodenrs(end, :); dbottom = reshape([2 * nbottom - 1; 2 * nbottom], 1, []); nright = flip(nodenrs(1:end-1, end))'; % NOTE: REVERSE! dright = reshape([2 * nright - 1; 2 * nright], 1, []); nup = flip(nodenrs(1, 1:end-1)); % NOTE: REVERSE! dup = reshape([2 * nup - 1; 2 * nup], 1, []); nleft = nodenrs(2:end - 1, 1)'; dleft = reshape([2 * nleft - 1; 2 * nleft], 1, []); boundarys = [dbottom, dright, dup, dleft]; inner = setdiff(alldofs, boundarys); end