www.gusucode.com > 基于多边形网格的流动问题拓扑优化设计元代码 > PolyBoundary.m

    %------------------------------ PolyTop ---------------------------------%
% Ref: A Pereira, C Talischi, GH Paulino, IFM Menezes, MS Carvalho   %
%      "Fluid Flow Topology Optimization in PolyTop: Stability and        %
%      Computational Implementation", Struct Multidisc Optim,          %
%      DOI 10.1007/s00158-014-1182-z                                                     %
%-------------------------------------------------------------------------%
function [BNode] = PolyBoundary(Node,Element) % Node in dimension (NNode,2);element is cell in dimension (NElem,1)
NNode = size(Node,1); NElem = size(Element,1);
ElemNNode = cellfun(@length,Element); % number of nodes per element in dimension (NElem,1)
NodeTri = zeros(NNode+NElem,2); NodeTri(1:NNode,:) = Node;
Tri = zeros(sum(ElemNNode),3); % assembling of node indices from elementary perspective
Count = 0;
for el=1:NElem
  % returns the mean value of the columns of Node(Element{el},1)(find the center of the modes in element el)
  NodeTri(NNode+el,:) = [mean(Node(Element{el},1)),...
                         mean(Node(Element{el},2))];
  nn = ElemNNode(el); %the number of node in element el
  Tri_e = zeros(nn,3);
  Tri_e(1:nn,1)=NNode + el; % Freedom index in BNode
  Tri_e(1:nn,2)=Element{el}(1:nn); % first Vertex in element el(returns its index in Node)
  Tri_e(1:(nn-1),3)=Element{el}(2:(nn-1)+1); % second Vertex (rolling)
  Tri_e(nn,3)=Element{el}(1); % second Vertex (rolling)
  Tri(Count+1:Count+nn,:) = Tri_e; % assemble node indices from elementary perspective
  Count = Count + nn;
end
TRep = TriRep(Tri,NodeTri(:,1),NodeTri(:,2)); % Triangular mesh form of nodes
BNode = unique(freeBoundary(TRep)); % extract the boundary vortices for each bound,and unique(them).