[Gmsh] Transfinite Line & SetSize with API on Python

Michel Cassagnes michelcassagnes11 at gmail.com
Sun May 3 01:55:15 CEST 2020


Dear all,

I need some help to make a transfinite line and set size at points work
with the API on Python.

I made many tests and many looks in examples and doc but I don't find how
to handle all this.

Please find enclosed an example that doesn't give anything for the line
entered as transfinite with 10 points (take care to change the working
folder at the begining of the script).

Maybe there is a conflict with other definitions of mesh size (filelds,
characteristic length at points, etc).

Thank you.

Best regards,

Michel Cassagnes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20200503/cbc17eef/attachment.html>
-------------- next part --------------
# --------
# API gmsh
# --------

import gmsh

import sys
systeme = sys.platform
import os
if systeme[0:3] == 'lin':
    profil = os.environ['PWD']
else:
    profil = os.environ['USERPROFILE']

rep = 'Documents\\Mulhouse\\Aster\\Test'

fichierModel = 'test'

fichierMed = os.path.join(profil,rep,fichierModel + '.med')

gmsh.initialize()

gmsh.model.add(fichierModel)

options = dict()
options['Mesh.CharacteristicLengthFromPoints'] = 0
options['Mesh.Algorithm'] = 8
options['Mesh.CharacteristicLengthExtendFromBoundary'] = 1
options['Mesh.Smoothing'] = 5
options['Mesh.RecombinationAlgorithm'] = 0
options['Mesh.RecombineAll'] = 0
options['Geometry.Tolerance'] = 0.01

for mo, val in iter(options.items()):
    gmsh.option.setNumber(mo, val)

point = [(0,0,0),(10,0,0),(10,10,0),(0,10,0),(5,5,0),(7.5,7.5,0)]
lines = [(0,1),(1,2),(2,3),(3,0),(4,5)]
line_loops = [(1,2,3,4)]
listOfPlaneSurface = {1:[1]}

Lc = 1.0

for n, p in enumerate(point):
    gmsh.model.geo.addPoint(p[0], p[1], p[2], Lc, n+1)
for n, l in enumerate(lines):
    gmsh.model.geo.addLine(l[0]+1, l[1]+1, n+1)
for m, b in enumerate(line_loops):
    gmsh.model.geo.addCurveLoop(b, m+1)
for m, b in iter(listOfPlaneSurface.items()):
    gmsh.model.geo.addPlaneSurface(b, m)

gmsh.model.geo.synchronize()
       
# Points in surfaces

gmsh.model.mesh.embed(0, [5], 2, 1)
    
# Lines in surfaces

gmsh.model.mesh.embed(1, [5], 2, 1)

# Transfinite Lines 

gmsh.model.mesh.setTransfiniteCurve(5, 10,'Progression', 1.5)

gmsh.model.mesh.setSize([6] , 0.25)

gmsh.model.geo.synchronize()

gmsh.model.mesh.generate(2)

gmsh.write(fichierMed)



gmsh.finalize()


More information about the gmsh mailing list