单纯形网格的快速工具

meshplex的Python项目详细描述


meshplex

用于单纯形网格的快速工具。

CircleCIcodecovCode style: blackDocumentation StatusPyPi VersionGitHub starsPyPi downloads

以三角形和 四面体网格,注重效率。在很多情况下都有用,例如, 有限元和有限体积计算。

meshplex用于optimeshpyfvm

快速启动

import numpy
import meshplex

# create a simple MeshTri instance
points = numpy.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
cells = numpy.array([[0, 1, 2]])
mesh = meshplex.MeshTri(points, cells)
# or read it from a file
# mesh = meshplex.read("pacman.vtk")

# triangle volumes
print(mesh.cell_volumes)

# circumcenters, centroids, incenters
print(mesh.cell_circumcenters)
print(mesh.cell_centroids)
print(mesh.cell_incenters)

# circumradius, inradius, cell quality, angles
print(mesh.cell_circumradius)
print(mesh.cell_inradius)
print(mesh.cell_quality)  # d * inradius / circumradius (min 0, max 1)
print(mesh.angles)

# control volumes, centroids
print(mesh.control_volumes)
print(mesh.control_volume_centroids)

# covolume/edge length ratios
print(mesh.ce_ratios)

# flip edges until the mesh is Delaunay
mesh.flip_until_delaunay()

# show the mesh
mesh.show()

meshplex的工作方式与四面体网格几乎相同。所有文件 类和函数,请参见readthedocs

(对于网格创建,请签出 this list)。

绘制

三角形

importmeshplexmesh=meshplex.read("pacman-optimized.vtk")mesh.show(# show_coedges=True,# control_volume_centroid_color=None,# mesh_color="k",# nondelaunay_edge_color=None,# boundary_edge_color=None,# comesh_color=(0.8, 0.8, 0.8),show_axes=False,)

四面体
importnumpyimportmeshplex# Generate tetrahedronnode_coords=numpy.array([[1.0,0.0,-1.0/numpy.sqrt(8)],[-0.5,+numpy.sqrt(3.0)/2.0,-1.0/numpy.sqrt(8)],[-0.5,-numpy.sqrt(3.0)/2.0,-1.0/numpy.sqrt(8)],[0.0,0.0,numpy.sqrt(2.0)-1.0/numpy.sqrt(8)],])/numpy.sqrt(3.0)cells=[[0,1,2,3]]# Create mesh objectmesh=meshplex.MeshTetra(node_coords,cells)# Plot cell 0 with control volume boundariesmesh.show_cell(0,# barycenter_rgba=(1, 0, 0, 1.0),# circumcenter_rgba=(0.1, 0.1, 0.1, 1.0),# circumsphere_rgba=(0, 1, 0, 1.0),# incenter_rgba=(1, 0, 1, 1.0),# insphere_rgba=(1, 0, 1, 1.0),# face_circumcenter_rgba=(0, 0, 1, 1.0),control_volume_boundaries_rgba=(1.0,0.0,0.0,1.0),line_width=3.0,)

安装

meshplex是available from the Python Package Index,所以只需键入

pip3 install --user meshplex

安装。

测试

要运行meshplex单元测试,请签出此存储库并键入

pytest

许可证

meshplex发布在MIT license下。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面如何在JavaGUI中为按钮创建各种颜色?   使用MSCAPI的RSA密钥包装的java使用   java Spring数据Redis JedisConnectionException:意外的流结束   java饼图未显示预期输出   java hystrixCommand注释commandKey的用途是什么   windows java可以从cmd运行jar,但不能通过双击来运行   java在单击按钮时遍历XML节点   java试图使用日期(int,int,int)构造函数   带有Buildship 2子项目的java不作为项目依赖项链接   java jsonrpc4j:如何从服务器获取列表<SomeObject>?   用于Java应用程序的内存设置MaxDirectMemory和MaxHeapMemory   java如何从以下类型格式化日期   javayoutube。搜索列表搜索不返回任何内容   java My参数在方法中不起作用,因为泛型存在问题   java如何将Map<Key1Type,Val1Type>转换为Map<Key1Type,Val2Type>   JavaJUnit测试:测试用例的改进,测试数组列表的长度?   java如何在Android中解析带有属性值的xml数据?   使用Hibernate对枚举类型进行Java8bean验证