本文整理汇总了Python中pylith.meshio.MeshIOAscii.MeshIOAscii.write方法的典型用法代码示例。如果您正苦于以下问题:Python MeshIOAscii.write方法的具体用法?Python MeshIOAscii.write怎么用?Python MeshIOAscii.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylith.meshio.MeshIOAscii.MeshIOAscii
的用法示例。
在下文中一共展示了MeshIOAscii.write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_readwrite
# 需要导入模块: from pylith.meshio.MeshIOAscii import MeshIOAscii [as 别名]
# 或者: from pylith.meshio.MeshIOAscii.MeshIOAscii import write [as 别名]
def test_readwrite(self):
"""
Test write() and read().
"""
filenameIn = "data/mesh2Din3D.txt"
filenameOut = "data/mesh2Din3D_test.txt"
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs._configure()
io = MeshIOAscii()
io.inventory.filename = filenameIn
io.inventory.coordsys = cs
io._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
mesh = io.read(debug=False, interpolate=True)
io.filename(filenameOut)
io.write(mesh)
fileE = open(filenameIn, "r")
linesE = fileE.readlines()
fileE.close()
fileT = open(filenameOut, "r")
linesT = fileT.readlines()
fileT.close()
self.assertEqual(len(linesE), len(linesT))
for (lineE, lineT) in zip(linesE, linesT):
self.assertEqual(lineE, lineT)
return
示例2: test_readwrite
# 需要导入模块: from pylith.meshio.MeshIOAscii import MeshIOAscii [as 别名]
# 或者: from pylith.meshio.MeshIOAscii.MeshIOAscii import write [as 别名]
def test_readwrite(self):
"""
Test read().
"""
filenameGmvIn = "data/cube2_ascii.gmv"
filenamePsetIn = "data/cube2_ascii.pset"
filenameOut = "data/cube2_test.txt"
filenameE = "data/cube2.txt"
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs._configure()
# For now, we only test reading the file. We would like to write
# the file and compare against the original.
io = MeshIOLagrit()
io.inventory.filenameGmv = filenameGmvIn
io.inventory.filenamePset = filenamePsetIn
io._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
mesh = io.read(debug=False, interpolate=True)
testhandler = MeshIOAscii()
testhandler.filename(filenameOut)
testhandler.coordsys = cs
testhandler.write(mesh)
fileE = open(filenameE, "r")
linesE = fileE.readlines()
fileE.close()
fileT = open(filenameOut, "r")
linesT = fileT.readlines()
fileT.close()
self.assertEqual(len(linesE), len(linesT))
for (lineE, lineT) in zip(linesE, linesT):
self.assertEqual(lineE, lineT)
return
示例3: test_readwrite
# 需要导入模块: from pylith.meshio.MeshIOAscii import MeshIOAscii [as 别名]
# 或者: from pylith.meshio.MeshIOAscii.MeshIOAscii import write [as 别名]
def test_readwrite(self):
"""
Test read().
"""
filenameIn = "data/twohex8.exo"
filenameOut = "data/twohex8_test.txt"
filenameE = "data/twohex8.txt"
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs._configure()
# For now, we only test reading the file.
io = MeshIOCubit()
io.inventory.filename = filenameIn
io.inventory.useNames = False
io._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
mesh = io.read(debug=False, interpolate=False)
testhandler = MeshIOAscii()
testhandler.filename(filenameOut)
testhandler.coordsys = cs
testhandler.write(mesh)
fileE = open(filenameE, "r")
linesE = fileE.readlines()
fileE.close()
fileT = open(filenameOut, "r")
linesT = fileT.readlines()
fileT.close()
self.assertEqual(len(linesE), len(linesT))
for (lineE, lineT) in zip(linesE, linesT):
self.assertEqual(lineE, lineT)
return
示例4: len
# 需要导入模块: from pylith.meshio.MeshIOAscii import MeshIOAscii [as 别名]
# 或者: from pylith.meshio.MeshIOAscii.MeshIOAscii import write [as 别名]
if len(sys.argv) != 2:
raise ValueError("usage: exotoascii.py EXODUS_MESH")
filenameEXO = sys.argv[1]
filenameASCII = filenameEXO.replace(".exo", ".mesh")
from pylith.meshio.MeshIOAscii import MeshIOAscii
from pylith.meshio.MeshIOCubit import MeshIOCubit
import pylith.utils.petsc as petsc
petsc.initialize(sys.argv)
cubit = MeshIOCubit()
cubit.inventory.filename = filenameEXO
cubit._configure()
mesh = cubit.read(debug=False, interpolate=True)
ascii = MeshIOAscii()
ascii.inventory.filename = filenameASCII
ascii._configure()
ascii.write(mesh)
del cubit
del ascii
del mesh
petsc.finalize()
# End of file