1 function [node,elem] = delmesh(node,elem,expr) 2 %% DELMESH delete part of the mesh 3 4 dim = size(node,2); elemdim = size(elem,2); 5 %% delete element 6 switch elemdim 7 case 3 8 center = (node(elem(:,1),:)+node(elem(:,2),:)+node(elem(:,3),:))/3; 9 case 4 10 center = (node(elem(:,1),:) + node(elem(:,2),:) ... 11 + node(elem(:,3),:) + node(elem(:,4),:))/4; 12 end 13 x = center(:,1); y = center(:,2); %#ok<*NASGU> 14 if dim == 3 15 z = center(:,3); %#ok<*NASGU> 16 end 17 idx = eval(expr); 18 elem(idx,:) = []; 19 20 %% delete vertices 21 isValidNode = false(size(node,1),1); 22 isValidNode(elem(:)) = true; 23 node = node(isValidNode,:); 24 25 %% shift index of element 26 Nnew = sum(isValidNode); 27 indexMap(isValidNode) = (1:Nnew)‘; 28 elem = indexMap(elem);
delmesh
时间: 2024-12-20 11:17:54