コード例 #1
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_count_equal(self):
        layer = Layer(10, 10)
        self.assertEqual(100, layer.countEqual(0))
        self.assertEqual(0, layer.countEqual(1))

        layer[3, 3] = 3
        self.assertEqual(1, layer.countEqual(3))
コード例 #2
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_matching(self):
        d = 10
        layer = Layer(d, d)

        for i in range(d):
            layer[i, i] = 10

        cell_list = layer.cellsEqual(1)
        self.assertEqual(cell_list, [])

        cell_list = layer.cellsEqual(10)
        self.assertEqual(cell_list, [(i, i) for i in range(d)])
コード例 #3
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    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))
コード例 #4
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_add_cell(self):
        layer = Layer(10, 10)
        with self.assertRaises(ValueError):
            layer[100, 100] = 199

        with self.assertRaises(ValueError):
            layer[100, "X"] = 199

        with self.assertRaises(ValueError):
            layer[100] = 199

        layer[5, 5] = 88
        self.assertEqual(layer[5, 5], 88)
コード例 #5
0
    def test_layer(self):
        region = EclRegion(self.grid, False)
        layer = Layer(self.grid.getNX(), self.grid.getNY() + 1)
        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, 0, 1)

        layer = Layer(self.grid.getNX(), self.grid.getNY())
        layer[0, 0] = 1
        layer[1, 1] = 1
        layer[2, 2] = 1

        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, -1, 1)

        with self.assertRaises(ValueError):
            region.selectFromLayer(layer, self.grid.getNZ(), 1)

        region.selectFromLayer(layer, 0, 2)
        glist = region.getGlobalList()
        self.assertEqual(0, len(glist))

        region.selectFromLayer(layer, 0, 1)
        glist = region.getGlobalList()
        self.assertEqual(3, len(glist))
コード例 #6
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
 def test_add_polyline_barrier(self):
     d = 10
     layer = Layer(d, d)
     grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1))
     pl = CPolyline(init_points=[(0, 0), (d / 2, d / 2), (d, d)])
     layer.addPolylineBarrier(pl, grid, 0)
     for i in range(d):
         self.assertTrue(layer.bottomBarrier(i, i))
         if i < (d - 1):
             self.assertTrue(layer.leftBarrier(i + 1, i))
コード例 #7
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_contact(self):
        nx = 20
        ny = 10
        layer = Layer(nx, ny)
        grid = EclGrid.createRectangular((nx, ny, 1), (1, 1, 1))

        with self.assertRaises(IndexError):
            layer.cellContact((-1, 0), (1, 1))

        with self.assertRaises(IndexError):
            layer.cellContact((20, 0), (1, 1))

        self.assertFalse(layer.cellContact((0, 0), (2, 0)))
        self.assertFalse(layer.cellContact((1, 0), (1, 0)))

        self.assertTrue(layer.cellContact((0, 0), (1, 0)))
        self.assertTrue(layer.cellContact((1, 0), (0, 0)))

        self.assertTrue(layer.cellContact((0, 0), (0, 1)))
        self.assertTrue(layer.cellContact((0, 1), (0, 0)))

        self.assertFalse(layer.cellContact((0, 0), (1, 1)))
        self.assertFalse(layer.cellContact((1, 1), (0, 0)))

        self.assertTrue(layer.cellContact((4, 0), (5, 0)))
        self.assertTrue(layer.cellContact((0, 4), (0, 5)))

        with TestAreaContext("Layer/barrier"):
            with open("faults.grdecl", "w") as f:
                f.write("FAULTS\n")
                f.write("\'FX\'   5   5   1   10   1   1  'X'  /\n")
                f.write("\'FY\'   1   10   5   5   1   1  'Y'  /\n")
                f.write("/")

            faults = FaultCollection(grid, "faults.grdecl")

        layer.addFaultBarrier(faults["FX"], 0)
        self.assertFalse(layer.cellContact((4, 0), (5, 0)))

        layer.addFaultBarrier(faults["FY"], 0)
        self.assertFalse(layer.cellContact((0, 4), (0, 5)))

        self.assertFalse(layer.cellContact((9, 4), (9, 5)))
        self.assertTrue(layer.cellContact((10, 4), (10, 5)))
コード例 #8
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
 def test_create_layer(self):
     layer = Layer(10, 10)
     self.assertTrue(isinstance(layer, Layer))
コード例 #9
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_assign(self):
        layer = Layer(10, 5)
        self.assertEqual(layer.cellSum(), 0)

        layer.assign(10)
        self.assertEqual(layer.cellSum(), 500)
コード例 #10
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_active(self):
        d = 10
        layer = Layer(d, d)
        with self.assertRaises(ValueError):
            layer.activeCell(d + 1, d + 2)

        self.assertTrue(layer.activeCell(1, 2))

        grid = EclGrid.createRectangular((d, d + 1, 1), (1, 1, 1))
        with self.assertRaises(ValueError):
            layer.updateActive(grid, 0)

        grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1))
        with self.assertRaises(ValueError):
            layer.updateActive(grid, 10)

        actnum = IntVector(initial_size=d * d * 1, default_value=1)
        actnum[0] = 0
        grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum)
        layer.updateActive(grid, 0)
        self.assertTrue(layer.activeCell(1, 2))
        self.assertFalse(layer.activeCell(0, 0))
コード例 #11
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    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())
コード例 #12
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    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))
コード例 #13
0
ファイル: test_layer.py プロジェクト: mahg/ResInsight
    def test_fault_barrier(self):
        nx = 120
        ny = 60
        nz = 43
        grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1))
        with TestAreaContext("python/faults/line_order"):
            with open("faults.grdecl", "w") as f:
                f.write("""FAULTS
\'F\'              105  107     50   50      1   43    \'Y\'    / 
\'F\'              108  108     50   50      1   43    \'X\'    /
\'F\'              108  108     50   50     22   43    \'Y\'    /
\'F\'              109  109     49   49      1   43    \'Y\'    /
\'F\'              110  110     49   49      1   43    \'X\'    /
\'F\'              111  111     48   48      1   43    \'Y\'    /
/
""")
            with open("faults.grdecl") as f:
                faults = FaultCollection(grid, "faults.grdecl")

        # Fault layout:
        #
        # +---+---+---+---+
        #                 |
        #                 +---+   +
        #                         |
        #                         +---+

        fault = faults["F"]
        layer = Layer(nx, ny)
        fault_pairs = [((104, 49), (104, 50)), ((105, 49), (105, 50)),
                       ((106, 49), (106, 50)), ((107, 49), (108, 49)),
                       ((107, 49), (107, 50)), ((108, 48), (108, 49)),
                       ((109, 48), (110, 48)), ((110, 47), (110, 48))]
        gap_pair = ((109, 48), (109, 49))

        for p1, p2 in fault_pairs:
            self.assertTrue(layer.cellContact(p1, p2))

        p1, p2 = gap_pair
        self.assertTrue(layer.cellContact(p1, p2))

        layer.addFaultBarrier(fault, 30, link_segments=False)
        for p1, p2 in fault_pairs:
            self.assertFalse(layer.cellContact(p1, p2))
        p1, p2 = gap_pair
        self.assertTrue(layer.cellContact(p1, p2))

        layer.addFaultBarrier(fault, 30)
        p1, p2 = gap_pair
        self.assertFalse(layer.cellContact(p1, p2))