meshing two slabs with an intersecting object

77 views
Skip to first unread message

Chris W

unread,
Apr 26, 2019, 11:03:58 AM4/26/19
to iso2mesh-users
Dear iso2mesh users,

i am currently stuck at a seemingly easy problem. I want to mesh a domain, consisting of two layered slabs, the lower
of which has a hemisphere sitting on the boundary, that "sticks" into the domain of the lower slab, like this:
The picture shown is my current workaround, but as mentioned, i would like the turquoise and yellow domain to be directly
on top of each other, like shown here:
I tried the following code (with various tweaks):

clear;clc;
tb1
= [-1 -1 5]; tb2 = [21 16 11]; % Tissue Slab "Box" (2 corner nodes)
bb1
= [0 0 0]; bb2 = [20 15 10]; % Bounding Box (2 corner nodes)
detpos
= [11.27, 7.5, 0];        % Detector Position
radius
= 0.8;

% mesh the tissue slab (slightly bigger, so it overlaps):
[node_box,faces_box] = meshabox(tb1,tb2,0.1,1);
% mesh the sphere:
[node_hs,faces_hs] = meshasphere(detpos,0.8,1,1);
% mesh the bounding box:
[node_bb,faces_bb] = meshabox(bb1,bb2,0.1,1);
% merge tissue slab and sphere
[node_merged,faces_merged] = mergemesh(node_hs,faces_hs,node_box,faces_box);
% sphere should be inside the domain of the bounding box:
[cnode,cface] = surfboolean(node_bb,faces_bb,'first',node_hs,faces_hs);

subplot
(1,2,1)
plotmesh
(cnode,cface,'x>11.27'); % looks reasonable
% the tissue slab should be inside of (bounding box + hemisphere)
[newnode,newface] = surfboolean(cnode,cface,'first',node_box,faces_box); % doesn't look right

subplot(1,2,2)
plotmesh(newnode,newface,'
x>11.27');

but whenever i try to concatenate the two boxes to a sandwich, something is wrong
(I tried to adapt the procedure from the issue "issue merging meshes" asked a few month ago).
What would be an appropriate way to mesh this? I also looked into latticegrid(), but could not find a way
to intersect/concatenate the spherical geometry with the two layered slab.
I might haven't fully understood, how iso2mesh's mesh generation works. From what i think (please correct me if
this is wrong), all functions like surfboolean() etc. work on surfaces (hence the name :>); it is not possible to merge meshes
directly into each other. So one would try to intersect/merge etc. different geometries' surfaces and only in the
final step generate the actual tetrahedral mesh.

Any help is highly appreciated, thanks!

Christoph Wagner

Qianqian Fang

unread,
Apr 26, 2019, 12:23:27 PM4/26/19
to iso2mes...@googlegroups.com, Chris W
hi Chris

please checkout the below example


it meshes a two-layered slab using latticegrid(), and then use surfboolean to combine with a cylindrical mesh to create an inclusion.

in your case, if you want to combine with a sphere, you can simply replace the meshacylinder by meshasphere. Here is my quick tweak of that script

%% create the skin-vessel benchmark mesh
[no,fc]=latticegrid([0 200],[0 200],[20 32 200]); % create a 3-layer tissue
fc2=cell2mat(fc);
fc=[fc2(:,[1 2 3]); fc2(:,[1 3 4])];

%[ncy,fcy]=meshacylinder([-1,99.5,99.5],[201,99.5,99.5],20,5); % add the vessel
[ncy,fcy]=meshasphere([100 100 200],20,4,5); % add the vessel
[newnode,newelem]=surfboolean(no,fc,'first',ncy,fcy);  % merge the two domains

%c0=[10,100,150,26]';
c0=[10 100 199 26]';
seeds=[ones(4,2)*100, c0];  % define the regions by index

%ISO2MESH_TETGENOPT='-Y -A'
[cfg.node,cfg.elem]=s2m(newnode,newelem(:,1:3),1,30,'tetgen',seeds); % creating the merged mesh domain
plotmesh(cfg.node,cfg.elem,'x>100')

the output mesh cross section is attached. you can modify the sphere location/radius/mesh density according to your needs.

Qianqian
--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
For more options, visit https://groups.google.com/d/optout.


twolayerslab_with_sphere.png

Chris W

unread,
Apr 28, 2019, 1:53:12 PM4/28/19
to iso2mesh-users
Dear Qianqian,

perfect, I must have missed that example code. Thank you so much!

Best Wishes,
Chris
To unsubscribe from this group and stop receiving emails from it, send an email to iso2me...@googlegroups.com.
To post to this group, send email to iso2me...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages