进行有限元计算等操作有时需要用到多边形网格。本文计划介绍四种多边形网格的生成方法,包括
- Polymesher直接生成平面多边形网格
- 平面N边形节点网格生成
- 曲面四节点网格重构为曲面多边形网格
- 曲面四节点网格重构为曲面N边形网格
本文是以上四点的第一部分, Polymesher直接生成平面多边形网格
案例一 圆形区域多边形网格生成
%%在半径为1.0047的圆上生成多边形网格
[Nodes_Coord,Element_Connect] = PolyMesher(@Circle,100,200);Nodes_Coord(:,3)=0;
showmesh(Nodes_Coord,Element_Connect)
%----------------------------------------------- Domain
function [x] = Circle(Demand,Arg)
BdBox = [-2 2 -2 2];
switch(Demand)
case('Dist'); x = DistFnc(Arg,BdBox);
case('BC'); x = BndryCnds(Arg{:},BdBox);
case('BdBox'); x = BdBox;
case('PFix'); x = FixedPoints(BdBox);
end
end
%----------------------------------------------- COMPUTE DISTANCE FUNCTIONS
function Dist = DistFnc(P,BdBox)
Dist = dCircle(P,0,0,1.0047);
end
%---------------------------------------------- SPECIFY BOUNDARY CONDITIONS
function [x] = BndryCnds(Node,Element,BdBox)
x = cell(2,1); %No boundary conditions specified for this problem
end
%----------------------------------------------------- SPECIFY FIXED POINTS
function [PFix] = FixedPoints(BdBox)
PFix = [0,0];
end
%-------------------------------------------------------------------------%
案例二 Cook梁多边形网格生成
[Nodes_Coord,Element_Connect] = PolyMesher(@Cook,16,100);Nodes_Coord(:,3)=0;
showmesh(Nodes_Coord,Element_Connect)
%----------------------------------------------- Domain
function [x] = Cook(Demand,Arg)
BdBox = [0 48 0 60];
switch(Demand)
case('Dist'); x = DistFnc(Arg,BdBox);
case('BC'); x = BndryCnds(Arg{:},BdBox);
case('BdBox'); x = BdBox;
case('PFix'); x = FixedPoints(BdBox);
end
end
%----------------------------------------------- COMPUTE DISTANCE FUNCTIONS
function Dist = DistFnc(P,BdBox)
d1 = dRectangle(P,0,48,0,60);
d2 = dLine(P,0,44,48,60);
D=dDiff(d1,d2);
d3 = dLine(P,0,0,48,44);
Dist = dIntersect(d3,D);
end
%---------------------------------------------- SPECIFY BOUNDARY CONDITIONS
function [x] = BndryCnds(Node,Element,BdBox)
x = cell(2,1); %No boundary conditions specified for this problem
end
%----------------------------------------------------- SPECIFY FIXED POINTS
function [PFix] = FixedPoints(BdBox)
PFix = [];
end
%-------------------------------------------------------------------------%
附件 Polymesher MATLAB包