Problem with creating mesh

96 views
Skip to first unread message

gian...@gmail.com

unread,
May 3, 2018, 9:44:18 AM5/3/18
to iso2mesh-users
Dear iso2mesh users,

I am trying to create a mesh which is composed of a slab with two beams inside of it. The slab and the two beams would ideally share the same top surface.
I attached a MATLAB figure showing this, which I obtained by simply plotting the three volumes separately.

I tried to create this mesh as following:

% Create two meshed volumes for both the 0.5-mm thick beams and extract only the longitudinal surfaces:
[n_beam_1,f_beam_1]=meshabox([-10 3 1.5],[10 2 2.5],0.01,1); % Create meshed volume for the first beam;
[n_beam_1,el_beam_1,fa_beam_1]=surf2mesh(n_beam_1,f_beam_1,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
[no_beam_1,fa_beam_1]=removeisolatednode(n_beam_1,fa_beam_1(fa_beam_1(:,end)==1,1:3)); % Remove isolated nodes in the beam surface;
[n_beam_2,f_beam_2]=meshabox([-10 -2 1.5],[10 -3 2.5],0.01,1); % Create meshed volume for the second beam;
[n_beam_2,el_beam_2,fa_beam_2]=surf2mesh(n_beam_2,f_beam_2,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
[no_beam_2,fa_beam_2]=removeisolatednode(n_beam_2,fa_beam_2(fa_beam_2(:,end)==1,1:3)); % Remove isolated nodes in the beam surface;

% Combine the meshed surfaces of the two beams:
 [no,fa]=mergemesh(no_beam_1,fa_beam_1,no_beam_2,fa_beam_2); 

% Create the meshed volume of the bounding 20x20x5 mm box around the merged inner volumes:
 [node,elem]=surf2mesh(no,fa,[-10 -10 -2.5],[10 10 2.5],1,0.01,[0 2.5 2; 0 -2.5 2]);
 elem(:,5)=elem(:,5)+1; % Adjust region identifiers of the initial meshed domain

However, this seems not to work. 

Anyone has any idea how to make it work?

Thanks,
Luca
Vasculature + CCO.fig

Qianqian Fang

unread,
May 3, 2018, 11:39:11 AM5/3/18
to iso2mes...@googlegroups.com, gian...@gmail.com
hi Luca

try the following code

    [n_beam_1,f_beam_1]=meshabox([-11 3 1.5],[11 2 2.6],0.01,1); % Create meshed volume for the first beam;
    [n_beam_1,el_beam_1,fa_beam_1]=surf2mesh(n_beam_1,f_beam_1,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
    [no_beam_1,fa_beam_1]=removeisolatednode(n_beam_1,fa_beam_1(:,1:3)); % Remove isolated nodes in the beam surface;
    [n_beam_2,f_beam_2]=meshabox([-11 -2 1.5],[11 -3 2.6],0.01,1); % Create meshed volume for the second beam;
    [n_beam_2,el_beam_2,fa_beam_2]=surf2mesh(n_beam_2,f_beam_2,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
    [no_beam_2,fa_beam_2]=removeisolatednode(n_beam_2,fa_beam_2(:,1:3)); % Remove isolated nodes in the beam surface;
    [nbox,fbox]=meshabox([-10 -10 -2.5],[10 10 2.5],1);

    % Combine the meshed surfaces of the two beams:
    [no,fa]=mergemesh(no_beam_1,fa_beam_1,no_beam_2,fa_beam_2);
    [n3obj, f3obj]=surfboolean(nbox, fbox(:,[1 3 2]), 'first', no,fa);

    % Create the meshed volume of the bounding 20x20x5 mm box around the merged inner volumes:
     [node,elem]=s2m(n3obj,f3obj,1,10,'tetgen',[0 0 0; 0 2.5 2; 0 -2.5 2]);
     plotmesh(node,elem)

I made a few changes (highlighted), the biggest change is to use surfboolean to combine
the two beams with the bounding box (bbx). you can not use mergemesh to
merge two surfaces that have intersections or coplanar faces.

but the surface boolean also does not work if two surfaces have overlapping
surfaces (i.e. co-planar), so I extended the x/y and z dimensions of your beams
(now it extends from -11 to 11 with z goes to 2.6), this way, you can use surface
boolean to cut a bounding box from -10 to 10 in x with max z at 2.5.

if you maintain the original dimensions, the two beams will overlap at the top surface
as well as the left and right ends. surface boolean may still run, but tetgen will fail.

here is the output I got from my linux box. 3 regions are labeled by the seeds
defined a the last parameter of the s2m call.

Qianqian



Thanks,
Luca
--
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.


beams_in_box.png

gian...@gmail.com

unread,
May 3, 2018, 12:14:06 PM5/3/18
to iso2mesh-users
Dear Dr. Fang,

Many thanks for the help.

I have just one question: do you have any suggestion regarding how to refine the elements at the boundaries of the three regions and make the meshed domain more homogeneous?

Thanks again,
Luca

gian...@gmail.com

unread,
May 8, 2018, 6:48:37 AM5/8/18
to iso2mesh-users
Dear Dr. Fang,

in addition to my previous question, I also tried to add a planar MMC source to the previous mesh, using the following script:

% Add wide-field planar source to refined mesh domain:
source=struct('srctype','planar','srcpos',[-2 -2 7],'srcdir',[0 0 -1 -3],'srcparam1',[4 0 0 0],'srcparam2',[0 4 0 0]);
[newnode,newelem]=mmcaddsrc(node,elem,source,'KeepShape',1);
newelem(:,1:4)=meshreorient(newnode,newelem(:,1:4));

% Plot the final mesh + source domain:
figure; plotmesh(newnode,newelem,'facealpha',0.5), hold on, plotmesh(node,elem) % Plot final mesh + source domain;

However, the resulting mesh I obtain is not what I expected. 
I attached the resulting figure.

Am I doing something wrong?

Thanks,
Luca
Result.jpg

gian...@gmail.com

unread,
May 10, 2018, 5:18:31 AM5/10/18
to iso2mesh-users
Is this connected to the heterogeneity of the meshes in the beam structures?

I attached a picture to show what I mean.

Luca
Tissue+Venules_IMAGE.jpg
Reply all
Reply to author
Forward
0 new messages