Ejemplo n.º 1
0
    def test_add_polyline(self):
        pc = CPolylineCollection()
        pl = pc.createPolyline( name = "TestP" )
        self.assertTrue( isinstance(pl , CPolyline))
        self.assertEqual(len(pc) , 1)
        self.assertTrue( "TestP" in pc )
        
        with self.assertRaises(IndexError):
            pl = pc[2]

        p0 = pc[0]
        self.assertTrue( p0 == pl )
            
        with self.assertRaises(KeyError):
            pn = pc["missing"]
            
        pn = pc["TestP"]
        self.assertTrue( pn == pl )

        px = CPolyline( name = "TestP")
        with self.assertRaises(KeyError):
            pc.addPolyline( px )
        self.assertEqual(len(pc) , 1)
            

        p2 = CPolyline( name = "Poly2")
        pc.addPolyline( p2 )
        
        self.assertEqual( len(pc) , 2 )
        self.assertTrue( "Poly2" in pc )

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


        points = [(0,1) , (1,1)]
        pc.addPolyline( points , name = "XYZ")
        self.assertTrue( "XYZ" in pc )
Ejemplo n.º 2
0
    def test_add_polyline(self):
        pc = CPolylineCollection()
        pl = pc.createPolyline( name = "TestP" )
        self.assertTrue( isinstance(pl , CPolyline))
        self.assertEqual(len(pc) , 1)
        self.assertTrue( "TestP" in pc )
        
        with self.assertRaises(IndexError):
            pl = pc[2]

        p0 = pc[0]
        self.assertTrue( p0 == pl )
            
        with self.assertRaises(KeyError):
            pn = pc["missing"]
            
        pn = pc["TestP"]
        self.assertTrue( pn == pl )

        px = CPolyline( name = "TestP")
        with self.assertRaises(KeyError):
            pc.addPolyline( px )
        self.assertEqual(len(pc) , 1)
            

        p2 = CPolyline( name = "Poly2")
        pc.addPolyline( p2 )
        
        self.assertEqual( len(pc) , 2 )
        self.assertTrue( "Poly2" in pc )

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


        points = [(0,1) , (1,1)]
        pc.addPolyline( points , name = "XYZ")
        self.assertTrue( "XYZ" in pc )
Ejemplo n.º 3
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")

            with cwrap.open("faultblock.grdecl") as f:
                kw = EclKW.read_grdecl(f,
                                       "FAULTBLK",
                                       ecl_type=EclDataType.ECL_INT)

            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)
Ejemplo n.º 4
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")

            with cwrap.open("faultblock.grdecl") as f:
                kw = EclKW.read_grdecl(
                    f, "FAULTBLK", ecl_type=EclDataType.ECL_INT)

            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 )