Mesh Generation for Computational Science in Python

你说的曾经没有我的故事 提交于 2019-11-30 04:00:44

问题


I have a need for a Python module/package that provides a mesh on which I can do computational science? I am not doing graphics, so I don't think the blender package is what I want.

Does anyone know of a good package?


回答1:


The most useful packages out there are perhaps

  • mshr,
  • pygalmesh,
  • dmsh,
  • pygmsh, and
  • MeshPy.

I've created a repo showcasing a number of examples.

In addition, there is optimesh for improving the quality of any mesh.

(Disclaimer: I'm the author of pygmsh, pygalmesh, dmsh, and optimesh.)




回答2:


If you're trying to solve FE or CFD style equations on a mesh you can use MeshPy in 2 and 3 dimensions. Meshpy is a nice wrapper around the existing tools tetgen and triangle.

If you're looking for more typical graphics style meshes, there was an interesting talk at PyCon 2011 "Algorithmic Generation of OpenGL Geometry", which described a pragmatic approach to procedural mesh generation. The code from the presentation is available online

If you're interested in reconstruction of surfaces from data, you can't go past the Standford 3D Scanning Repository, home of the Stanford Bunny

Edit:

A dependancy free alternative may be to use something like gmsh, which is platform independent, and uses similar tools to meshpy in its back-end.




回答3:


I recommend using NumPy (especially if you've used MATLAB before). Many computational scientists / mechanical engineers working in python might agree, but I'm biased as it found it's way into much of the last year of my research. It's part of SciPy: http://numpy.scipy.org/ I was fond of numpy.linspace(a,b,N) which makes an N length vector of equally spaced values from a to b. You can use numpy.ndarray to make a N x M matrix, or if you want 2D arrays use numpy.meshgrid.



来源:https://stackoverflow.com/questions/7975522/mesh-generation-for-computational-science-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!