def setUp(self): h = np.ones(16) mesh = TreeMesh([h,2*h,3*h]) mesh.refine(3) mesh._refineCell([0,0,0,3]) mesh._refineCell([0,2,0,3]) self.mesh = mesh
def setUp(self): h = np.ones(16) mesh = TreeMesh([h, 2 * h, 3 * h]) mesh.refine(3) mesh._refineCell([0, 0, 0, 3]) mesh._refineCell([0, 2, 0, 3]) self.mesh = mesh
def test_UBCfiles(self): mesh = self.mesh # Make a vector vec = np.arange(mesh.nC) # Write and read mesh.writeUBC('temp.msh', {'arange.txt': vec}) meshUBC = TreeMesh.readUBC('temp.msh') vecUBC = meshUBC.readModelUBC('arange.txt') # The mesh assert mesh.__str__() == meshUBC.__str__() assert np.sum(mesh.gridCC - meshUBC.gridCC) == 0 assert np.sum(vec - vecUBC) == 0 assert np.all(np.array(mesh.h) - np.array(meshUBC.h) == 0) print 'IO of UBC octree files is working' os.remove('temp.msh') os.remove('arange.txt')
def test_UBCfiles(self): mesh = self.mesh # Make a vector vec = np.arange(mesh.nC) # Write and read mesh.writeUBC('temp.msh', {'arange.txt':vec}) meshUBC = TreeMesh.readUBC('temp.msh') vecUBC = meshUBC.readModelUBC('arange.txt') # The mesh assert mesh.__str__() == meshUBC.__str__() assert np.sum(mesh.gridCC - meshUBC.gridCC) == 0 assert np.sum(vec - vecUBC) == 0 assert np.all(np.array(mesh.h) - np.array(meshUBC.h) == 0) print 'IO of UBC octree files is working' os.remove('temp.msh') os.remove('arange.txt')