当前位置: 首页>>代码示例>>Python>>正文


Python EclGrid.createRectangular方法代码示例

本文整理汇总了Python中ecl.grid.EclGrid.createRectangular方法的典型用法代码示例。如果您正苦于以下问题:Python EclGrid.createRectangular方法的具体用法?Python EclGrid.createRectangular怎么用?Python EclGrid.createRectangular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ecl.grid.EclGrid的用法示例。


在下文中一共展示了EclGrid.createRectangular方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_contact2

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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 ))
开发者ID:OPM,项目名称:ResInsight,代码行数:29,代码来源:test_layer.py

示例2: test_region_filter

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_region_filter(self):
        nx = 10
        ny = 10
        nz = 1
        actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 )
        actnum[nx*ny - 1] = 0

        grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum)
        self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 )

        kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True )
        kw.assign( 0 )
        kw[0:int(nx*ny/2)] = 1
        kw[5,2,0] = 0
        kw[0,9,0] = 2

        kw.fixUninitialized( grid )

        # Not assigned because they are in contact with a '2'; these
        # two are problem cells.
        self.assertEqual( kw[0,ny - 2,0] , 0)
        self.assertEqual( kw[1,ny - 1,0] , 0)

        # Not assigned because it is inactive
        self.assertEqual( kw[nx - 1,ny - 1,0] , 0)

        self.assertEqual( kw[5,2,0] , 1 )
        for j in range(5,10):
            self.assertEqual( kw[5,j,0] , 1 )

        for i in range(10):
            self.assertEqual( kw[i,7,0] , 1 )
开发者ID:OPM,项目名称:ResInsight,代码行数:34,代码来源:test_kw_function.py

示例3: test_setitem

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_setitem( self ):
        actnum = IntVector(default_value = 1 , initial_size = 1000)
        for i in range(100):
            actnum[i] = 0

        grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum)
        kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77)
        
        with self.assertRaises(IndexError):
            kw[1000]

        with self.assertRaises(IndexError):
            kw[0,10,100]

        with self.assertRaises(ValueError):
            kw[1,1]

        with self.assertRaises(ValueError):
            kw[1,1,1,1]

        kw.assign(99)
        self.assertEqual( kw[0,0,0] , 77 )
        self.assertEqual( kw[0,0,1] , 99 )

        
        with self.assertRaises(ValueError):
            kw[0,0,0] = 88
            
        kw[0,0,1] = 100 
        self.assertEqual( kw[0,0,1] , 100 )
开发者ID:OPM,项目名称:ResInsight,代码行数:32,代码来源:test_ecl_3dkw.py

示例4: make_grid

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
def make_grid( ):
    grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) )
    if not os.path.isdir("grid"):
        os.makedirs("grid")
    grid.save_EGRID("grid/CASE.EGRID")

    return grid
开发者ID:berland,项目名称:ert,代码行数:9,代码来源:make_data.py

示例5: test_connectWithPolyline

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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))
开发者ID:OPM,项目名称:ResInsight,代码行数:35,代码来源:test_faults.py

示例6: test_extend_to_polyline

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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 )
开发者ID:OPM,项目名称:ResInsight,代码行数:28,代码来源:test_faults.py

示例7: test_extend_polyline_on

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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 )
开发者ID:OPM,项目名称:ResInsight,代码行数:32,代码来源:test_faults.py

示例8: test_contact

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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) )        
开发者ID:OPM,项目名称:ResInsight,代码行数:33,代码来源:test_faults.py

示例9: test_fault_line_order

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_fault_line_order(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\'    /
/
""")
            faults = FaultCollection( grid , "faults.grdecl" )

        fault = faults["F"]
        layer = fault[29]
        self.assertEqual(len(layer) , 2)

        line1 = layer[0]
        line2 = layer[1]
        self.assertEqual(len(line1) , 4)
        self.assertEqual(len(line2) , 2)

        seg0 = line1[0]
        seg1 = line1[1]
        seg2 = line1[2]
        seg3 = line1[3]
        self.assertEqual( seg0.getCorners() , (50 * (nx + 1) + 104 , 50 * (nx + 1) + 107))
        self.assertEqual( seg1.getCorners() , (50 * (nx + 1) + 107 , 50 * (nx + 1) + 108))
        self.assertEqual( seg2.getCorners() , (50 * (nx + 1) + 108 , 49 * (nx + 1) + 108))
        self.assertEqual( seg3.getCorners() , (49 * (nx + 1) + 108 , 49 * (nx + 1) + 109))
开发者ID:OPM,项目名称:ResInsight,代码行数:37,代码来源:test_faults.py

示例10: test_join_faults

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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)] )
开发者ID:OPM,项目名称:ResInsight,代码行数:32,代码来源:test_faults.py

示例11: test_rect

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_rect(self):
        with TestAreaContext("python/grid-test/testRect"):
            a1 = 1.0
            a2 = 2.0
            a3 = 3.0
            grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3))
            grid.save_EGRID("rect.EGRID")
            grid2 = EclGrid("rect.EGRID")
            self.assertTrue(grid)
            self.assertTrue(grid2)

            (x, y, z) = grid.get_xyz(ijk=(4, 4, 4))
            self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3])

            v = grid.cell_volume(ijk=(4, 4, 4))
            self.assertFloatEqual(v, a1 * a2 * a3)

            z = grid.depth(ijk=(4, 4, 4 ))
            self.assertFloatEqual(z, 4.5 * a3)

            g1 = grid.global_index(ijk=(2, 2, 2))
            g2 = grid.global_index(ijk=(4, 4, 4))
            (dx, dy, dz) = grid.distance(g2, g1)
            self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3])

            self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2)))
开发者ID:,项目名称:,代码行数:28,代码来源:

示例12: test_grdecl_load

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_grdecl_load(self):
        with self.assertRaises(IOError):
            grid = EclGrid.loadFromGrdecl("/file/does/not/exists")

        with TestAreaContext("python/grid-test/grdeclLoad"):
            with open("grid.grdecl","w") as f:
                f.write("Hei ...")

            with self.assertRaises(ValueError):
                grid = EclGrid.loadFromGrdecl("grid.grdecl")

            actnum = IntVector(default_value = 1 , initial_size = 1000)
            actnum[0] = 0
            g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum )
            self.assertEqual( g1.getNumActive() , actnum.elementSum() )
            g1.save_EGRID("G.EGRID")

            with open("grid.grdecl" , "w") as f2:
                f2.write("SPECGRID\n")
                f2.write("  10  10  10  \'F\' /\n")

            with openEclFile("G.EGRID") as f:
                with copen("grid.grdecl" , "a") as f2:

                    coord_kw = f["COORD"][0]
                    coord_kw.write_grdecl( f2 )

                    zcorn_kw = f["ZCORN"][0]
                    zcorn_kw.write_grdecl( f2 )

                    actnum_kw = f["ACTNUM"][0]
                    actnum_kw.write_grdecl( f2 )

            g2 = EclGrid.loadFromGrdecl("grid.grdecl")
            self.assertTrue( g1.equal( g2 ))
开发者ID:,项目名称:,代码行数:37,代码来源:

示例13: test_boundingBox

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_boundingBox(self):
        grid = EclGrid.createRectangular((10,10,10) , (1,1,1))
        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D(layer = -1 )

        with self.assertRaises(ValueError):
            bbox = grid.getBoundingBox2D( layer = 11 )

        bbox = grid.getBoundingBox2D( layer = 10 )
        self.assertEqual( bbox , ((0,0) , (10, 0) , (10 , 10) , (0,10)))


        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (-1,0) )

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (6,10) )

        bbox = grid.getBoundingBox2D( lower_left = (3,3) )
        self.assertEqual( bbox , ((3,3) , (10,3) , (10,10) , (3,10)))

        with self.assertRaises(ValueError):
            grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (2,2))

        bbox = grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (7,7))
        self.assertEqual( bbox , ((3,3) , (7,3) , (7,7) , (3,7)))
开发者ID:,项目名称:,代码行数:28,代码来源:

示例14: test_get_ijk

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    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")
            with cwrap.open("kw.grdecl") as f:
                kw = EclKW.read_grdecl(
                    f, "FAULTBLK", ecl_type=EclDataType.ECL_INT)

        grid = EclGrid.createRectangular( (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]
开发者ID:OPM,项目名称:ResInsight,代码行数:31,代码来源:test_fault_blocks.py

示例15: test_truth_and_size

# 需要导入模块: from ecl.grid import EclGrid [as 别名]
# 或者: from ecl.grid.EclGrid import createRectangular [as 别名]
    def test_truth_and_size(self):
        actnum = IntVector( initial_size = 100, default_value = 0)
        actnum[0:50] = 1
        grid = EclGrid.createRectangular( (10,10,1) , (1,1,1), actnum = actnum)
        region = EclRegion(grid, False)

        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))

        region.select_all( )
        self.assertTrue( region )
        self.assertEqual( 50, region.active_size( ))
        self.assertEqual( 100, region.global_size( ))
        
        region.deselect_all()
        self.assertFalse( region )
        self.assertEqual( 0, region.active_size( ))
        self.assertEqual( 0, region.global_size( ))
        
        region = EclRegion(grid, False)
        region.select_inactive()
        self.assertTrue( region )
        self.assertEqual( 0 , region.active_size( ))
        self.assertEqual( 50, region.global_size( ))
开发者ID:OPM,项目名称:ResInsight,代码行数:27,代码来源:test_region.py


注:本文中的ecl.grid.EclGrid.createRectangular方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。