Python网格生成
问题描述:
如何在Python中创建2D网格?我试图使用meshpy。如果我尝试运行,python告诉我错误:所有顶点都是共面的。Python网格生成
我目前正在研究一个有限元程序,第一步是构建几何图形的网格。有谁能够帮助我?
这就是我通常使用的代码,你可以在下面看到它。
import meshpy as mp
from meshpy.tet import MeshInfo, build
mesh_info = MeshInfo()
mesh = build(mesh_info)
mesh_info.set_points([
(0, 0, 0), (1.445, 0.19, 0), (3, 0.19, 0), (1.555, 0.19, 0),
(1.555, 2.81, 0), (3, 2.81, 0), (3, 3, 0), (0, 3, 0),
(0, 2.81, 0), (1.445, 2.81, 0), (1.445, 0.19, 0),
(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0),
mesh_info.set_facets([
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
[0,1,2],[0,2,3],
])
print('Mesh Points')
for i,p in enumerate(mesh_info.points):
print(i, p)
...创建您自己的网格数据结构?如果你知道Python中的OOP,那么这很简单 – meowgoesthedog