[Gmsh] Transfinite 3D meshing

Bruno bruno.agostini at gmail.com
Tue Oct 6 13:59:18 CEST 2020


Dear Gmsh community,

I have a 3 dimensional square duct here attached that I wish to mesh 
using the transfinite option in Gmsh, which seems very powerful.

I wish to have on each side of the inlet and outlet square of the duct 
20 meshing points

To this end I wrote the script below, but it does the meshing without 
taking into account the transfinite points.

Any clue what I am doing wrong here? I could not find the answer in the 
mail archive.

Python script:

import gmsh

dcell = Wd = Hd = 2.8
tol = dcell / 100
Ld = 18.46

gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
gmsh.option.setNumber("Mesh.MshFileVersion", 4.1)
gmsh.option.setString("Geometry.OCCTargetUnit", "MM")
gmsh.option.setNumber("Mesh.Optimize",1)
#gmsh.option.setNumber("Mesh.Optimize",1)

gmsh.merge("SquareDuct.brep")
model = gmsh.model
model.mesh.removeDuplicateNodes()


# CREATE PHYSICAL GROUPS

# WALLS
s = []
s_bot = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, -Ld/2-tol, 
-Hd/2+tol, Wd/2+tol, Ld/2+tol, dim = 2)
s_top = model.getEntitiesInBoundingBox(Hd/2-tol, -Wd/2-tol, -Ld/2-tol, 
Hd/2+tol, Wd/2+tol, Ld/2+tol, dim = 2)
s_left = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, -Ld/2-tol, 
Hd/2+tol, -Wd/2+tol, Ld/2+tol, dim = 2)
s_right = model.getEntitiesInBoundingBox(-Hd/2-tol, Wd/2-tol, -Ld/2-tol, 
Hd/2+tol, Wd/2+tol, Ld/2+tol, dim = 2)
s = s + s_bot + s_left + s_top + s_right
s_no_slip = [s[i][1] for i in range(len(s))]
p = model.addPhysicalGroup(2, s_no_slip)
model.setPhysicalName(2, p, "noslip")
print("noslip = ", len(s))

# FLUID INLET CURVE
c_in = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, -Ld/2-tol, 
Hd/2+tol, Wd/2+tol, -Ld/2+tol, dim = 1)
# FLUID INLET
s = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, -Ld/2-tol, 
Hd/2+tol, Wd/2+tol, -Ld/2+tol, dim = 2)
p = model.addPhysicalGroup(2, [s[i][1] for i in range(len(s))])
model.setPhysicalName(2, p, "inlet")
print("inlet = ", len(s))
for ci in c_in:
     gmsh.model.geo.mesh.setTransfiniteCurve(ci[1], 20)
p = model.addPhysicalGroup(1, [c_in[i][1] for i in range(len(c_in))])
model.setPhysicalName(1, p, "inlet_curve")

# FLUID OUTLET CURVE
c_out = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, Ld/2-tol, 
Hd/2+tol, Wd/2+tol, Ld/2+tol, dim = 1)
# FLUID OUTLET
s = model.getEntitiesInBoundingBox(-Hd/2-tol, -Wd/2-tol, Ld/2-tol, 
Hd/2+tol, Wd/2+tol, Ld/2+tol, dim = 2)
p = model.addPhysicalGroup(2, [s[i][1] for i in range(len(s))])
model.setPhysicalName(2, p, "outlet")
print("outlet = ", len(s))
for co in c_out:
     gmsh.model.geo.mesh.setTransfiniteCurve(co[1], 20)
p = model.addPhysicalGroup(1, [c_out[i][1] for i in range(len(c_out))])
model.setPhysicalName(1, p, "outlet_curve")

for si in s_no_slip:
     gmsh.model.geo.mesh.setTransfiniteSurface(si)

# VOLUME
s = model.getEntities(3)
p = model.addPhysicalGroup(3, [s[i][1] for i in range(len(s))])
model.setPhysicalName(3, p, "air")

for vi in [s[i][1] for i in range(len(s))]:
     gmsh.model.geo.mesh.setTransfiniteVolume(vi)

gmsh.model.geo.synchronize()

# MESH 3D
model.mesh.generate(3)
#model.mesh.recombine()

gmsh.write("SquareDuct.msh")
gmsh.finalize()


Best regards

Bruno Agostini


-------------- next part --------------
A non-text attachment was scrubbed...
Name: SquareDuct.brep
Type: model/brep
Size: 4226 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20201006/d2829baa/attachment.brep>


More information about the gmsh mailing list