Errors when using Python on Windows 10
Hi, I'm writing a meshing script in Python 3.7.6 and Windows 10 and I think I may have found a few bugs:
- It appears that when meshing a volume with 2nd order elements I get the following error:
File "C:\Users\atheo\OneDrive\Documents\Hydrogen GT\Turbine Sizing\RITUAL_v0.005\test.py", line 35, in <module>
gmsh.model.mesh.generate(3)
File "C:\ProgramData\Anaconda3\lib\site-packages\gmsh-4.5.6-Windows64-sdk\lib\gmsh.py", line 1322, in generate
byref(ierr))
OSError: exception: access violation writing 0x00000000266A0000
- When starting GUI from python using gmsh.fltk.run() and going into Mesh->Define->Curve and applying Transfinite Curve to a curve I get the following error in the console at the bottom of the screen:
Error : Unable to open file ''
and the path at the top of the screen shows:
Gmsh - C:\Users\atheo\AppData\Roaming/untitled.geo
It looks like when opening GUI from python it doesn't apply the correct slash in Windows (the transfinite command still works so maybe it's not an issue after all). I've included a picture highlighting the issue
3)Finally, I can't get transfinite settings to work via Python. If I open up GUI and click through the settings, it creates transfinite surface just fine. However, when putting all the settings in my Python script it doesn't seem to work. (I've included the step file that I'm using and the location of the surface in question in attachments)
My code:
import gmsh, math, os, sys
from pathlib import Path
try:
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
gmsh.model.add("Turbine Sector FEA")
path = Path(os.getcwd() + "/turbineSector.stp")
if not path.exists():
sys.exit("Turbine CAD file not found!")
gmsh.merge(str(path))
gmsh.model.occ.synchronize()
gmsh.model.geo.mesh.setTransfiniteCurve(9, 4, "Progression", 1.0)
gmsh.model.geo.mesh.setTransfiniteCurve(16, 4, "Progression", 1.0)
gmsh.model.geo.mesh.setTransfiniteCurve(23, 4, "Progression", 1.0)
gmsh.model.geo.mesh.setTransfiniteCurve(22, 4, "Progression", 1.0)
gmsh.model.geo.mesh.setTransfiniteSurface(5, "Left", [9,10,15,19])
gmsh.model.geo.synchronize()
sectorPitch = 0.4487989505128276
rotation = [math.cos(sectorPitch), math.sin(sectorPitch), 0., 0., \
-math.sin(sectorPitch), math.cos(sectorPitch), 0., 0., \
0.,0.,1.,0., \
0.,0.,0.,1.]
gmsh.model.mesh.setPeriodic(2, [8], [4], rotation)
gmsh.model.mesh.setPeriodic(2, [21], [13], rotation)
gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 2.3542207510210558)
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 2.3542207510210558)
gmsh.option.setNumber("Mesh.ElementOrder", 1![Issue3_Location](/uploads/775fb4d47114ee00af39fedce93ca813/Issue3_Location.jpg))
gmsh.option.setNumber("Mesh.Smoothing", 100)
gmsh.model.mesh.generate(3)
gmsh.fltk.run()
gmsh.finalize()
except:
gmsh.finalize()
sys.exit("An error occured while generating turbine sector mesh. The run has been terminated.")