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=EclDataType.ECL_INT) 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)
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=EclDataType.ECL_INT) 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)
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)))
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=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)