# Two nearly self-intersecting facets

**URL:** <https://community.freefem.org/t/two-nearly-self-intersecting-facets/1384>\
**Category:** General Discussion\
**Created:** [December 13, 2021, 1:06am UTC](https://community.freefem.org/t/two-nearly-self-intersecting-facets/1384 "2021-12-13T01:06:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaojiemo](https://avatars.discourse-cdn.com/v4/letter/x/a4c791/32.png) [@xiaojiemo](https://community.freefem.org/u/xiaojiemo)\
**Post date:** [December 13, 2021, 1:06am UTC](https://community.freefem.org/t/two-nearly-self-intersecting-facets/1384/1 "2021-12-13T01:06:45Z")

</div>

hello,everyone. I am building a network which consists of a cylinder and an array of solid particle in it. I tried to build 3D curve and used tegten to build the mesh. The procedure said that

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/0c8edc3b271b2c41f7e0c87b60fa13bec06ea083.png)  
my whole code is like below,  
// test of mmg3d for move objets in a mesh …  
load “msh3”  
load “tetgen”  
load “medit”  
load “mmg3d-v4.0”  
include “MeshSurface1.idp”

//The surface for cylinder

real r1=0.2;  
real hs = 0.1;  
border cc(t=0,2_pi){x=25_cos(t);y=25_sin(t);label=0;}  
mesh Thcercle = buildmesh(cc(10));  
mesh Thcarre=square(50,50,[50_x,2_pi_y]);  
func f1 = x;  
func f2 =25_cos(y);  
func f3 = 25_sin(y);  
meshS Thsurf1=movemesh23(Thcarre,transfo=[f1,f2,f3],orientation=-1);// sidewall  
meshS Thsurf2=movemesh23(Thcercle,transfo=[0,x,y],orientation=-1);// bottom  
meshS Thsurf3=movemesh23(Thcercle,transfo=[50,x,y],orientation=1); //top  
meshS Thsurf=Thsurf1+Thsurf2+Thsurf3;// gluing the three meshes together

plot(Thsurf,wait=1);  
meshS Th1=Ellipsoide(r1,r1,r1,hs,300,0.2,0.2,0.2,-1);  
meshS Th2;  
meshS Th3;  
for(int i=1;i\<5;i++)  
{  
for(int j=1;j\<5;j++)  
{  
for(int k=1;k\<5;k++)  
{  
Th2=Ellipsoide(r1,r1,r1,hs,300,(2_i+1)r1,r1+2j_r1,r1+2_k_r1,-1);  
Th1=Th1+Th2;  
}  
}  
}

for(int i=1;i\<5;i++)  
{  
for(int j=1;j\<5;j++)  
{  
for(int k=1;k\<5;k++)  
{  
Th3=Ellipsoide(r1,r1,r1,hs,300,(-2_i+1)r1,r1-2j_r1,r1-2_k_r1,-1);  
Th1=Th1+Th3;  
}  
}  
}

meshS Th=Th1+Thsurf;  
//meshS Th=Thsurf+th111+th211+th311+th411+th511+th611+th711+th811+th911+th1011;  
plot(Th);

real[int] domain=[25,0,0,300,0.01];  
mesh3 Th3sph=tetg(Th,switch=“paAAQYY”,nbofregions=1,regionlist=domain);  
savemesh(Th3sph,“POROUS.msh”);
