Hi!
I'm writing a Python program for parameter optimization as part of my Master's
thesis. In this program, I'm using GMSH for meshing a STEP-file that has been
generated in Autodesk Inventor. It has been working very nicely, and I'm
impressed by the capabilities of the software.
However, I've run into some problems now, which I can't seem to figure out the
cause of. I've realized that I need to use second order elements for my
problem, as shear locking is causing large errors when I use linear elements. I
can successfully generate a mesh of tetrahedrons with my desired fineness, so
the only thing I need to change is the order of the elements. In the graphical
interface, this works fine by just clicking "Set order 2". Looking at the
documentation, the appropriate command for setting the element order to 2 is:
gmsh.model.mesh.setOrder(2)
But when I add this line to my Python code, it either doesn't do anything
(elements still turn out linear), or makes Python crash (the shell is restarted
without any message), depending on if I add the line before or after
gmsh.model.mesh.generate(3). I've tried getting log messages, to figure out
what is going on, using gmsh.logger.start() after initializing GMSH, but when I
add that command GMSH crashes with the following message, once it reaches
gmsh.model.mesh.generate(3):
File "C:\PythonSpringGen\gmshSDK\lib\gmsh.py", line 1007, in generate
byref(ierr))
OSError: exception: access violation writing 0x00007FF80125DD40
I've also tried looking for some kind of log file, which, to my understanding,
should be saved in case GMSH crashes, but I don't know where to find it.
My code looks like this:
gmsh.initialize()
gmsh.open(stepPath)
#gmsh.logger.start()
ent = gmsh.model.getEntities(0)
gmsh.model.mesh.setSize(ent, elemSize)
# for some reason it doesn't work with ElmerGrid if you use the new
version 4 for GMSH mesh file format, so choose v2 (previous)
gmsh.option.setNumber("Mesh.MshFileVersion", 2)
gmsh.model.mesh.generate(3) # Generate mesh with 3 dimensions
gmsh.model.mesh.setOrder(2) # <--------------- it crashes here
#print(gmsh.logger.get())
gmsh.write(meshPath)
nodeTags, self.nodeCoords, parametricCoord = gmsh.model.mesh.getNodes()
gmsh.finalize()
I'm using GMSH SDK 4.1.4. I tried using the latest version (4.2.2), but then my
program always hangs at gmsh.model.mesh.generate(3), even if I don't set the
mesh order to 2.
So, to sum up my questions:
- Am I doing something wrong in my code when trying to implement 2nd order mesh
generation?
- How do I access GMSH log messages when I run it from the Python API?
Any help or pointers would be greatly appreciated!
Sunny greetings from Gothenburg,
Felix Eriksson
_______________________________________________
gmsh mailing list
[email protected]
http://onelab.info/mailman/listinfo/gmsh