我在 gambit 中生成了一个网格文件,并希望将其转换为 xml 格式。我尝试了下面的代码,但没有输出。
from dolfin import *
from dolfin_utils import meshconvert
dolfin-convert cylinder6.msh out.xml
谁能告诉我如何使用 dolfin 进行转换?
我在 gambit 中生成了一个网格文件,并希望将其转换为 xml 格式。我尝试了下面的代码,但没有输出。
from dolfin import *
from dolfin_utils import meshconvert
dolfin-convert cylinder6.msh out.xml
谁能告诉我如何使用 dolfin 进行转换?
从终端窗口使用 dolfin-convert。
要查看 dolfin-convert 可以处理哪些网格类型,请参阅命令行帮助:
$ dolfin-convert
Usage: dolfin-convert [OPTIONS] ... input.x output.y
Options:
-h display this help text and exit
-i format specify input format
-o format specify output format
Alternatively, the following long options may be used:
--help same as -h
--input same as -i
--output same as -o
Supported formats:
xml - DOLFIN XML mesh format (current)
xml-old - DOLFIN XML mesh format (DOLFIN 0.6.2 and earlier)
mesh - Medit, generated by tetgen with option -g
Triangle - Triangle file format (input prefix of .ele and .node files)
gmsh - Gmsh, version 2.0 file format
metis - Metis graph file format
scotch - Scotch graph file format
diffpack - Diffpack tetrahedral grid format
abaqus - Abaqus tetrahedral grid format
ExodusII - Sandia Format (requires ncdump utility from NetCDF)
Star-CD - Star-CD tetrahedral grid format
If --input or --output are not specified, the format will
be deduced from the suffix:
.xml - xml
.mesh - mesh
.gmsh - gmsh
.msh - gmsh
.gra - metis
.grf - scotch
.grid - diffpack
.inp - abaqus
.e - Exodus II
.exo - Exodus II
.ncdf - ncdump'ed Exodus II
.vrt and .cell - starcd
要从 python 调用 dolfin 网格转换实用程序,请尝试:
from dolfin_utils import meshconvert
# Convert to XML
meshconvert.convert2xml(ifilename, ofilename, iformat=iformat)
但是你必须自己订购网格(或调用命令 dolfin-order)
# Order mesh
os.system("dolfin-order %s" % ofilename)
meshio(我的一个小项目)具有可以执行此操作的命令行工具:
meshio-convert cylinder6.msh out.xml
要从 python 运行 shell 脚本(例如dolfin-convert),您必须通过 将必要的命令行传递给 shell os.system(),例如,
import os
os.system('dolfin-convert carbon_f.msh mesh.xml')