Google
Grid Generation: Mesh Generation Using MATLAB Delaunay Function

Wednesday, November 01, 2006

Mesh Generation Using MATLAB Delaunay Function

If you are using Matlab Delaunay function to generate a unstructured 2D or 3D mesh you will land up in some sort of trouble. For very simple reasons. Have a look at the following piece of MATLAB code.
This code is to generate 3D tetrahedral mesh using the Matlab function Delaunay
x=[(0):1/(numx):(1)]; % numx=numy=numz = 1 (typical cube)
y=[(0):1/(numy):(1)];
z=[(0):1/(numz):(1)];
[X,Y,Z] = meshgrid(x,y,z);
X = [X(:)];
Y= [Y(:)];
Z = [Z(:)];
Tes = delaunay3(X,Y,Z);
L = [X(:) Y(:) Z(:)];
tetramesh1(Tes,L);camorbit(20,0) ;

This gives me a tetrahedral mesh with 'Tes' having the nodal connectivity matrix for a typical case (a cube with 6-tetrahedra, 8 nodes)it looks like
Tes = 4 7 8 6
1 5 7 6
2 4 7 6
2 1 7 6
2 4 7 3
2 1 7 3
Now if you are not care full you might land up in trouble. The reason being that output of delaunay function is in a random order some of the tessellation are arranged in clock wise direction and some in anticlockwise direction. So you need to reorder the tessellation in a particluar oder keeping one/summit node fixed and arranging others in clockwise or anticlcokwise direction.
Same thing happens in 2D. Now you can either do that if you are fond of MATLAB function Delaunay or you can use fowllowing piece of code given to me by some one who is master in tetrahedral meshes.




function [vertices,tess]=tess_lat(varargin)
% tess_lat: simplicial tessellation of a rectangular lattice
% usage: [tessellation,vertices]=tess_lat(p1,p2,p3,...)
%
% arguments: input
% p1,p2,p3,... - numeric vectors defining the lattice in
% each dimension.
% Each vector must be of length >= 1
%
% arguments: (output)
% vertices - factorial lattice created from (p1,p2,p3,...)
% Each row of this array is one node in the lattice
% tess - integer array defining simplexes as references to
% rows of "vertices".


% dimension of the lattice
n = length(varargin);


% create a single n-d hypercube
% list of vertices of the cube itself
vhc=('1'==dec2bin(0:(2^n-1)));
% permutations of the integers 1:n
p=perms(1:n);
nt=factorial(n);
thc=zeros(nt,n+1);
for i=1:nt
thc(i,:)=find(all(diff(vhc(:,p(i,:)),[],2)>=0,2))';
end


% build the complete lattice
nodecount = cellfun('length',varargin);
if any(nodecount<2)
error 'Each dimension must be of size 2 or more.'
end
vertices = lattice(varargin{:});


% unrolled index into each hyper-rectangle in the lattice
ind = cell(1,n);
for i=1:n
ind{i} = 0:(nodecount(i)-2);
end
ind = lattice(ind{:});
k = cumprod([1,nodecount(1:(end-1))]);
ind = 1+ind*k';
nind = length(ind);


offset=vhc*k';
tess=zeros(nt*nind,n+1);
L=(1:nind)';
for i=1:nt
tess(L,:)=repmat(ind,1,n+1)+repmat(offset(thc(i,:))',nind,1);
L=L+nind;
end


% ======== subfunction ========
function g = lattice(varargin)
% generate a factorial lattice in n variables
n=nargin;
sizes = cellfun('length',varargin);
c=cell(1,n);
[c{1:n}]=ndgrid(varargin{:});
g=zeros(prod(sizes),n);
for i=1:n
g(:,i)=c{i}(:);
end

In the next post I will discuss how you can get boundary nodes in a much easier fashion for any kind of meshes by using Faces in 3D.

8 comments:

Mayur said...

nice post man..quite interesting stuff...can you provide more details on how to construct other kind of meshes in 2D

Unknown said...

加气混凝土设备
加气混凝土设备
疤痕
糖尿病
搜索引擎优化
游戏币
买金币
魔兽金币
魔兽金币
游戏币
买金币
食道癌
食管癌
食道癌的治疗
食管癌的治疗
贲门癌
贲门癌的治疗
食道癌的治疗
癌症
肿瘤
食道癌
肝癌
胃癌
肺癌
脑瘤
乳腺癌
直肠癌
淋巴癌
鼻咽癌
乳腺癌
胃癌
肝癌
土工格栅
碳纤维
输送设备
输送设备
非淋菌性尿道炎
疱疹
鄂式破碎机
免烧砖机
烘干机
碎石机
球磨机
耐火材料
煤气发生炉
雷蒙磨
雷蒙磨
球磨机
选矿设备
牛皮癣
银屑病
牛皮癣
银屑病
球磨机
碎石机
免烧砖机
食道癌
膀胱癌
肺癌
桥式起重机
桥式起重机
起重机
起重机
天车
电动葫芦
室内设计
癫痫
鲜花
旅游策划
旅游规划
旅游规划
旅游开发
旅游规划
旅游规划
造粒
反应釜
反应釜
造粒机
肝硬化腹水
肝腹水
肝硬化
瘦脸
抽脂
除皱
变性
丰胸
整形美容
整形美容
网络电话
液晶电视
等离子电视
食道癌
食道癌
食管癌
贲门癌
糖尿病
癫痫病
癫痫
糖尿病

Anonymous said...

食品公司-销售供销中心
安溪茗茶-茶叶供销中心
保健食品销售中心
大家看看未来的香港六合彩去向
2007年六合彩的去向
香港六合彩的危害性
茶叶-安溪铁观音|茗茶批发|销售中心
打击中关村六合彩|香港六合彩|大暴光
liuhecai公司
开奖结果
曾道人
liuhecai公司
白小姐
liuhecaitema
liuhecai百度
安溪茗茶-茶叶供销中心
liu合彩blog
香港六合彩彩票
[六合彩]赌博六合彩
香[六合彩]香港六合彩栏目
香港六合彩特码
香港六合彩游戏规则
六合彩的内幕
香港六合彩危害之深
香港六合彩在线
专家香港六合彩一码
香港六合彩经济
香港六合彩透码网站
香港六合彩给你一码中特
香港六合彩特等奖
[六合彩本期相关信息]在线华人网
香港六合彩提供特码
香港六合彩公司内幕料
香港六合彩图库内幕料
香港六合彩图库一码中特资料
香港六合彩图库网
综合香港六合彩资料一码
香港六合彩资料透特
香港六合彩网站
特码六合彩报码聊天室
特码白小姐图库
香港六合彩财神资讯中心
香港六合彩(liuhecai)
香港六合彩内幕机密偷偷公布
六合彩-香港六合彩
泉州警方生擒劫钞歹徒,与六合彩有关
香港六合彩询问特码
香港”六合彩”的信息-六合彩在线
广东省|六合彩|特码|liuhecai|香港六合彩|大公开
香港六合彩提供特码
六合彩”最新资料
透彻"香港六合彩"一码中特
中关村“六合彩”大暴光
美国打击“香港六合彩”庄家
香港六合彩打击庄家理由
香港六合彩一码打击庄家
沉迷香港“六合彩”主特码
香港“六合彩”特码信息
香港六合彩外围彩庄家
香港六合彩诱惑性
香港六合彩日历
揭秘地下“六合彩”特码玄机--逍遥王优化
香港六合彩特码伪装
香港六合彩特码暗剑
香港六合彩特码曝光
远离"六合彩"-共同打击"香港六合彩
全国全面整治香港六合彩图库特码大公开
香港六合彩真的还想再活五百年 六合彩| 香港六合彩新闻中心
缔造“香港六合彩”一码
“香港六合彩”有风险
香港“六合彩”庄家主一码OK
广东“香港六合彩”专项调查
“liuhecai”公开十二特码生肖
本站打击香港六合彩送资料
上海狠打击香港六合彩
六合彩一码中特OK
六合彩免费一码OK
香港六合彩特码曝光
香港六合彩中特“歪招”
福建专项整治“香港六合彩”
偷印“六合彩图库”的特码
“香港六合彩”唾弃
广东“香港六合彩”专项调查
“liuhecai”公开十二特码生肖
香港六合彩秘笈
香港六合彩专研调查
香港六合彩特码外围彩
六合彩诱惑不少人
香港六合彩内幕调查
“六合彩”一肖中特资料
“香港六合彩”特码
“香港六合彩”交易特码
香港六合彩重点整治
“六合彩图库”里有玄机
根除“香港六合彩”要通过科普宣传
香港六合彩会员料大公开会员料大公开
liuhecai公开十二特码生肖
香港六合彩
重点打击六合彩赌博
实行香港六合彩一码中特
香港六合彩特码准OK

José Estudillo said...

Thanks to write this code, but i have a doubt: is anticlockwise the tetrahedral direction generated?

Anonymous said...

东风程力汽车国家发改委定点生产各类专用汽车的专业厂家,国家大型专用汽车制造厂。

国内知名园林绿化石油化工
市政环卫专用汽车制造商。

其主导品种有园林绿化洒水车吸粪车
垃圾车压缩式垃圾车油罐车吸污车高空作业车随车吊自卸车教练车厢式车专用车配件消防车半挂车冷藏车运水车牵引头清障车牵引车散装水泥车化工液体车水泥搅拌车等八大系列100多个品种车型。

提供各类车型产品价格:洒水车价格|吸粪车价格|垃圾车价格|吸污车价格|油罐车价格|高空作业车价格|压缩垃圾车价格|挂桶式垃圾车价格|摆臂式垃圾车价格、地坑式垃圾车价格|自卸车价格|运水车价格|厢式货车价格|消防车价格|冷藏车价格|教练车价格

新浪洒水车百度洒水车汽车博客网汽车和讯网
免费销售咨询电话:0722-3812866 3817866

Anonymous said...

单级离心泵
中开泵
不锈钢多级泵
氟塑料离心泵
塑料离心泵
管道离心泵
管道离心泵
不锈钢管道泵
隔膜泵
油桶泵
磁力驱动泵
齿轮油泵
自吸油泵
电动隔膜泵
立式多级泵
不锈钢离心泵
单螺杆泵
多级管道泵
浓浆泵
化工离心泵
氟塑料离心泵
单级离心泵
卧式离心泵
不锈钢多级泵
卧式多级泵
管道油泵
自吸排污泵
上海水泵厂
磁力泵
电动隔膜泵
潜水泵
电动隔膜泵
导热油泵
插桶泵
管道泵
管道泵
管道泵
导热油泵

螺杆泵
化工泵
水泵
消防泵
屏蔽泵
深井泵
转子泵
潜水泵
标牌制作
锅炉给水泵
消防泵
立式消防泵
转子泵
氟塑料磁力泵
控制柜
液下泵
污水泥浆泵
玻璃钢液下泵
耐腐蚀离心泵
氟塑料合金离心泵

Anonymous said...

月中霜斗嬋娟
元和天神武姿
彼何人軒與羲
誓將上列聖恥
坐法宮朝四夷
淮西有五十載
不據山據平地
長戈利日可麾
帝得聖相曰度
賊斫不神扶持
尋芳不醉流霞
倚樹沉日已斜
客散酒深夜後
更持紅賞殘花
休問梁舊賓客
茂陵秋病相如
君到臨問酒壚
近來還長卿無
金徽卻無情物
九廟無八馬回
奉天城長春苔
咸陽原英雄骨
半向君養馬來
嵩雲秦久離居

Unknown said...

mesh generation is so over my head. Goodness me.