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_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')