Re: [firedrake] circles in firedrake?
Hi Francis, There appears to be something called vext.vtk which claims to make system vtk accessible from inside a virtualenv. There is also this email: http://vtk.1045678.n5.nabble.com/Re-VTK-in-virtualenv-td5716725.html I have to confess that I have not really tried either. Regards, David On Mon, 20 Mar 2017 at 01:40 Francis Poulin <fpoulin@uwaterloo.ca> wrote:
Thanks for suggesting PyGmsh! I bumped into it a while ago but never really figured it out. Now I'm keen since it should help building and modifying meshes more easily.
I installed pygmsh easily using the instructions on the website. It imports correctly. There is even an example that builds a circle, I think.
When I try running this, as well as other examples, I get an error because no module named vtk is found. See below. I get this comes from meshio?
Traceback (most recent call last):
File "circle.py", line 24, in <module> meshio.write('circle.vtu', *out) File "/home/fpoulin/software/firedrake/local/lib/python2.7/site-packages/meshio/__init__.py", line 187, in write field_data=field_data File "/home/fpoulin/software/firedrake/local/lib/python2.7/site-packages/meshio/vtk_io.py", line 204, in write import vtk ImportError: No module named vtk
When I do a pip install it tells me that it is already installed and up to date.
(firedrake) fpoulin@fpoulin-Gazelle:~/software/pygmsh/test/examples$ pip install -U meshio Requirement already up-to-date: meshio in /home/fpoulin/software/firedrake/lib/python2.7/site-packages Requirement already up-to-date: pipdated in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from meshio) Requirement already up-to-date: numpy in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from meshio) Requirement already up-to-date: requests in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from pipdated->meshio) Requirement already up-to-date: appdirs in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from pipdated->meshio)
I realize this isn't necessarily a firedrake question but if anyone had an idea on how to get this working I would be keen to try it.
Cheers, Francis ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo
email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637 <(519)%20888-4567>
------------------------------ *From:* firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of G. D. McBain [gdmcbain@protonmail.com] *Sent:* Sunday, March 19, 2017 6:16 PM
*To:* firedrake@imperial.ac.uk *Subject:* Re: [firedrake] circles in firedrake?
I would expect a user to run gmsh separately (at the command line or through the GUI), rather than from within the Python script. I don't think it's possible to interact with gmsh from Python nowadays without jumping through considerable hoops.
Have you tried the (free third-party) PyGmsh? It generates .geo code from Python. From there one calls Gmsh using Python subprocess and reads in the resulting .msh. I've found it handy.
https://github.com/nschloe/pygmsh
--
Dr David Ham Department of Mathematics Imperial College London
Hello David, Thanks for pointing out vext.vtk. I agree that it should make vtk accessible in a virtualenv, or so I've read. I have installed it using pip and still get the same error. My guess is I need to do more to set things up. At the moment, learning gmsh doesn't sound so bad. I will probably do that but if someone else has had any success using this please let me know. Cheers, Francis ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637 ________________________________ From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk] on behalf of David Ham [David.Ham@imperial.ac.uk] Sent: Monday, March 20, 2017 5:56 AM To: firedrake; G. D. McBain Subject: Re: [firedrake] circles in firedrake? Hi Francis, There appears to be something called vext.vtk which claims to make system vtk accessible from inside a virtualenv. There is also this email: http://vtk.1045678.n5.nabble.com/Re-VTK-in-virtualenv-td5716725.html I have to confess that I have not really tried either. Regards, David On Mon, 20 Mar 2017 at 01:40 Francis Poulin <fpoulin@uwaterloo.ca<mailto:fpoulin@uwaterloo.ca>> wrote: Thanks for suggesting PyGmsh! I bumped into it a while ago but never really figured it out. Now I'm keen since it should help building and modifying meshes more easily. I installed pygmsh easily using the instructions on the website. It imports correctly. There is even an example that builds a circle, I think. When I try running this, as well as other examples, I get an error because no module named vtk is found. See below. I get this comes from meshio? Traceback (most recent call last): File "circle.py", line 24, in <module> meshio.write('circle.vtu', *out) File "/home/fpoulin/software/firedrake/local/lib/python2.7/site-packages/meshio/__init__.py", line 187, in write field_data=field_data File "/home/fpoulin/software/firedrake/local/lib/python2.7/site-packages/meshio/vtk_io.py", line 204, in write import vtk ImportError: No module named vtk When I do a pip install it tells me that it is already installed and up to date. (firedrake) fpoulin@fpoulin-Gazelle:~/software/pygmsh/test/examples$ pip install -U meshio Requirement already up-to-date: meshio in /home/fpoulin/software/firedrake/lib/python2.7/site-packages Requirement already up-to-date: pipdated in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from meshio) Requirement already up-to-date: numpy in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from meshio) Requirement already up-to-date: requests in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from pipdated->meshio) Requirement already up-to-date: appdirs in /home/fpoulin/software/firedrake/lib/python2.7/site-packages (from pipdated->meshio) I realize this isn't necessarily a firedrake question but if anyone had an idea on how to get this working I would be keen to try it. Cheers, Francis ------------------ Francis Poulin Associate Professor Department of Applied Mathematics University of Waterloo email: fpoulin@uwaterloo.ca<mailto:fpoulin@uwaterloo.ca> Web: https://uwaterloo.ca/poulin-research-group/ Telephone: +1 519 888 4567 x32637<tel:(519)%20888-4567> ________________________________ From: firedrake-bounces@imperial.ac.uk<mailto:firedrake-bounces@imperial.ac.uk> [firedrake-bounces@imperial.ac.uk<mailto:firedrake-bounces@imperial.ac.uk>] on behalf of G. D. McBain [gdmcbain@protonmail.com<mailto:gdmcbain@protonmail.com>] Sent: Sunday, March 19, 2017 6:16 PM To: firedrake@imperial.ac.uk<mailto:firedrake@imperial.ac.uk> Subject: Re: [firedrake] circles in firedrake? I would expect a user to run gmsh separately (at the command line or through the GUI), rather than from within the Python script. I don't think it's possible to interact with gmsh from Python nowadays without jumping through considerable hoops. Have you tried the (free third-party) PyGmsh? It generates .geo code from Python. From there one calls Gmsh using Python subprocess and reads in the resulting .msh. I've found it handy. https://github.com/nschloe/pygmsh -- Dr David Ham Department of Mathematics Imperial College London
Thanks for pointing out vext.vtk. I agree that it should make vtk accessible in a virtualenv, or so I've read. I have installed it using pip and still get the same error. My guess is I need to do more to set things up. At the moment, learning gmsh doesn't sound so bad. I will probably do that but if someone else has had any success using this please let me know. Learning Gmsh isn't too bad, no. It can be convenient creating the geometry in Python though, so here's a hint. I'm not sure how to fix your VTK problem (maybe pip install PyVTK?), but I believe the "import vtk" is not in pygmsh so much as in meshio, which is an "install_requires" of pygmsh according to its setup.py. Now meshio is useful too, but just to generate the .geo file for Gmsh, meshio isn't required, just pygmsh. This suggests hacks along the lines of editing pygmsh/setup.py or downloading pygmsh but not installing it and pointing PYTHONPATH or sys.path to it.
participants (3)
- 
                
                David Ham
- 
                
                Francis Poulin
- 
                
                G. D. McBain