与tetgen的python接口
tetgen的Python项目详细描述
这个python模块是hang si的接口 {a3} C++软件。 该模块结合了C++的速度和便携性和安装方便性。 以及与PyVista的集成 三维可视化和分析。 有关详细信息,请参见TetGengithub页面 关于最初的创造者。
<>对原C++软件的最后一次更新是在2011年1月19日,但是 软件在今天仍然很重要。简要说明 Weierstrass Institute Software:TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralization, boundary conforming Delaunay meshes, and Voronoi partitions.
TetGen provides various features to generate good quality and adaptive tetrahedral meshes suitable for numerical methods, such as finite element or finite volume methods. For more information of TetGen, please take a look at a list of features.
基本示例
<>本模块实现的C++ TeGEN软件的特点主要有: 重点研究了流形三角形曲面的四面体化。这个基本 示例演示如何四面体化流形曲面并绘制 网格。importpyvistaaspvimporttetgenimportnumpyasnppv.set_plot_theme('document')sphere=pv.Sphere()tet=tetgen.TetGen(sphere)tet.tetrahedralize(order=1,mindihedral=20,minratio=1.5)grid=tet.gridgrid.plot(show_edges=True)
四面体球体
提取XY平面下球体四面体网格的一部分并绘制 网格质量。
# get cell centroidscells=grid.cells.reshape(-1,5)[:,1:]cell_center=grid.points[cells].mean(1)# extract cells below the 0 xy planemask=cell_center[:,2]<0cell_ind=mask.nonzero()[0]subgrid=grid.extract_cells(cell_ind)# advanced plottingplotter=pv.Plotter()plotter.add_mesh(subgrid,'lightgrey',lighting=True,show_edges=True)plotter.add_mesh(sphere,'r','wireframe')plotter.add_legend([[' Input Mesh ','r'],[' Tesselated Mesh ','black']])plotter.show()
单元格质量标量可以通过以下方式获取和绘制:
cell_qual=subgrid.quality# plot qualitysubgrid.plot(scalars=cell_qual,stitle='Quality',cmap='bwr',clim=[0,1],flip_scalars=True,show_edges=True,)
致谢
软件最初是由Hang Si根据 TetGen, a Delaunay-Based Quality Tetrahedral Mesh Generator。