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.

47 lines
1.7 KiB

3 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-02-26 13:52:54
% @LastEditTime: 2021-02-26 14:01:46
% find the indices of its 48-macro-dofs distributed on the surface in this macro-ele
% don't care about duplicated pnts on neighbor edges, just cover them when assigning
% 4-----3
% /| /|
% 8-----7 2
% | |/
% 5-----6
% RETURN: back(1234),up(3478),front(5678),down(1256),left(1485),right(2376)
% PARAMETER: this macro-ele is divided into microx^3 elements
%--------------------------
function [up_id, front_id, down_id, back_id, left_id, right_id, dofs_num] = surface_dofs_id(microx)
Num_node = (1+microx)^3;
nodenrs = reshape(1:Num_node, 1+microx, 1+microx, 1+microx);
% extract surface nodes
inner = nodenrs(2:end-1, 2:end-1, 2:end-1);
surface_nodes = setdiff(nodenrs(:), inner(:));
dofs_num = length(surface_nodes)*3;
% faces
back = reshape(squeeze(nodenrs(1:end, 1:end, 1)), 1, []);
front = reshape(squeeze(nodenrs(1:end, 1:end, end)), 1, []);
up = reshape(squeeze(nodenrs(1, 1:end, 1:end)), 1, []);
down = reshape(squeeze(nodenrs(end, 1:end, 1:end)), 1, []);
left = reshape(squeeze(nodenrs(1:end, 1, 1:end)), 1, []);
right = reshape(squeeze(nodenrs(1:end, end, 1:end)), 1, []);
back_id = get_dofs_id(surface_nodes, back);
front_id = get_dofs_id(surface_nodes, front);
up_id = get_dofs_id(surface_nodes, up);
down_id = get_dofs_id(surface_nodes, down);
left_id = get_dofs_id(surface_nodes, left);
right_id = get_dofs_id(surface_nodes, right);
end
function dofs_id = get_dofs_id(all_nodes, nid)
[nid1, ~] = find(all_nodes==nid);
dofs_id = [3*nid1(:)-2, 3*nid1(:)-1, 3*nid1(:)]';
dofs_id = dofs_id(:);
end