def test_fault_block(self):
        grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1))
        kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT)
        kw.assign(0)
        for j in range(1, 4):
            for i in range(1, 4):
                g = i + j * grid.getNX()
                kw[g] = 1

        layer = FaultBlockLayer(grid, 0)
        layer.scanKeyword(kw)
        block = layer[1]

        self.assertEqual((2.50, 2.50), block.getCentroid())
        self.assertEqual(len(block), 9)
        self.assertEqual(layer, block.getParentLayer())
Exemple #2
0
    def test_fault_block(self):
        grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) )
        kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT )
        kw.assign( 0 )
        for j in range(1,4):
            for i in range(1,4):
                g = i + j*grid.getNX()
                kw[g] = 1

        layer = FaultBlockLayer( grid , 0 )
        layer.scanKeyword( kw )
        block = layer[1]

        self.assertEqual( (2.50 , 2.50) , block.getCentroid() )
        self.assertEqual( len(block) , 9)
        self.assertEqual( layer , block.getParentLayer() )
Exemple #3
0
    def test_stepped(self):
        grid = EclGrid.createRectangular((6, 1, 4), (1, 1, 1))
        f = Fault(grid, "F")
        f.addRecord(4, 4, 0, 0, 0, 1, "X")
        f.addRecord(2, 2, 0, 0, 1, 1, "Z")
        f.addRecord(1, 1, 0, 0, 2, 3, "X")

        block_kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT)
        block_kw.assign(1)
        block_kw[5] = 2
        block_kw[11] = 2
        block_kw[14:18] = 2
        block_kw[14:18] = 2
        block_kw[20:23] = 2

        layer0 = FaultBlockLayer(grid, 0)
        layer0.scanKeyword(block_kw)
        layer0.addFaultBarrier(f)
        self.assertTrue(layer0.cellContact((0, 0), (1, 0)))
        self.assertFalse(layer0.cellContact((4, 0), (5, 0)))

        layer1 = FaultBlockLayer(grid, 1)
        layer1.scanKeyword(block_kw)
        layer1.addFaultBarrier(f)
        self.assertTrue(layer1.cellContact((0, 0), (1, 0)))
        self.assertFalse(layer1.cellContact((4, 0), (5, 0)))

        layer2 = FaultBlockLayer(grid, 2)
        layer2.scanKeyword(block_kw)
        layer2.addFaultBarrier(f)
        self.assertTrue(layer2.cellContact((0, 0), (1, 0)))
        self.assertFalse(layer2.cellContact((1, 0), (2, 0)))

        layer3 = FaultBlockLayer(grid, 3)
        layer3.scanKeyword(block_kw)
        layer3.addFaultBarrier(f)
        self.assertTrue(layer3.cellContact((0, 0), (1, 0)))
        self.assertFalse(layer3.cellContact((1, 0), (2, 0)))
Exemple #4
0
    def test_stepped(self):
        grid = EclGrid.createRectangular( (6,1,4) , (1,1,1))
        f = Fault(grid , "F")
        f.addRecord(4,4,0,0,0,1,"X")
        f.addRecord(2,2,0,0,1,1,"Z")
        f.addRecord(1,1,0,0,2,3,"X")
        
        block_kw = EclKW("FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT)
        block_kw.assign(1)
        block_kw[5] = 2
        block_kw[11] = 2
        block_kw[14:18] = 2
        block_kw[14:18] = 2
        block_kw[20:23] = 2
        
        layer0 = FaultBlockLayer( grid , 0 )
        layer0.scanKeyword( block_kw )
        layer0.addFaultBarrier( f )
        self.assertTrue( layer0.cellContact((0,0) , (1,0)))
        self.assertFalse( layer0.cellContact((4,0) , (5,0)))

        layer1 = FaultBlockLayer( grid , 1 )
        layer1.scanKeyword( block_kw )
        layer1.addFaultBarrier( f )
        self.assertTrue( layer1.cellContact((0,0) , (1,0)))
        self.assertFalse( layer1.cellContact((4,0) , (5,0)))

        layer2 = FaultBlockLayer( grid , 2 )
        layer2.scanKeyword( block_kw )
        layer2.addFaultBarrier( f )
        self.assertTrue( layer2.cellContact((0,0) , (1,0)))
        self.assertFalse( layer2.cellContact((1,0) , (2,0)))

        layer3 = FaultBlockLayer( grid , 3 )
        layer3.scanKeyword( block_kw )
        layer3.addFaultBarrier( f )
        self.assertTrue( layer3.cellContact((0,0) , (1,0)))
        self.assertFalse( layer3.cellContact((1,0) , (2,0)))
Exemple #5
0
 def test_load(self):
     for k in range(self.grid.getNZ()):
         faultBlocks = FaultBlockLayer(self.grid, k)
         faultBlocks.scanKeyword(self.kw)
         for block in faultBlocks:
             centroid = block.getCentroid()
    def test_fault_block_layer(self):
        with self.assertRaises(ValueError):
            layer = FaultBlockLayer(self.grid, -1)

        with self.assertRaises(ValueError):
            layer = FaultBlockLayer(self.grid, self.grid.getGlobalSize())

        layer = FaultBlockLayer(self.grid, 1)
        self.assertEqual(1, layer.getK())

        kw = EclKW("FAULTBLK", self.grid.getGlobalSize(),
                   EclDataType.ECL_FLOAT)
        with self.assertRaises(ValueError):
            layer.scanKeyword(kw)

        layer.scanKeyword(self.kw)
        self.assertEqual(2, len(layer))

        with self.assertRaises(TypeError):
            ls = layer["JJ"]

        l = []
        for blk in layer:
            l.append(blk)
        self.assertEqual(len(l), 2)

        l0 = layer[0]
        l1 = layer[1]
        self.assertTrue(isinstance(l1, FaultBlock))
        l0.getCentroid()
        l1.getBlockID()

        with self.assertRaises(IndexError):
            l2 = layer[2]

        self.assertEqual(True, 1 in layer)
        self.assertEqual(True, 2 in layer)
        self.assertEqual(False, 77 in layer)
        self.assertEqual(False, 177 in layer)

        l1 = layer.getBlock(1)
        self.assertTrue(isinstance(l1, FaultBlock))

        with self.assertRaises(KeyError):
            l = layer.getBlock(66)

        with self.assertRaises(KeyError):
            layer.deleteBlock(66)

        layer.deleteBlock(2)
        self.assertEqual(1, len(layer))
        blk = layer[0]
        self.assertEqual(blk.getBlockID(), 1)

        with self.assertRaises(KeyError):
            layer.addBlock(1)

        blk2 = layer.addBlock(2)
        self.assertEqual(len(layer), 2)

        blk3 = layer.addBlock()
        self.assertEqual(len(layer), 3)

        layer.addBlock(100)
        layer.addBlock(101)
        layer.addBlock(102)
        layer.addBlock(103)

        layer.deleteBlock(2)
        blk1 = layer.getBlock(103)
        blk2 = layer[-1]
        self.assertEqual(blk1.getBlockID(), blk2.getBlockID())

        fault_block = layer[0]
        fault_block.assignToRegion(2)
        self.assertEqual([2], list(fault_block.getRegionList()))

        fault_block.assignToRegion(2)
        self.assertEqual([2], list(fault_block.getRegionList()))

        fault_block.assignToRegion(3)
        self.assertEqual([2, 3], list(fault_block.getRegionList()))

        fault_block.assignToRegion(1)
        self.assertEqual([1, 2, 3], list(fault_block.getRegionList()))

        fault_block.assignToRegion(2)
        self.assertEqual([1, 2, 3], list(fault_block.getRegionList()))
Exemple #7
0
    def test_fault_block_layer(self):
        with self.assertRaises(ValueError):
            layer = FaultBlockLayer( self.grid , -1 )

        with self.assertRaises(ValueError):
            layer = FaultBlockLayer( self.grid , self.grid.getGlobalSize()  )
            
        layer = FaultBlockLayer( self.grid , 1 )
        self.assertEqual( 1 , layer.getK() )

        kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT )
        with self.assertRaises(ValueError):
            layer.scanKeyword( kw )

        layer.scanKeyword( self.kw )
        self.assertEqual( 2 , len(layer) )

        with self.assertRaises(TypeError):
            ls = layer["JJ"]

        l = []
        for blk in layer:
            l.append( blk )
        self.assertEqual( len(l) , 2 )

        l0 = layer[0]
        l1 = layer[1]
        self.assertTrue( isinstance(l1 , FaultBlock ))
        l0.getCentroid()
        l1.getBlockID()

        with self.assertRaises(IndexError):
            l2 = layer[2]

            
        self.assertEqual( True , 1 in layer)
        self.assertEqual( True , 2 in layer)
        self.assertEqual( False , 77 in layer)
        self.assertEqual( False , 177 in layer)

        l1 = layer.getBlock( 1 )
        self.assertTrue( isinstance(l1 , FaultBlock ))
        
        with self.assertRaises(KeyError):
            l =layer.getBlock(66)

        with self.assertRaises(KeyError):
            layer.deleteBlock(66)

        layer.deleteBlock(2)
        self.assertEqual( 1 , len(layer))
        blk = layer[0]
        self.assertEqual( blk.getBlockID() , 1 ) 

        with self.assertRaises(KeyError):
            layer.addBlock(1)
            
        blk2 = layer.addBlock(2)
        self.assertEqual( len(layer) , 2 ) 
        
        blk3 = layer.addBlock()
        self.assertEqual( len(layer) , 3 ) 
        

        layer.addBlock(100)
        layer.addBlock(101)
        layer.addBlock(102)
        layer.addBlock(103)

        layer.deleteBlock(2)
        blk1 = layer.getBlock( 103 )
        blk2 = layer[-1]
        self.assertEqual( blk1.getBlockID() , blk2.getBlockID() )

        fault_block = layer[0]
        fault_block.assignToRegion( 2 )
        self.assertEqual( [2] , list(fault_block.getRegionList()))

        fault_block.assignToRegion( 2 )
        self.assertEqual( [2] , list(fault_block.getRegionList()))

        fault_block.assignToRegion( 3 )
        self.assertEqual( [2,3] , list(fault_block.getRegionList()))

        fault_block.assignToRegion( 1 )
        self.assertEqual( [1,2,3] , list(fault_block.getRegionList()))

        fault_block.assignToRegion( 2 )
        self.assertEqual( [1,2,3] , list(fault_block.getRegionList()))