コード例 #1
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_extend_polyline_on(self):
        grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1))

        #  o   o   o   o
        #
        #  o---o---o---o
        #
        #  o===o===o===o
        #
        #  o   o   o   o

        fault1 = Fault(grid, "Fault")
        fault1.addRecord(0, 2, 0, 0, 0, 0, "Y")

        polyline0 = CPolyline(init_points=[(0, 2)])
        polyline1 = CPolyline(init_points=[(0, 2), (3, 2)])
        polyline2 = CPolyline(init_points=[(1, 3), (1, 2)])
        polyline3 = CPolyline(init_points=[(1, 3), (1, 0)])

        with self.assertRaises(ValueError):
            fault1.extendPolylineOnto(polyline0, 0)

        points = fault1.extendPolylineOnto(polyline1, 0)
        self.assertIsNone(points)

        points = fault1.extendPolylineOnto(polyline2, 0)
        self.assertEqual(points, [(1, 2), (1, 1)])

        points = fault1.extendPolylineOnto(polyline3, 0)
        self.assertIsNone(points)
コード例 #2
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_extend_to_polyline(self):
        grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1))

        #  o   o   o   o
        #
        #  o---o---o---o
        #
        #  o===+   o   o
        #  |
        #  o   o   o   o

        fault1 = Fault(grid, "Fault")

        fault1.addRecord(0, 0, 0, 0, 0, 0, "X-")
        fault1.addRecord(0, 0, 0, 0, 0, 0, "Y")

        polyline = CPolyline(init_points=[(0, 2), (3, 2)])
        points = fault1.extendToPolyline(polyline, 0)
        self.assertEqual(points, [(1, 1), (2, 2)])

        end_join = fault1.endJoin(polyline, 0)
        self.assertEqual(end_join, [(1, 1), (0, 2)])

        polyline2 = CPolyline(init_points=[(0.8, 2), (0.8, 0.8)])
        end_join = fault1.endJoin(polyline2, 0)
        self.assertIsNone(end_join)
コード例 #3
0
 def joinFaults(self , fault1 , fault2):
     if not fault1.intersectsFault( fault2 , self.getK()):
         layer = self.getGeoLayer()
         try:
             layer.addIJBarrier( Fault.joinFaults( fault1 , fault2 , self.getK()) )
         except ValueError:
             print('Failed to join faults %s and %s' % (fault1.getName() , fault2.getName()))
             raise ValueError("")
コード例 #4
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_PolylineIJ(self):
        nx = 10
        ny = 10
        nz = 10
        grid = EclGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1))
        f = Fault(grid, "F")
        f.addRecord(0, 1, 0, 0, 0, 0, "Y-")
        f.addRecord(2, 2, 0, 1, 0, 0, "X-")
        f.addRecord(2, 2, 1, 1, 0, 0, "Y")

        pl = f.getIJPolyline(0)
        self.assertEqual(pl, [(0, 0), (2, 0), (2, 2), (3, 2)])
コード例 #5
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    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)))
コード例 #6
0
    def test_splitLine2(self):
        grid = self.loadGrid()
        f = Fault(grid, "DF41_C")

        #                         179   180   181
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                             |
        #  78                         |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                             |
        #  77                         |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                             |
        #  76                         |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                             |
        #  75                         |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #
        #  74
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #
        #  73
        #           o     o     o     o-----o     o     o     o     o     o     o     o     o     o
        #                                   |
        #  72                               |
        #           o     o     o     o-----o     o     o     o     o     o     o     o     o     o
        #
        #  71
        #           o     o     o     o-----o     o     o     o     o     o     o     o     o     o
        #                                   |
        #  70                               |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                                   |
        #  69                               |
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #
        #  68
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #
        #  67
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #
        #  66
        #           o     o     o     o     o     o     o     o     o     o     o     o     o     o
        #                                   |
        #  65                               |
        #           o     o     o     o-----o     o     o     o     o     o     o     o     o     o

        f.addRecord(179, 179, 77, 78, 0, 42, 'X')
        f.addRecord(179, 179, 75, 76, 0, 41, 'X')
        f.addRecord(180, 180, 72, 72, 0, 41, 'X')
        f.addRecord(180, 180, 72, 72, 0, 41, 'Y')
        f.addRecord(180, 180, 72, 72, 0, 41, 'Y-')

        f.addRecord(180, 180, 70, 70, 0, 42, 'Y')
        f.addRecord(180, 180, 69, 70, 0, 42, 'X')
        f.addRecord(180, 180, 65, 65, 0, 42, 'X')
        f.addRecord(180, 180, 65, 65, 0, 42, 'Y-')

        ij_polyline = f.getIJPolyline(19)
        ij_list = [(180, 79), (180, 77), (180, 75), (180, 73), (181, 73),
                   (181, 72), (180, 72), (180, 71), (181, 71), (181, 69),
                   (181, 66), (181, 65), (180, 65)]

        self.assertEqual(ij_polyline, ij_list)
コード例 #7
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_empty_fault(self):
        f = Fault(self.grid, "NAME")
        self.assertEqual("NAME", f.getName())

        with self.assertRaises(Exception):
            g = f["Key"]
コード例 #8
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_connectWithPolyline(self):
        grid = EclGrid.createRectangular((4, 4, 1), (1, 1, 1))

        #  o   o   o   o   o
        #
        #  o   o   o   o   o
        #
        #  o---o---o---o---o
        #
        #  o   o   o   o   o
        #          |
        #  o   o   o   o   o

        fault1 = Fault(grid, "Fault1")
        fault1.addRecord(0, 3, 1, 1, 0, 0, "Y")

        fault2 = Fault(grid, "Fault2")
        fault2.addRecord(1, 1, 0, 0, 0, 0, "X")

        fault3 = Fault(grid, "Fault3")
        fault3.addRecord(1, 1, 0, 2, 0, 0, "X")

        self.assertIsNone(fault3.connect(fault1, 0))

        intersect = fault2.connect(fault1, 0)
        self.assertEqual(len(intersect), 2)
        p1 = intersect[0]
        p2 = intersect[1]

        self.assertEqual(p1, (2, 1))
        self.assertEqual(p2, (2, 2))
コード例 #9
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_polyline_intersection(self):
        grid = EclGrid.createRectangular((100, 100, 10), (0.25, 0.25, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #                              (5 , 2.50)
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 10, 15, 15, 0, 0, "Y")
        fault3.addRecord(5, 10, 5, 5, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        polyline = Polyline(init_points=[(4, 4), (8, 4)])
        self.assertTrue(fault4.intersectsPolyline(polyline, 0))

        cpolyline = CPolyline(init_points=[(4, 4), (8, 4)])
        self.assertTrue(fault4.intersectsPolyline(cpolyline, 0))

        polyline = Polyline(init_points=[(8, 4), (16, 4)])
        self.assertFalse(fault4.intersectsPolyline(polyline, 0))

        cpolyline = CPolyline(init_points=[(8, 4), (16, 4)])
        self.assertFalse(fault4.intersectsPolyline(cpolyline, 0))
コード例 #10
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_fault(self):
        f = Fault(self.grid, "NAME")

        with self.assertRaises(ValueError):
            # Invalid face
            f.addRecord(10, 10, 11, 11, 1, 43, "F")

        with self.assertRaises(ValueError):
            # Invalid coordinates
            f.addRecord(-1, 10, 11, 11, 1, 43, "X")

        with self.assertRaises(ValueError):
            # Invalid coordinates
            f.addRecord(10000, 10, 11, 11, 1, 43, "X")

        with self.assertRaises(ValueError):
            # Invalid coordinates
            f.addRecord(10, 9, 11, 11, 1, 43, "X")

        with self.assertRaises(ValueError):
            # Invalid coordinates
            f.addRecord(10, 9, 11, 11, 1, 43, "X")

        with self.assertRaises(ValueError):
            # Invalid coordinates/face combination
            f.addRecord(10, 11, 11, 11, 1, 43, "X")

        with self.assertRaises(ValueError):
            # Invalid coordinates/face combination
            f.addRecord(10, 11, 11, 12, 1, 43, "Y")

        f.addRecord(10, 10, 0, 10, 1, 10, "X")
コード例 #11
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_contact(self):
        grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   ----------------------+--  Fault2
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 30, 15, 15, 0, 0, "Y")
        fault3.addRecord(2, 10, 9, 9, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        #self.assertFalse( fault1.intersectsFault(fault2 , 0) )
        #self.assertFalse( fault2.intersectsFault(fault1 , 0) )

        #self.assertTrue( fault2.intersectsFault(fault4 , 0) )
        #self.assertTrue( fault4.intersectsFault(fault2 , 0) )

        self.assertTrue(fault1.intersectsFault(fault1, 0))
コード例 #12
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_join_faults(self):
        grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 10, 15, 15, 0, 0, "Y")
        fault3.addRecord(5, 10, 5, 5, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        rays = fault1.getEndRays(0)
        self.assertEqual(rays[0], [(2, 10), (0, -1)])
        self.assertEqual(rays[1], [(2, 100), (0, 1)])

        extra = Fault.joinFaults(fault1, fault3, 0)
        self.assertEqual(extra, [(2, 10), (2, 6), (5, 6)])
コード例 #13
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_intersect_intRays(self):
        p1 = (0, 0)
        dir1 = (1, 0)
        p2 = (0, 0)
        dir2 = (0, 1)

        line = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(line, [])

        # Opposite direction
        p3 = (-1, 0)
        dir3 = (-1, 0)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p3, dir3))

        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p3, dir3), (p1, dir1))

        # Parallell with offset
        p4 = (0, 1)
        dir4 = (1, 0)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p4, dir4))

        p5 = (0, 1)
        dir5 = (-1, 0)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p5, dir5))

        p6 = (1, 1)
        dir6 = (1, 0)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p6, dir6))

        p2 = (-1, 0)
        dir2 = (-1, 0)
        join = Fault.intersectFaultRays((p2, dir1), (p1, dir2))
        self.assertEqual(join, [p2, p1])

        join = Fault.intersectFaultRays((p1, dir3), (p3, dir1))
        self.assertEqual(join, [p1, p3])

        p2 = (1, 0)
        dir2 = (1, 0)
        join = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(join, [p1, p2])

        # Orthogonal
        p2 = (1, 1)
        dir2 = (0, 1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (0, 1)
        dir2 = (0, 1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (-1, 0)
        dir2 = (0, 1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (-1, 1)
        dir2 = (0, 1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (-1, 1)
        dir2 = (0, -1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (3, -1)
        dir2 = (0, -1)
        with self.assertRaises(ValueError):
            Fault.intersectFaultRays((p1, dir1), (p2, dir2))

        p2 = (1, -1)
        dir2 = (0, 1)
        join = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(join, [p1, (1, 0), p2])

        p2 = (1, 1)
        dir2 = (0, -1)
        join = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(join, [p1, (1, 0), p2])

        p2 = (0, 3)
        dir2 = (0, -1)
        join = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(join, [p1, p2])

        p2 = (3, 0)
        dir2 = (0, -1)
        join = Fault.intersectFaultRays((p1, dir1), (p2, dir2))
        self.assertEqual(join, [p1, p2])
コード例 #14
0
ファイル: test_faults.py プロジェクト: mahg/ResInsight
    def test_connect_faults(self):
        grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1))

        #    Fault1                    Fault4
        #      |                         |
        #      |                         |
        #      |                         |
        #      |   -------  Fault2       |
        #      |                         |
        #      |                         |
        #
        #          -------- Fault3
        #

        fault1 = Fault(grid, "Fault1")
        fault2 = Fault(grid, "Fault2")
        fault3 = Fault(grid, "Fault3")
        fault4 = Fault(grid, "Fault4")

        fault1.addRecord(1, 1, 10, grid.getNY() - 1, 0, 0, "X")
        fault2.addRecord(5, 10, 15, 15, 0, 0, "Y")
        fault3.addRecord(5, 10, 5, 5, 0, 0, "Y")
        fault4.addRecord(20, 20, 10, grid.getNY() - 1, 0, 0, "X")

        for other_fault in [fault2, fault3, fault4]:
            with self.assertRaises(ValueError):
                fault1.extendToFault(other_fault, 0)

        with self.assertRaises(ValueError):
            fault2.extendToFault(fault3, 0)

        for other_fault in [fault1, fault2, fault4]:
            with self.assertRaises(ValueError):
                fault3.extendToFault(other_fault, 0)

        for other_fault in [fault1, fault2, fault3]:
            with self.assertRaises(ValueError):
                fault4.extendToFault(other_fault, 0)

        ext21 = fault2.extendToFault(fault1, 0)
        self.assertEqual(len(ext21), 2)
        p0 = ext21[0]
        p1 = ext21[1]
        self.assertEqual(p0, (5, 16))
        self.assertEqual(p1, (2, 16))

        ext24 = fault2.extendToFault(fault4, 0)
        self.assertEqual(len(ext24), 2)
        p0 = ext24[0]
        p1 = ext24[1]
        self.assertEqual(p0, (11, 16))
        self.assertEqual(p1, (21, 16))