error when creating multilayer mesh

25 views
Skip to first unread message

cate.ame...@gmail.com

unread,
Dec 17, 2024, 8:55:16 AM12/17/24
to mmc-users
Dear Prof. Fang, 

I am trying to create a multilapyer cylinder, with a hole of different material. I tried in two different ways, but I always get errors. I report here the two codes with the errors.


First way:
I am not able to correclty create the faces of my domain, cause the function surfboolean give me an error:

[no,fc]=meshcylinders([S.R,S.R,0],[0,0,1], [S.T0,S.T1,S.T2], S.R,0,0,20);
plotmesh(no,fc,  'y>30')

[nhole,fhole]=meshacylinder([S.R, S.R, S.T0],[S.R,S.R, S.T0+S.T1], S.R0, radbound, maxvol,20);
[n,f] = surfboolean(no,fc,'resolve',nhole,fhole);
plotmesh(n,f,  'y>30')
regionseeds=[];
holeseeds=[]; 
method='tetgen1.5';
[node, elem]=s2m(n, f, 0.7, 10, method, regionseeds, holeseeds);
plotmesh(node, elem, 'x>30')

This way the function surfboolean give me error of
 "A self-intersection was detected. Program stopped." And if I use  in the function "meshcylinders" a tsize different from 0, it returns a cell structure...


Second way:
I correctly create the surfaces of my domain, but I get error when using s2m:

[ncyl,fcyl]=meshacylinder([S.R, S.R, 0],[S.R,S.R, S.T0+S.T1+S.T2+S.Textra], S.R, radbound, maxvol,20);
[nhole,fhole]=meshacylinder([S.R, S.R, S.T0],[S.R,S.R, S.T0+S.T1], S.R0, radbound, maxvol,20);
[nhole2,fhole2]=meshacylinder([S.R, S.R, S.T0+S.T1],[S.R,S.R, S.T0+S.T1+S.Textra], S.Rextra, radbound, maxvol,20);
[nh,fh] = surfboolean(nhole2,fhole2,'resolve',nhole,fhole);
[no, fc]=surfboolean(ncyl, fcyl, boolopt, nh, fh);
[no,fc]=removeisolatednode(no(:,1:3),fc(:,1:3));
[node2, elem2]=s2m(no, fc, 0.02, maxvol, method, regionseeds, holeseeds, 'cgalmesh');


Can you please help me?
Thank you in advance, 

Caterina

Fang, Qianqian

unread,
Dec 17, 2024, 2:47:56 PM12/17/24
to mmc-users
Hi Caterina, 

Can you provide your S struct? I can not run your code as many of the parameters are not defined.

Qianqian


From: cate.ame...@gmail.com <cate.ame...@gmail.com>
Sent: Tuesday, December 17, 2024 8:55 AM
To: mmc-users <mmc-...@googlegroups.com>
Subject: [mmc-users] error when creating multilayer mesh
 
--
You received this message because you are subscribed to the Google Groups "mmc-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mmc-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mmc-users/ad516edb-d474-4cd8-b882-e86eb4268452n%40googlegroups.com.

Caterina Amendola

unread,
Dec 18, 2024, 4:17:17 AM12/18/24
to mmc-...@googlegroups.com
Hi,
Here the struct:
S.R = 30;               %[mm] radius of cylinder
S.R0=3;                   %[mm] radius of the hole
S.T0 = 20;                %[mm] thickness of the first layer
S.T1 = 1.0;                %[mm] thickness of the hole
S.T2 = 10;                %[mm] thickness of the third layer

Thank you very much !

Fang, Qianqian

unread,
Dec 18, 2024, 11:36:00 AM12/18/24
to mmc-...@googlegroups.com
hi Caterina,

see my rewritten script below.

here are some of the key comments

1. surfboolean can only intersect triangular surfaces, so you can not use PLC (piecewise-linear-complex) output from meshcylinders in surfboolean

2. surfboolean can not intersect co-planar surfaces - if any of the surfaces between the two inputs are along the same plane, it will fail. you must move one of the overlapping surfaces above or below

3. try to avoid downsampling surfaces when you are meshing multi-compartment surfaces, set keepration to 1

4. do not remove the center cylinder - even it is filled with air, you still want to mesh it and label it with a non-zero label (and assign air's properties), so that mmc can continue propagating photons through this region. if you remove it, the center hole becomes exterior space, and any photon reaching that surface will be terminated and will never fly across.

this the same reason that one should not label an air cavity in an mcx simulation with label 0, but a non-zero air-like tissue type.


    S.R = 30;               %[mm] radius of cylinder
    S.R0 = 3;               %[mm] radius of the hole
    S.T0 = 20;              %[mm] thickness of the first layer
    S.T1 = 1.0;             %[mm] thickness of the hole
    S.T2 = 10;              %[mm] thickness of the third layer

    % get multi-segment cylinder PLC
    [no,fc]=meshcylinders([S.R,S.R,0],[0,0,1], [S.T0,S.T1,S.T2], S.R,0,0,20);

    % convert PLC to tri-surface before boolean
    [no1,el1,fc1]=s2m(no,fc,1,10);

    % keep only surface nodes
    [no2,fc2]=removeisolatednode(no1,fc1(:,1:3));

    % create the center cylinder, MUST NOT BE CO-PLANAR to surfboolean surface
    [nhole,fhole]=meshacylinder([S.R, S.R, S.T0-1],[S.R,S.R, S.T0+S.T1+1], S.R0, 1, 0.5, 20);

    % use surfboolean('first') to slice no2/fc2 by nhole/fhole
    [no3,fc3] = surfboolean(no2,fc2,'first',nhole,fhole);

    % manually define region seeds
    regionseeds=[S.R,S.R,1; S.R, S.R,20.5; S.R+5,S.R+5,20.5; S.R, S.R, 25];

    % s2m to convert surf to volumetric mesh, do not simplify!
    [node, elem]=s2m(no3, fc3, 1, 10, 'tetgen1.5', regionseeds);

    plotmesh(node, elem, 'x>30','facealpha', 0.9)


Qianqian


From: Caterina Amendola <cate.ame...@gmail.com>
Sent: Wednesday, December 18, 2024 4:17 AM
To: mmc-...@googlegroups.com <mmc-...@googlegroups.com>
Subject: Re: [mmc-users] error when creating multilayer mesh
 
Reply all
Reply to author
Forward
0 new messages