[Gmsh] Transfinite 3D meshing

Max Orok morok at mevex.com
Tue Oct 6 18:46:29 CEST 2020


Hi Bruno,

At a quick glance, it's possible you require some more synchronize calls
between the different API calls.
It's good practice to call synchronize when you move from one part of the
API to another (e.g. from gmsh.model.geo to gmsh.model.geo.mesh).
This is a somewhat common issue (see e.g.
https://gitlab.onelab.info/gmsh/gmsh/-/issues/987,
https://gitlab.onelab.info/gmsh/gmsh/-/issues/986).

I see you have a single sync call at the end but it possibly comes too late
to register the transfinite settings.
I would suggest trying to minimize your script further (maybe a single
geometry and a single transfinite call) to dig in further.

Sincerely,
Max

On Tue, Oct 6, 2020 at 10:43 AM Bruno <bruno.agostini at gmail.com> wrote:

> 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
>
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
>


-- 
Max Orok
Contractor
www.mevex.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20201006/08111022/attachment.html>


More information about the gmsh mailing list