def test_contact2(self): nx = 10 ny = 10 layer = Layer(nx,ny) grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) # Too short with self.assertRaises(ValueError): layer.addIJBarrier( [(1,5)] ) # Out of range with self.assertRaises(ValueError): layer.addIJBarrier( [(10,15),(5,5)] ) # Out of range with self.assertRaises(ValueError): layer.addIJBarrier( [(7,7),(-5,5)] ) # Must have either i1 == i2 or j1 == j2 with self.assertRaises(ValueError): layer.addIJBarrier( [(7,8),(6,5)] ) p1 = (0 , 4) p2 = (0 , 5) self.assertTrue(layer.cellContact( p1 , p2 )) layer.addIJBarrier( [(0,5) , (nx , 5)] ) self.assertFalse(layer.cellContact( p1 , p2 ))
def test_get_barrier(self): layer = Layer(10,10) self.assertFalse( layer.leftBarrier(5,5) ) self.assertFalse( layer.bottomBarrier(5,5) ) layer.addIJBarrier([(1,1),(2,1),(2,2)]) self.assertTrue( layer.bottomBarrier(1,1) ) self.assertTrue( layer.leftBarrier(2,1) )
def test_update_connected(self): nx = 10 ny = 10 layer = Layer(nx,ny) layer[0,0] = 100 self.assertEqual( layer[0,0], 100 ) layer.clearCells() self.assertEqual( layer[0,0], 0 ) self.assertEqual( layer.cellSum( ) , 0 ) with self.assertRaises(ValueError): layer.updateConnected( (10,10) , 10 ) layer[0,0] = 77 with self.assertRaises(ValueError): layer.updateConnected( (0,0) , 10 , org_value = 0) layer.updateConnected( (0,0) , 10 ) self.assertEqual( 10 , layer.cellSum() ) layer[0,0] = 0 layer.updateConnected( (0,0) , 3 ) self.assertEqual( nx*ny*3 , layer.cellSum() ) layer.addIJBarrier( [(5,0), (5,10)] ) layer.clearCells( ) self.assertEqual( 0 , layer.cellSum( ) ) layer.updateConnected( (0,0) , 1 ) self.assertEqual( 50 , layer.cellSum( ) ) self.assertEqual( layer[4,0] , 1 ) self.assertEqual( layer[5,0] , 0 ) layer = Layer(nx,ny) layer.addIJBarrier( [(5,0), (5,5)] ) layer.updateConnected( (0,0) , 1 ) self.assertEqual( 100 , layer.cellSum( ) )