Exemplo n.º 1
0
    def test_get_ijk(self):
        with TestAreaContext("python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")

            kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
        
        grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        layer.loadKeyword( kw )

        block = layer[0,0]
        self.assertEqual( block.getBlockID() , 1 )

        block = layer[2,2]
        self.assertEqual( block.getBlockID() , 2 )

        with self.assertRaises(ValueError):
            layer[3,3]

        with self.assertRaises(IndexError):
            layer[5,5]
Exemplo n.º 2
0
    def splitFaultBlockClosedPolygon( grid , fault_blocks , polygon ):
        """
        Special case code when the region is limited only by one polygon.
        """
        new_fault_blocks = FaultBlockLayer( grid , fault_blocks.getK() )
        new_block = new_fault_blocks.addBlock()

        for block in fault_blocks:
            for p in block:
                if GeometryTools.pointInPolygon( (p.x , p.y) , polygon ):
                    new_block.addCell(p.i , p.j)
        
        return new_fault_blocks
Exemplo n.º 3
0
 def test_add_polyline_barrier1(self):
     grid = EclGrid.create_rectangular( (4,1,1) , (1,1,1) )
     layer = FaultBlockLayer( self.grid , 0 )
     polyline = Polyline( init_points = [ (1.99 , 0.001) , (2.01 , 0.99)])
     
     points = [((1,0) , (2,0))]
     
     geo_layer = layer.getGeoLayer()
     for p1,p2 in points:
         self.assertTrue(geo_layer.cellContact( p1 , p2 ))
         
     layer.addPolylineBarrier( polyline )
     for p1,p2 in points:
         print(p1,p2)
         self.assertFalse(geo_layer.cellContact( p1 , p2 ))
Exemplo n.º 4
0
    def test_add_polyline_barrier1(self):
        grid = EclGrid.createRectangular((4, 1, 1), (1, 1, 1))
        layer = FaultBlockLayer(self.grid, 0)
        polyline = Polyline(init_points=[(1.99, 0.001), (2.01, 0.99)])

        points = [((1, 0), (2, 0))]

        geo_layer = layer.getGeoLayer()
        for p1, p2 in points:
            self.assertTrue(geo_layer.cellContact(p1, p2))

        layer.addPolylineBarrier(polyline)
        for p1, p2 in points:
            print(p1, p2)
            self.assertFalse(geo_layer.cellContact(p1, p2))
Exemplo n.º 5
0
    def test_fault_block(self):
        grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) )
        kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE )
        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() )
Exemplo n.º 6
0
    def test_internal_blocks(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        with TestAreaContext("python/FaultBlocks/internal_blocks"):
            with open("faultblock.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 4 4 1 2 5 5 2 \n")
                fileH.write("1 4 4 1 2 5 5 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 3 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("/\n")


            kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   4   4   1   4   1   1  'X'  /\n")
                f.write("\'FX\'   5   5   4   4   1   1  'Y'  /\n")
                f.write("\'FX\'   5   5   5   8   1   1  'X'  /\n")
                f.write("/")
            
            faults = FaultCollection( grid , "faults.grdecl")

        layer.loadKeyword( kw )
        layer.addFaultBarrier( faults["FX"] )
        b1 = layer.getBlock( 1 )
        b2 = layer.getBlock( 2 )
        b3 = layer.getBlock( 3 )
        b4 = layer.getBlock( 4 )
        b5 = layer.getBlock( 5 )


        nb = b1.getNeighbours()
        for b in nb:
            print('Block:%d' % b.getBlockID())

        self.assertTrue( len(nb) == 2 )
        self.assertTrue( b3 in nb )
        self.assertTrue( b4 in nb )

        nb = b2.getNeighbours()
        self.assertTrue( len(nb) == 1 )
        self.assertTrue( b5 in nb )
Exemplo n.º 7
0
    def test_fault_block_edge(self):
        grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) )
        kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE )
        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 )
Exemplo n.º 8
0
    def test_fault_block_edge(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 )
    def setUp(self):
        self.grid = EclGrid(
            self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID"))

        with open(
                self.createTestPath(
                    "Statoil/ECLIPSE/Mariner/faultblock.grdecl")) as fileH:
            self.kw = EclKW.read_grdecl(fileH,
                                        "FAULTBLK",
                                        ecl_type=EclTypeEnum.ECL_INT_TYPE)

        self.faults = FaultCollection(
            self.grid,
            self.createTestPath("Statoil/ECLIPSE/Mariner/faults.grdecl"))
        self.poly_file1 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol1.xyz")
        self.poly_file2 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol2.xyz")
        self.poly_file3 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol3.xyz")
        self.poly_file4 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol4.xyz")
        self.poly_file5 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol5.xyz")
        self.poly_file6 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol6.xyz")
        self.poly_file7 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol7.xyz")
        self.poly_file8 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol8.xyz")
        self.poly_file9 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol9.xyz")
        self.poly_file10 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol10.xyz")
        self.poly_file11 = self.createTestPath(
            "Statoil/ECLIPSE/Mariner/pol11.xyz")

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            blocks = FaultBlockLayer(self.grid, k)
            blocks.scanKeyword(self.kw)
            self.fault_blocks.append(blocks)
Exemplo n.º 10
0
    def setUp(self):
        self.grid = EclGrid.create_rectangular( (16,16,1) , (1,1,1) )
        self.poly1 = Polyline(init_points = [(0,0) , (0,4) , (5,5) , (0,5)])
        self.poly2 = Polyline(init_points = [(11,11) , (16,12) , (16,16) , (12,16)])
        self.fault_block_kw = EclKW.create( "FAULTBLK" , self.grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE )
        self.fault_block_kw.assign( 0 )
        self.faults = FaultCollection( self.grid )
        for j in range(4):
            for i in range(4):
                g1 = i + j*self.grid.getNX()
                g2 = i + 12 + (j + 12)* self.grid.getNX()
                
                self.fault_block_kw[g1] = 1
                self.fault_block_kw[g2] = 2

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            block = FaultBlockLayer( self.grid , k)
            block.scanKeyword( self.fault_block_kw )
            self.fault_blocks.append( block )
Exemplo n.º 11
0
    def setUp(self):
        self.grid = EclGrid.create_rectangular((16, 16, 1), (1, 1, 1))
        self.poly1 = Polyline(init_points=[(0, 0), (0, 4), (5, 5), (0, 5)])
        self.poly2 = Polyline(init_points=[(11, 11), (16, 12), (16,
                                                                16), (12, 16)])
        self.fault_block_kw = EclKW.create("FAULTBLK",
                                           self.grid.getGlobalSize(),
                                           EclTypeEnum.ECL_INT_TYPE)
        self.fault_block_kw.assign(0)
        self.faults = FaultCollection(self.grid)
        for j in range(4):
            for i in range(4):
                g1 = i + j * self.grid.getNX()
                g2 = i + 12 + (j + 12) * self.grid.getNX()

                self.fault_block_kw[g1] = 1
                self.fault_block_kw[g2] = 2

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            block = FaultBlockLayer(self.grid, k)
            block.scanKeyword(self.fault_block_kw)
            self.fault_blocks.append(block)
Exemplo n.º 12
0
    def test_fault_block_layer_export(self):
        layer = FaultBlockLayer( self.grid , 1 )
        kw1 = EclKW.create( "FAULTBLK" , self.grid.size + 1 , EclTypeEnum.ECL_INT_TYPE )
        with self.assertRaises(ValueError):
            layer.exportKeyword( kw1 )

        kw2 = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE )
        with self.assertRaises(TypeError):
            layer.exportKeyword(kw2)
Exemplo n.º 13
0
    def test_fault_block_layer_export(self):
        layer = FaultBlockLayer( self.grid , 1 )
        kw1 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() + 1 , EclDataType.ECL_INT )
        with self.assertRaises(ValueError):
            layer.exportKeyword( kw1 )

        kw2 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT )
        with self.assertRaises(TypeError):
            layer.exportKeyword(kw2)
Exemplo n.º 14
0
    def test_neighbours(self):

        with TestAreaContext(
                "python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl", "w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")

            kw = EclKW.read_grdecl(open("kw.grdecl"),
                                   "FAULTBLK",
                                   ecl_type=EclTypeEnum.ECL_INT_TYPE)

        grid = EclGrid.create_rectangular((5, 5, 1), (1, 1, 1))
        layer = FaultBlockLayer(grid, 0)

        layer.loadKeyword(kw)
        block1 = layer.getBlock(1)
        block2 = layer.getBlock(2)
        block3 = layer.getBlock(3)
        block4 = layer.getBlock(4)
        block5 = layer.getBlock(5)
        self.assertEqual(block1.getParentLayer(), layer)

        #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {}

        neighbours = block1.getNeighbours()
        self.assertEqual(len(neighbours), 2)
        self.assertTrue(block2 in neighbours)
        self.assertTrue(block4 in neighbours)

        neighbours = block2.getNeighbours()
        self.assertEqual(len(neighbours), 3)
        self.assertTrue(block1 in neighbours)
        self.assertTrue(block3 in neighbours)
        self.assertTrue(block4 in neighbours)

        neighbours = block3.getNeighbours()
        self.assertEqual(len(neighbours), 1)
        self.assertTrue(block2 in neighbours)

        neighbours = block4.getNeighbours()
        self.assertEqual(len(neighbours), 2)
        self.assertTrue(block1 in neighbours)
        self.assertTrue(block2 in neighbours)

        neighbours = block5.getNeighbours()
        self.assertEqual(len(neighbours), 0)
Exemplo n.º 15
0
 def test_add_polyline_barrier2(self):
     grid = EclGrid.create_rectangular( (10,10,1) , (1,1,1) )
     layer = FaultBlockLayer( self.grid , 0 )
     polyline = Polyline( init_points = [ (0.1 , 0.9) , (8.9,0.9) , (8.9,8.9) ])
     
     points = [((0,0) , (0,1)),
               ((2,0) , (2,1)),
               ((4,0) , (4,1)),
               ((6,0) , (6,1)),
               ((8,0) , (8,1)),
               #
               ((8,1) , (9,1)),
               ((8,3) , (9,3)),
               ((8,5) , (9,5)),
               ((8,7) , (9,7))]
     
     geo_layer = layer.getGeoLayer()
     for p1,p2 in points:
         self.assertTrue(geo_layer.cellContact( p1 , p2 ))
         
     layer.addPolylineBarrier( polyline )
     for p1,p2 in points:
         print(p1,p2)
         self.assertFalse(geo_layer.cellContact( p1 , p2 ))
    def setUp(self):
        self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID"))

        with open( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) as fileH:
            self.kw = EclKW.read_grdecl( fileH , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE )

        self.faults = FaultCollection( self.grid , self.createTestPath("Statoil/ECLIPSE/Mariner/faults.grdecl"))
        self.poly_file1  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol1.xyz")
        self.poly_file2  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol2.xyz")
        self.poly_file3  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol3.xyz")
        self.poly_file4  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol4.xyz")
        self.poly_file5  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol5.xyz")
        self.poly_file6  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol6.xyz")
        self.poly_file7  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol7.xyz")
        self.poly_file8  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol8.xyz")
        self.poly_file9  = self.createTestPath("Statoil/ECLIPSE/Mariner/pol9.xyz")
        self.poly_file10 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol10.xyz")
        self.poly_file11 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol11.xyz")

        self.fault_blocks = []
        for k in range(self.grid.getNZ()):
            blocks = FaultBlockLayer( self.grid , k)
            blocks.scanKeyword( self.kw )
            self.fault_blocks.append( blocks )
Exemplo n.º 17
0
    def splitFaultBlocks(self , grid , fault_blocks ):
        boundingPolygon = Polyline(init_points = grid.getBoundingBox2D())
        boundingPolygon.assertClosed()
        if self.hasPolygon():
            if len(self.edges) == 1:
                return self.splitFaultBlockClosedPolygon( grid , fault_blocks , self.edges[0] )
            else:
                current_fault_block_layer = fault_blocks
                k = fault_blocks.getK()
                for edge in self.edges:
                    if isinstance(edge , Polyline):
                        # Start on a brand new fault block layer.
                        next_fault_block_layer = FaultBlockLayer( grid , k )
                        for block in current_fault_block_layer:
                            if block.containsPolyline(edge):
                                print "Block %d is split due to edge:%s" % (block.getBlockID() , edge.name())
                                sliced = GeometryTools.slicePolygon( boundingPolygon , edge )
                                inside_list = []
                                outside_list = []
                                for p in block:
                                    if GeometryTools.pointInPolygon( (p.x , p.y) , sliced ):
                                        inside_list.append( p )
                                    else:
                                        outside_list.append( p )

                                if len(inside_list) * len(outside_list) == 0:
                                    new_block = next_fault_block_layer.addBlock( )
                                    for p in inside_list:
                                        new_block.addCell(p.i , p.j)

                                    for p in outside_list:
                                        new_block.addCell(p.i , p.j)
                                else:
                                    layer = Layer( grid.getNX() , grid.getNY() )
                                    for p in inside_list:
                                        layer[p.i , p.j] = 1

                                    for p in outside_list:
                                        layer[p.i , p.j] = 2
                                            
                                    next_fault_block_layer.scanLayer( layer )
                            else:
                                next_fault_block_layer.insertBlockContent( block )

                        current_fault_block_layer = next_fault_block_layer
                return current_fault_block_layer
        else:
            return fault_blocks
Exemplo n.º 18
0
    def test_neighbours(self):

        with TestAreaContext("python/fault_block_layer/neighbour") as work_area:
            with open("kw.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 0 0\n")
                fileH.write("1 2 2 0 3\n")
                fileH.write("4 2 2 3 3\n")
                fileH.write("4 4 4 0 0\n")
                fileH.write("4 4 4 0 5\n")
                fileH.write("/\n")

            kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
        
        grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )

        layer.loadKeyword( kw )
        block1 = layer.getBlock( 1 )
        block2 = layer.getBlock( 2 )
        block3 = layer.getBlock( 3 )
        block4 = layer.getBlock( 4 )
        block5 = layer.getBlock( 5 )
        self.assertEqual( block1.getParentLayer() , layer )

        #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {}
                
        neighbours = block1.getNeighbours()
        self.assertEqual( len(neighbours) , 2)
        self.assertTrue( block2 in neighbours )
        self.assertTrue( block4 in neighbours )

        neighbours = block2.getNeighbours()
        self.assertEqual( len(neighbours) , 3)
        self.assertTrue( block1 in neighbours )
        self.assertTrue( block3 in neighbours )
        self.assertTrue( block4 in neighbours )
                
        neighbours = block3.getNeighbours()
        self.assertEqual( len(neighbours) , 1)
        self.assertTrue( block2 in neighbours )

        neighbours = block4.getNeighbours()
        self.assertEqual( len(neighbours) , 2)
        self.assertTrue( block1 in neighbours )
        self.assertTrue( block2 in neighbours )

        neighbours = block5.getNeighbours()
        self.assertEqual( len(neighbours) , 0)
Exemplo n.º 19
0
    def test_neighbours3(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1))
        layer = FaultBlockLayer(grid, 0)
        with TestAreaContext("python/FaultBlocks/neighbours"):
            with open("faultblock.grdecl", "w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("/\n")

            kw = EclKW.read_grdecl(open("faultblock.grdecl"),
                                   "FAULTBLK",
                                   ecl_type=EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl", "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   4   4   1   4   1   1  'X'  /\n")
                f.write("\'FX\'   5   5   5   8   1   1  'X'  /\n")
                f.write("/")

            faults = FaultCollection(grid, "faults.grdecl")
        layer.loadKeyword(kw)
        b1 = layer.getBlock(1)
        b2 = layer.getBlock(2)

        nb = b1.getNeighbours()
        self.assertTrue(b2 in nb)

        layer.addFaultBarrier(faults["FX"], link_segments=False)
        nb = b1.getNeighbours()
        self.assertTrue(b2 in nb)
Exemplo n.º 20
0
    def test_neighbours3(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        with TestAreaContext("python/FaultBlocks/neighbours"):
            with open("faultblock.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("1 1 1 1 1 2 2 2 \n")
                fileH.write("/\n")
                
            kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   4   4   1   4   1   1  'X'  /\n")
                f.write("\'FX\'   5   5   5   8   1   1  'X'  /\n")
                f.write("/")
            
            faults = FaultCollection( grid , "faults.grdecl")
        layer.loadKeyword( kw )
        b1 = layer.getBlock( 1 )
        b2 = layer.getBlock( 2 )

        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
        
        layer.addFaultBarrier( faults["FX"] , link_segments = False)
        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
Exemplo n.º 21
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.size  )
            
        layer = FaultBlockLayer( self.grid , 1 )
        self.assertEqual( 1 , layer.getK() )

        kw = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE )
        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()))
Exemplo n.º 22
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)))
Exemplo n.º 23
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()
Exemplo n.º 24
0
    def test_stepped(self):
        grid = EclGrid.create_rectangular( (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.create("FAULTBLK" , grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE)
        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)))
Exemplo n.º 25
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()
Exemplo n.º 26
0
    def test_neighbours2(self):
        nx = 8
        ny = 8
        nz = 1
        grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) )
        layer = FaultBlockLayer( grid , 0 )
        with TestAreaContext("python/FaultBlocks/neighbours"):
            with open("faultblock.grdecl","w") as fileH:
                fileH.write("FAULTBLK \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("1 1 1 1 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("3 3 3 3 2 2 2 2 \n")
                fileH.write("/\n")
                
            kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE)
            with open("faults.grdecl" , "w") as f:
                f.write("FAULTS\n")
                f.write("\'FY\'   1   4   4   4   1   1  'Y'  /\n")
                f.write("\'FX\'   4   4   1   8   1   1  'X'  /\n")
                f.write("/")
            
            faults = FaultCollection( grid , "faults.grdecl")
        layer.loadKeyword( kw )
        b1 = layer.getBlock( 1 )
        b2 = layer.getBlock( 2 )
        b3 = layer.getBlock( 3 )

        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
        self.assertTrue( b3 in nb )
        
        polylines1 = CPolylineCollection()
        p1 = polylines1.createPolyline(name="P1")
        p1.addPoint(4,0)
        p1.addPoint(4,4)
        p1.addPoint(4,8)
        nb = b1.getNeighbours( polylines = polylines1 )
        self.assertFalse( b2 in nb )
        self.assertTrue( b3 in nb )


        polylines2 = CPolylineCollection()
        p1 = polylines2.createPolyline(name="P2")
        p1.addPoint(0,4)
        p1.addPoint(4,4)
        nb = b1.getNeighbours( polylines = polylines2 )
        self.assertTrue( b2 in nb )
        self.assertFalse( b3 in nb )

        

        layer.addFaultBarrier( faults["FY"] )
        nb = b1.getNeighbours()
        self.assertTrue( b2 in nb )
        self.assertFalse( b3 in nb )
        
        layer.addFaultBarrier( faults["FX"] )
        nb = b1.getNeighbours()
        self.assertEqual( len(nb) , 0 )