一、双洞模型
代码:
hg=[1 1 1 1 1 1 1 1 2 0 -2 0 0 1 0 -1 0 -2 0 2 1 0 -1 0 0 2 0 -2 0 1 2 1 2 0 -2 0 1 2 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 1 1 1 1]; ug=[1 1 1 1 0 1 0 -1 1 0 -1 0 -2 -1 0 -1 -1 0 -1 -2 0 0 0 0 1 1 1 1 0 0 0 0 -1 -1 -1 -1 1 1 1 1]; % 顺时针 g=[hg ug]; [p,e,t] = initmesh(g,'hmax',0.25); figure pdemesh(p,e,t);
二、铜钱型
代码:
g=[1 1 1 1 2 2 2 2 2 0 -2 0 1 1 -1 -1 0 -2 0 2 1 -1 -1 1 0 2 0 -2 -1 1 1 -1 2 0 -2 0 1 1 -1 -1 1 1 1 1 0 0 0 0 % 这里0改为2即可变为实心 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 0 0 0 0]; [p,e,t] = initmesh(g,'hmax',0.25); figure pdemesh(p,e,t); figure node=p';elem=t(1:3,:)'; h = trisurf(elem(:,1:3),node(:,1),node(:,2),zeros(size(node,1),1)); set(h,'facecolor',[0.9 0.9 0.1],'edgecolor','k'); view(2); axis equal; axis tight; axis off;
三、环状
g=[1 1 1 1 1 1 1 1 2 0 -2 0 1 0 -1 0 0 -2 0 2 0 -1 0 1 0 2 0 -2 0 1 0 -1 2 0 -2 0 1 0 -1 0 1 1 1 1 0 0 0 0 % 把0变为2可为实心 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 1 1 1 1]; [p,e,t] = initmesh(g,'hmax',0.25); figure pdemesh(p,e,t); figure node=p';elem=t(1:3,:)'; h = trisurf(elem(:,1:3),node(:,1),node(:,2),zeros(size(node,1),1)); set(h,'facecolor',[1 0. 0.],'edgecolor','k'); % 红色[1,0,0],绿色[0,1,0],蓝色[0,0,1] view(2); axis equal; axis tight; axis off;
四、常见区域(方形,圆形及L型区域)
clc,clear; close all h=0.25; %% Ex1: L shape mesh figure g=[2 0 2 0 0 1 0 2 2 2 0 1 1 0 2 2 1 1 1 1 0 2 1 1 1 2 1 0 2 1 0 2 2 1 0 2 0 0 2 0 1 0]'; [p,e,t] = initmesh(g,'hmax',h); pdemesh(p,e,t); %% Rectangle figure r=Rectg(0,0,1,1); [p,e,t] = initmesh(r,'hmax',h); pdemesh(p,e,t); %% Unit circle figure [p,e,t] = initmesh('circleg','hmax',h); pdemesh(p,e,t);
标签:node,initmesh,剖分,figure,网格,pdemesh,MATLAB,hmax,axis From: https://www.cnblogs.com/qfl21/p/18341146