nschloe / pygmsh

:spider_web: Gmsh for Python
GNU General Public License v3.0
842 stars 161 forks source link

pygmsh,Cylinder #324

Closed ghazalemir closed 4 years ago

ghazalemir commented 4 years ago

Hi every Body, I am trying to use this code to generat a cylinder and mesh it.

from math import pi
import pygmsh
import meshio

def test():
    geom = pygmsh.opencascade.Geometry()
    geom.add_cylinder([0.0,0.0,0.0], [0.0,0.0,1.0], 20, 0.25*pi,char_length=1)
    mesh = pygmsh.generate_mesh(geom)
    #meshio.write("final.vtk", mesh)
    return mesh
meshio.write("opencascade_cylinder.vtk",test())

but I have this error:

runfile('C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py', wdir='C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code')
Is gmsh installed?
Traceback (most recent call last):

  File "<ipython-input-16-0c493db11ef0>", line 1, in <module>
    runfile('C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py', wdir='C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code')

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py", line 19, in <module>
    meshio.write("opencascade_cylinder.vtk",test())

  File "C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py", line 16, in test
    mesh = pygmsh.generate_mesh(geom)

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\pygmsh\helpers.py", line 123, in generate_mesh
    [gmsh_executable] + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\Users\ghaza\Anaconda3\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\Users\ghaza\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified
nschloe commented 4 years ago
Is gmsh installed?

(Also, best make yourself familiar with GitHub markdown syntax, they have code blocks. https://guides.github.com/features/mastering-markdown/ Makes it easier to read.)

ghazalemir commented 4 years ago

Yes I think it is installed, Becuase when I import it there is no error.

ghazalemir commented 4 years ago

In fact I have installed pygmsh!

nschloe commented 4 years ago

Not pygmsh, gmsh. https://gmsh.info/ (pygmsh is a Python lib that calls gmsh under the hood. See the main readme.)

ghazalemir commented 4 years ago

You are right! :)

nschloe commented 4 years ago

Cool. Feel free to close the issue if you have no more troubles with this.

ghazalemir commented 4 years ago

I installed the gmsh but unfortunately again I have that error.

runfile('C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py', wdir='C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code')
Reloaded modules: pytest
Is gmsh installed?
Traceback (most recent call last):

  File "<ipython-input-2-0c493db11ef0>", line 1, in <module>
    runfile('C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py', wdir='C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code')

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py", line 19, in <module>
    meshio.write("opencascade_cylinder.vtk",test())

  File "C:/Users/ghaza/Documents/PhD/Documents/CFD-DEM course/Project/Code/1.py", line 16, in test
    mesh = pygmsh.generate_mesh(geom)

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\pygmsh\helpers.py", line 123, in generate_mesh
    [gmsh_executable] + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT

  File "C:\Users\ghaza\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\Users\ghaza\Anaconda3\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\Users\ghaza\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified
nschloe commented 4 years ago

(Also, best make yourself familiar with GitHub markdown syntax, they have code blocks. https://guides.github.com/features/mastering-markdown/ Makes it easier to read.)

You can edit your post for readability.