[Gmsh] Transfinite Line & SetSize with API on Python

Michel Cassagnes michelcassagnes11 at gmail.com
Sun May 3 12:09:57 CEST 2020


Hi Christophe,

I have modified the script, see attached.

What works for TransfiniteCurve is :
- remove geo.synchronize
- *keep* gmsh.model.mesh.setTransfiniteCurve()

But setSize is not affected by removing geo.synchronize. Is this command
ignored if Mesh.CharacteristicLengthFromPoints is set to 0 ?

What is wrong in my script ?

Thank you!

Michel





Le dim. 3 mai 2020 à 11:04, Michel Cassagnes <michelcassagnes11 at gmail.com>
a écrit :

>
> Ok! Thank you very much Christophe.
>
> Best regards,
>
> Michel Cassagnes
>
> Le dim. 3 mai 2020 à 08:45, Christophe Geuzaine <cgeuzaine at uliege.be> a
> écrit :
>
>>
>>
>> > On 3 May 2020, at 01:55, Michel Cassagnes <michelcassagnes11 at gmail.com>
>> wrote:
>> >
>> > 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).
>> >
>>
>> Your last call to gmsh.model.geo.synchronize() resets the meshing
>> attributes of the curve. Either remove it (it's useless anyway), or set
>> your meshing contraints within the "geo" kernel, with
>> "gmsh.model.geo.mesh.setTransfiniteCurve()" instead of
>> "gmsh.model.mesh.setTransfiniteCurve()".
>>
>> Christophe
>>
>>
>>
>> > Thank you.
>> >
>> > Best regards,
>> >
>> > Michel Cassagnes
>> > <test-transfinite.py>_______________________________________________
>> > 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
>>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20200503/064bd7a9/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'

fichierMaillage = 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 = 2.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, 3,'Progression', 1.0)

# setSize

gmsh.model.geo.mesh.setSize([1] , 0.25)

##gmsh.model.geo.synchronize()

gmsh.model.mesh.generate(2)

gmsh.write(fichierMaillage)



gmsh.finalize()


More information about the gmsh mailing list