Communication between meshes

Hi everybody!
I am approaching the solution of a magnetostatic problem with two different meshing strategies and one of them is not working properly having apparently “no communication” between the mesh components.
The problem is the following:
I have a vertical conductor in which is flowing a current and it should provide results close to the Biot-Savart problem (since the conductor length is much bigger than its diameter).
The first meshing strategy is summarized in the following code lines:

real lw = 2.76;
real Rw = 0.14;
border ww(t=0.,2.pi){x=Rwcos(t);y=Rwsin(t);};
border bb(t=0.,2.pi){x=Rboxcos(t);y=Rbox
sin(t);label=97;};
mesh maind = buildmesh(ww(20)+bb(15));
func zgiu = -lw/2.;
func zsu = lw/2.;
mesh3 maind3D = buildlayers(maind,10,zbound=[zgiu,zsu]);
func ztop = lw;
func zmin = -lw;
//upper and lower
border bbu(t=0.,2.pi){x=Rboxcos(t);y=Rboxsin(t);label=97;};
mesh baseu = buildmesh(bbu(15));
border bbl(t=0.,2.pi){x=Rboxcos(t);y=Rbox
sin(t);label=97;};
mesh basel = buildmesh(bbu(15));
mesh3 upper = buildlayers(baseu,5,zbound=[zsu,ztop]);
mesh3 lower = buildlayers(basel,5,zbound=[zmin,zgiu]);
mesh3 MM = upper+lower+maind3D;

This first case is basically producing a big cylinder representing the “external environment” containing my vertical conductor and it is working well.

In the second case, instead of building the subvolumes that have been built previously I decided to build the conductor and separately a big cylinder and then obtaining the final mesh just summing them up, but in such a way it seems that the current that is flowing in the conductor is not causing any effect on the external environment, producing no magnetic field, as the two mesh components are not communicating at all! The code lines for the production of this second kind of mesh are the following:

//building of the “box”
func zdown = -5;
func zup = 5;
border cc(t=0.,2.pi){x=Rboxcos(t);y=Rboxsin(t);label=97;};
mesh box=buildmesh(cc(2
el));
mesh3 box3D=buildlayers(box,lay,zbound=[zdown,zup]);
//building of the conductor
real lw = 2.76;
real Rw = 0.14;
border ww(t=0.,2.pi){x=Rwcos(t);y=Rw*sin(t);};
mesh Thw = buildmesh(ww(30));
//extreme of the wipe
func zgiu = -lw/2.;
func zsu = lw/2.;
mesh3 Thw3D = buildlayers(Thw,20,zbound=[zgiu,zsu]);
mesh3 MM = Thw3D+box3D;

Is some of you knowing why the second meshing strategy is not working properly? And is some of you able to explain me how to make the second strategy to work? Since if the conductor geometry is getting more complicated actually the first strategy that I have mentioned it seems not to be feasable anymore.

I’m already thanking a lot everybody that will help me in solving this problem!

Best regards

Marco

1 Like

Hi Marco,
Did you menage to understand why joining two meshes as you did in the second case does not work? I am curious because I am facing the same complication!

Thank you in advance,

Christian

Hi,
In the latter code the two meshes overlap in the inside region, which is the problem. Instead you need to build a meshS with all the boundaries and then build the mesh3 with tetgen, as

load "msh3"
load "tetgen"

real lw = 2.76;
real Rw = 0.14;
real Rbox = 2.;
func zdown = -lw;
func zup = lw;
//building of the "box"
border cc(t=0.,2.*pi){x=Rbox*cos(t);y=Rbox*sin(t);label=97;};
mesh discc=buildmesh(cc(15));
int[int] lab1=[0,1];
meshS bot1=movemesh23(discc,transfo=[x,y,zdown],region=lab1);
int[int] lab2=[0,2];
meshS top2=movemesh23(discc,transfo=[x,-y,zup],region=lab2);
mesh lat=square(15,20);
int[int] lab3=[0,3];
meshS lat3=movemesh23(lat,transfo=[Rbox*cos(2.*pi*x),-Rbox*sin(2.*pi*x),zdown+y*(zup-zdown)],region=lab3);

//building of the conductor
border ww(t=0.,2.*pi){x=Rw*cos(t);y=Rw*sin(t);};
mesh discw = buildmesh(ww(20));
func zgiu = -lw/2.;
func zsu = lw/2.;
int[int] lab4=[0,4];
meshS botw4=movemesh23(discw,transfo=[x,y,zgiu],region=lab4);
int[int] lab5=[0,5];
meshS topw5=movemesh23(discw,transfo=[x,-y,zsu],region=lab5);
mesh latw=square(20,10);
int[int] lab6=[0,6];
meshS latw6=movemesh23(latw,transfo=[Rw*cos(2.*pi*x),-Rw*sin(2.*pi*x),zgiu+y*(zsu-zgiu)],region=lab6);
meshS ThS=bot1+top2+lat3+botw4+topw5+latw6;
real[int] domain = [(Rbox+Rw)/2.,0.,0.,0,1.,0.,0.,0.,1,1.];
mesh3 MM=tetg(ThS,switch="paAAYY",nbofregions=2,regionlist=domain);
plot(MM, cmm="MM",fill=0, wait=1);
1 Like

Thank you very much for your prompt responce! It is a very usefull example to show how to work around the problem of joining together multiple buildlayers-meshes.
I have few more troubles with my case. The 2D “base” mesh is the following one:


I would like to extrude it and define two different axial regions that will be characterized by different materials (thus there should be a kind of "separator that hallows me to define different regions and cast the proper material). The challenge in this case is defining the lateral surface of the 3D system, as one boundary has hexagonal edges, as shown in the following figure.

Do you have any suggestions on how to proceed?
I was wondering if it is possible to use the whole border of the 2D figure and extrude it in z direction, and then to insert one plane in the midle for separating the two axial region?

I linked a extrimely simplified case (only one hexagon), hoping it can be helpful.

Thank you in advance!
prova.edp (898 Bytes)

Your tentative file looks not feasible because to my knowledge there is no command to extrude a boundary (1d boundary of a 2d mesh to 2d boundary meshS).

But maybe you can do it by hand: for the lateral boundary you could try to write a parametrization (X(t),Y(t)) of the right boundary of your first figure, for t\in[0,1]. Denote by n1 the number of segments in your right boundary (30 on your figure). You need that each segment number i corresponds to the interval t\in [i/n1,(i+1)/n1] for i=0,...,n1-1.Then take a square mesh
mesh flat=square(n1,n2);
with n2 corresponding to the vertical discretization.
Next transport the mesh in 3d with something like
meshS lateral=movemesh23(flat,transfo=[X(x),Y(x),y],region=lab3);

The other way you propose could work also (extrude the 2d mesh with buildlayers), but your 2d mesh must contain the separation already.

Thank you, François, for your suggestions—they really helped me. However, I later discovered that the issue preventing communication between the two regions was related to the physics (incorrect equation definition) and not the mesh!

That said, this mistake gave me the opportunity to improve my “mesh generation skills” in FreeFem++ and Gmsh.

For the readers: In simple terms, what I tried to do was generate three 3D meshes (Th3D1,Th3D2 and Th3D3) by extruding a 2D mesh (Th2D) three times, and then joining them using the “+” operator (i.e., mesh3 Th3Dtot = Th3D1 + Th3D2 + Th3D3). This worked for me, probably because the extruded base was the same for all the 3D meshes. If that’s not the case for you, you could try working around the issue using other “internal” methods (like movemesh) or external software like Gmsh. Personally, I found the second option easier, thanks to Gmsh’s ability to continue extruding from the top fsurface mesh of the previous extrusion (keep in mind that my geometry is fairly simple in the axial direction).