adjusted mesh size in particular direction

Hi,

I want to generate triangular mesh for concentric cylinder with a thin membrane between inner and outer region:
My input file :

algebraic3d
solid cube1 = orthobrick (0, 0, 0; 1400, 1400, 800);
solid cyl1 = cylinder (700, 700, 0; 700, 700, 800; 200.0);

solid dom1=cyl1 and cube1;

solid cube2 = orthobrick (0, 0, 0; 1400, 1400, 800);
solid cyl2 = cylinder (700, 700, 0; 700, 700, 800; 210);
solid gab2= cyl2 and cube2;

solid dom2= gab2 and not dom1;

solid cube3 = orthobrick (0, 0, 0; 1400, 1400, 800);
solid cyl3 = cylinder (700, 700, 0; 700, 700, 800; 700);
solid gab3= cyl3 and cube3;

solid dom3= gab3 and not dom1 and not dom2;

tlo dom1 -col=[1,0,0];
tlo dom2 -col=[0,1,0];
tlo dom3 -col=[0,1,0]- transparent;


The coarse mesh looks like this:

and to simulate the “physics” that iam interested in, i need to refine the mesh near the membrane, so it looks like this:

The number of mesh is too large and i know the change of physics quantity iam interested is signifiicant only in radial direction. Is there a way to refine mesh only in particular direction, in my case in radial direction? This way i can save lots of computational time and resource.

(Edited :
I could make more multiple regions and mesh them later to look like this :

But when i tried to increase the length of cylinder, the mesh generation took forever)

Thanks,
Alex

[attachment=undefined]coarse.png[/attachment]

Hi Alex,

You should use prismatic elements for that, so you can use the CloseSurface and ZRefinement features. With this you can slice the prismatic elements to get a refinement only in radial direction. This is a python script for that:


from netgen.csg import *

geo = CSGeometry()
cube1 = OrthoBrick(Pnt(0,0,0), Pnt(1400,1400,800))
cyl1 = Cylinder(Pnt(700,700,0), Pnt(700,700,800),200)
dom1 = cyl1 * cube1
cyl2 = Cylinder(Pnt(700,700,0), Pnt(700,700,800),210)
gab2 = cyl2 * cube1
dom2 = gab2 - cyl1
cyl3 = Cylinder(Pnt(700,700,0), Pnt(700,700,800),700)
gab3 = cyl3 * cube1
dom3 = gab3 - cyl2

geo.Add(dom1)
geo.Add(dom2)
geo.Add(dom3)

n = 4
slices = [i/n for i in range(1,n)]

geo.CloseSurfaces(cyl1,cyl2,slices)

ngmesh = geo.GenerateMesh(maxh=100)
ZRefinement(ngmesh, geo)

from ngsolve import *
mesh = Mesh(ngmesh)
Draw(mesh)

Hi,
be careful here with the z-refinement, it does not go together with curved elements well. But you can use a couple of cylinders for the shell, if needed.
Joachim

Hi christopher,

Thanks for your help with the info of slicing feature, it works well for the previously quoted parameters. I tried to play and double the cylinder length from 800 to 1600, it generated mesh with “too large” zmax

The modifed part of input:

cube1 = OrthoBrick(Pnt(0,0,0), Pnt(1400,1400,1600))
cyl1 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),200)
dom1 = cyl1 * cube1
cyl2 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),210)
gab2 = cyl2 * cube1
dom2 = gab2 - cyl1
cyl3 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),700)
gab3 = cyl3 * cube1
dom3 = gab3 - cyl2

i must have done something wrong here, would you please help to take a look at this?

Thanks,
Alex

you have to set a bounding-box for the geometry as follows. Default values are +/-1000


geo.CloseSurfaces(cyl1,cyl2,slices)
geo.SetBoundingBox(Pnt (-2000, -2000, -2000), Pnt(2000, 2000, 2000))
ngmesh = geo.GenerateMesh(maxh=100)

Hi Joachim,

that works, thank you.

Alex

Hi,

Lets say i want to refine the mesh in the region 1 and/or 3 near the membrane(region 2), I can do this by creating 4 cylindrical surfaces:

geo = CSGeometry()
cube1 = OrthoBrick(Pnt(0,0,0), Pnt(1400,1400,1600))
cyl1 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),180)
dom1 = cyl1 * cube1

cyl2 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),200)
gab2 = cyl2 * cube1
dom2 = gab2 - cyl1

cyl3 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),210)
gab3 = cyl3 * cube1
dom3 = gab3 - cyl2

cyl4 = Cylinder(Pnt(700,700,0), Pnt(700,700,1600),700)
gab4 = cyl4 * cube1
dom4 = gab4 - cyl3

geo.Add(dom1)
geo.Add(dom2)
geo.Add(dom3)
geo.Add(dom4)

n = 4
slices = [i/n for i in range(1,n)]

geo.CloseSurfaces(cyl1,cyl2,slices)
geo.CloseSurfaces(cyl2,cyl3,slices)
geo.SetBoundingBox(Pnt (-6000, -6000, -6000), Pnt(6000, 6000, 6000))
ngmesh = geo.GenerateMesh(maxh=500)
ZRefinement(ngmesh, geo)

But the above script will create 4 regions, instead of 3.
Is it possible to create an imaginary cylindrical surface (not part of physical region) and slices/refine between that surface and another surface? Or am i better off with modifying the 4 region indices in output “*.vol” file to be 3 region indices ?

Another question is related to the prism constructed between the two surfaces. If the cyl1 and cyl2 facing surfaces are quite paralel (lets say r1=200 and r2=205), then i will get nice parallel triangular prisms between the two surfaces like below:

However if the r1=200 and r2=230, then the two facing tetrahedral surfaces are not quite paralel, then the prisms between look quite funny. like bellow:

[attachment=undefined]not_paralel.jpg[/attachment]

For my research, i need to have parallel prisms between the surfaces. Is there a way to modify such that we have all parallel triangular prisms. I dont mind if there is small void of volume created by doing so, because in my project, the most important things occur near this membrane and it decays exponentially outward.

Best,
Alex