创建并将立方体球体网格转换为非结构网格
csgrid2unstr的Python项目详细描述
安装
您可以通过PIP轻松安装此软件包,即
$ pip install csgrid2unstr --user
当然,您可以直接从存储库安装它:
$ git clone https://github.com/chiao45/csgrid2unstr.git $cd csgrid2unstr && python setup.py install --user
请注意,此包取决于:
用法
作为可执行二进制文件
安装软件包后,打开终端并键入:
$ csgrid2unstr -h usage: csgrid2unstr [-h] [-n SIZE] [-o OUTPUT] [-r REFINE] [-f {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl}] [-b] [-V] [-v] write CSGrid to unstr optional arguments: -h, --help show this help message and exit -n SIZE, --size SIZE Number of intervals of a square face -o OUTPUT, --output OUTPUT Output file name, w/o extension -r REFINE, --refine REFINE Level of refinements, default is 1 -f {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl}, --format {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl} Output file format, default is VTK -b, --binary Use BINARY. Notice that this flag is ignored for some formats -V, --verbose Verbose output -v, --version Check version
如果有command not found: csgrid2unstr,请确保csgrid2unstr是 在你的$PATH里。
必须提供两个参数,即-n(--size)和-o (--output)。前者是定义一个正方形的间隔数 面,即面的四边形数是n*n,后者是 提供输出文件名(,不带扩展名)。例如:
$ csgrid2unstr -n 20 -o demo
将为每个面构造400个四边形的CSGrid,并将其转换为 一个非结构化网格并将其存储在demo.vtk中。
通过添加^{tt9},可以创建一系列统一的优化网格$ (--refine)开关,例如:
$ csgrid2unstr -n 10 -r 3 -o demo -f xdmf
将构建三个CSGrid,每个面有100、400和1600个四边形, 将它们转换为三个非结构化网格并存储在demo0.xdmf, demo1.xdmf,和demo2.xdfm,分别是。
作为模块
使用csgrid2unstr作为python模块也很简单。
from__future__importprint_functionfromcsgrid2unstr.cubed_sphereimportCSGridfromcsgrid2unstr.unstrimportUnstr# create a CSGrid of 25 quads per facecs=CSGrid(5)# convert it into an unstructured meshmesh=Unstr(cs)# two attributes, points and cells, of np.ndarrayprint('Nodes {}-by-3'.format(len(mesh.points)))print(mesh.points)print('Cells {}-by-4'.format(len(mesh.cells)))print(mesh.cells)
许可证
麻省理工学院许可证
版权所有(c)2018乔晨