def test_flyTags(self): dom=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH, "rectangle_8x10.fly")) tags=sorted(dom.showTagNames().split(', ')) self.assertEqual(tags,sorted(['top', 'bottom', 'left', 'right'])) self.assertEqual(dom.getTag('top'),20,'error with top') self.assertEqual(dom.getTag('bottom'),10,'error with bottom,') self.assertEqual(dom.getTag('left'),1,'error with left') self.assertEqual(dom.getTag('right'),2,'error with reight') self.assertRaises(ValueError, dom.getTag, 'tag4')
def test_flyTags(self): dom = ReadMesh( os.path.join(FINLEY_TEST_MESH_PATH, "rectangle_8x10.fly")) tags = sorted(dom.showTagNames().split(', ')) self.assertEqual(tags, sorted(['top', 'bottom', 'left', 'right'])) self.assertEqual(dom.getTag('top'), 20, 'error with top') self.assertEqual(dom.getTag('bottom'), 10, 'error with bottom,') self.assertEqual(dom.getTag('left'), 1, 'error with left') self.assertEqual(dom.getTag('right'), 2, 'error with reight') self.assertRaises(ValueError, dom.getTag, 'tag4')
def test_brickReadMesh(self): fname=os.path.join(FINLEY_TEST_MESH_PATH,'brick_4x4x4.fly') self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0)]) self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0)]) self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40]) self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"]) z=ReadMesh(fname, diracPoints=[(0,0,1), (0.25,0.25, 0.25)], diracTags=[40,51]) z=ReadMesh(fname, diracPoints=[(0.125,0.625,0), (0.5,1,1), (0.75, 0.25,0), (0.89, 0.875, 0.5)], diracTags=["A", "B", "A", "C"]) v=interpolate(z.getX(), DiracDeltaFunctions(z)) if mpisize==1: self.assertEqual(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 1.0), (0.75, 0.25, 0.0), (1.0, 0.75, 0.5)]) self.assertEqual(v.getNumberOfDataPoints(), 4) self.assertEqual(inf(v[0]), 0) self.assertEqual(inf(v[1]), 0.25) self.assertEqual(Lsup(v[0]), 1) self.assertEqual(Lsup(v[1]), 1) v.setTaggedValue("A",(-10,0.5,-0.5)) if mpisize==1: self.assertEqual(inf(v[0]), -10) self.assertEqual(inf(v[1]), 0.5) self.assertEqual(inf(v[2]), -0.5) v.setTaggedValue(500,(-100,-100, -100)) # non-existant tag if mpisize==1: self.assertEqual(inf(v[0]), -10) self.assertEqual(inf(v[1]), 0.5) self.assertEqual(inf(v[2]), -0.5) self.assertEqual(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top') self.assertEqual(z.getTag("C"), 203)
def test_ReadWriteTagNames(self): file="hex_2D_order2.msh" test = os.path.join(FINLEY_WORKDIR,"test.fly") dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,file),3,optimize=False) insertTagNames(dom,A=1,B=2) dom.write(test) dom2 = ReadMesh(test,3,optimize=False) t=getTagNames(dom) self.assertTrue(len(t)==6) self.assertTrue("A" in t) self.assertTrue("B" in t) self.assertTrue(dom2.getTag("A") == 1) self.assertTrue(dom2.getTag("B") == 2) self.assertTrue(dom2.isValidTagName("A")) self.assertTrue(dom2.isValidTagName("B"))
def test_ReadWriteTagNames(self): file = "hex_2D_order2.msh" test = os.path.join(FINLEY_WORKDIR, "test.fly") dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH, file), 3, optimize=False) insertTagNames(dom, A=1, B=2) dom.write(test) dom2 = ReadMesh(test, 3, optimize=False) t = getTagNames(dom) self.assertTrue(len(t) == 6) self.assertTrue("A" in t) self.assertTrue("B" in t) self.assertTrue(dom2.getTag("A") == 1) self.assertTrue(dom2.getTag("B") == 2) self.assertTrue(dom2.isValidTagName("A")) self.assertTrue(dom2.isValidTagName("B"))