[Gmsh] Transfinite 3D meshing
Christophe Geuzaine
cgeuzaine at uliege.be
Tue Oct 6 19:39:32 CEST 2020
Hi Bruno and Max,
There is nothing mysterious about the "gmsh.model.geo.synchronize()" and "gmsh.model.occ.synchronize()" calls :-) They serve a single purpose: to synchronize the topological Gmsh model (the model manipulated by the "gmsh.model" functions) with the internal CAD representations in each of the supported CAD kernels (the representations manipulated by the "gmsh.model.geo" functions for the built-in kernel, or the "gmsh.model.occ" functions for the OpenCASCADE kernel).
In Bruno's case the issue is not linked to a missing sync. It is simply that the script merges a BREP file (the OpenCASCADE CAD file format, which thus creates an internal occ representation and is synced with the gmsh model) but tries to set transfinite constraints on the built-in internal CAD representation - using "gmsh.model.geo.setTransfiniteSurface()". The transfinite constraint should simply be set on the Gmsh model using "gmsh.model.setTransfiniteSurface()" (without the ".geo"!).
I encourage you to read the introduction of the API chapter in the user's guide (http://gmsh.info/dev/doc/texinfo/gmsh.html#Gmsh-API): it explains the Gmsh data model and all the underlying concepts.
Cheers,
Christophe
> On 6 Oct 2020, at 18:46, Max Orok <morok at mevex.com> wrote:
>
> 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
>
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
—
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine
More information about the gmsh
mailing list