def test_filename(self): """ Test filename(). """ value = "hi.txt" io = MeshIOCubit() io.filename(value) self.assertEqual(value, io.filename()) return
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=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
#!/usr/bin/env nemesis import sys 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()
def test_constructor(self): """ Test constructor. """ io = MeshIOCubit() return