當前位置: 首頁>>代碼示例>>Python>>正文


Python grid.EclGridGenerator類代碼示例

本文整理匯總了Python中ecl.grid.EclGridGenerator的典型用法代碼示例。如果您正苦於以下問題:Python EclGridGenerator類的具體用法?Python EclGridGenerator怎麽用?Python EclGridGenerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EclGridGenerator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_actnum_extraction

    def test_actnum_extraction(self):
        dims = (4,4,4)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        actnum = EclKW("ACTNUM", six.functools.reduce(operator.mul, dims),
                       EclDataType.ECL_INT)
        random.seed(1337)
        for i in range(len(actnum)):
            actnum[i] = random.randint(0, 1)

        grid = EclGrid.create(dims, zcorn, coord, actnum)

        ijk_bounds = generate_ijk_bounds(dims)
        for ijk_bound in ijk_bounds:
            if not decomposition_preserving(ijk_bound):
                continue

            sub = GridGen.extract_subgrid_data(
                                         dims,
                                         coord,
                                         zcorn,
                                         ijk_bound,
                                         actnum=actnum
                                       )

            sub_coord, sub_zcorn, sub_actnum = sub
            sub_dims = tuple([u-l+1 for l, u in ijk_bound])
            subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum)
            self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
            self.assertSubgrid(grid, subgrid, ijk_bound)
開發者ID:OPM,項目名稱:ResInsight,代碼行數:32,代碼來源:test_grid_generator.py

示例2: test_translation

    def test_translation(self):
        dims = (3,3,3)

        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
        grid = EclGrid.create(dims, zcorn, coord, None)

        ijk_bound = [(0, d-1) for d in dims]
        translation = (1, 2, 3)
        sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data(
                                                        dims,
                                                        coord,
                                                        zcorn,
                                                        ijk_bound,
                                                        translation=translation
                                                       )

        tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None)
        self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize())

        for gi in range(grid.getGlobalSize()):
            translation = numpy.array(translation)
            corners = [grid.getCellCorner(i, gi) for i in range(8)]
            corners = [tuple(numpy.array(c)+translation) for c in corners]

            tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)]

            self.assertEqual(corners, tcorners)
開發者ID:OPM,項目名稱:ResInsight,代碼行數:28,代碼來源:test_grid_generator.py

示例3: test_export

    def test_export(self):
        dims = (3, 3, 3)
        coord = GridGen.create_coord(dims, (1,1,1))
        zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)

        grid = EclGrid.create(dims, zcorn, coord, None)

        self.assertEqual(zcorn, grid.export_zcorn())
        self.assertEqual(coord, grid.export_coord())
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例4: test_subgrid_translation

    def test_subgrid_translation(self):
        grid = GridGen.create_grid((4,4,4), (1,1,1), offset=0.5,
                    irregular=True, irregular_offset=True, concave=True,
                    translation=(10,10,0))

        # Create grid with MAPAXES
        mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT)
        for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]):
            mapaxes[i] = val

        grid = EclGrid.create(
                grid.getDims(),
                grid.export_zcorn(),
                grid.export_coord(),
                None,
                mapaxes=mapaxes
                )

        for translation in [
                (0,0,0),
                (10, 10, 100),
                (-1, -1, -1)
                ]:
            subgrid = GridGen.extract_subgrid(
                                        grid,
                                        ((0,3), (0,3), (0,3)),
                                        translation=translation
                                        )

            self.assertEqual(grid.getDims(), subgrid.getDims())

            translation = numpy.array(translation)
            for gindex in range(grid.getGlobalSize()):
                grid_corners = [
                                grid.getCellCorner(i, global_index=gindex)
                                for i in range(8)
                              ]

                subgrid_corners = [
                                subgrid.getCellCorner(i, global_index=gindex)
                                for i in range(8)
                                ]

                subgrid_corners = [
                                list(numpy.array(corner) - translation)
                                for corner in subgrid_corners
                                ]

                for gc, sc in zip(grid_corners, subgrid_corners):
                    self.assertAlmostEqualList(
                            gc,
                            sc,
                            msg="Failed to translate corners correctly." +
                                "Expected %s, was %s." % (gc, sc),
                            tolerance=10e-10
                            )
開發者ID:OPM,項目名稱:ResInsight,代碼行數:56,代碼來源:test_grid_generator.py

示例5: test_create

    def test_create(self):
        with self.assertRaises(ValueError):
            grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = [0,1,1,2])

        with self.assertRaises(ValueError):
            grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = IntVector(initial_size = 10))
        grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) # actnum=None -> all active
        self.assertEqual( grid.getNumActive( ) , 30*20*10)
        actnum = IntVector(default_value = 1 , initial_size = 6000)
        actnum[0] = 0
        actnum[1] = 0
        grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = actnum)
        self.assertEqual( grid.getNumActive( ) , 30*20*10 - 2)
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例6: createContainmentTestBase

def createContainmentTestBase():
    return [
            (3,  GridGen.create_grid((6,6,6), (1,1,1), offset=1)),
            (10, GridGen.create_grid((3,3,3), (1,1,1), offset=1, concave=True)),
            (4,  GridGen.create_grid((10,10,1), (1,1,1), offset=0., misalign=True)),
            (3,
                GridGen.create_grid((6,6,6), (1,1,1), offset=0.,
                    escape_origo_shift=(100, 100, 0),
                    irregular_offset=True, concave=True, irregular=True,
                    scale=1.5, translation=(5,5,0),
                    misalign=True
                    )
                )
            ]
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例7: test_output_units

    def test_output_units(self):
        n = 10
        a = 1
        grid = GridGen.createRectangular( (n,n,n), (a,a,a))

        with TestAreaContext("python/ecl_grid/units"):
            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_FIELD_UNITS )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "FEET" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 3.28084*3.28084*3.28084)


            grid.save_EGRID( "CASE.EGRID" )
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip( ) , "METRES" )

            grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_LAB_UNITS)
            f = EclFile("CASE.EGRID")
            g = f["GRIDUNIT"][0]
            self.assertEqual( g[0].strip() , "CM" )
            g2 = EclGrid("CASE.EGRID")
            self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 100*100*100 )
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例8: test_extract_grid_slice_spec

    def test_extract_grid_slice_spec(self):
        dims = (4,4,4)
        zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0))
        coord = list(GridGen.create_coord(dims, (1,1,1)))

        ijk_bounds = generate_ijk_bounds(dims)
        for ijk in ijk_bounds:
            ijk = list(ijk)
            for i in range(3):
                if len(set(ijk[i])) == 1:
                    ijk[i] = ijk[i][0]

            GridGen.extract_subgrid_data(dims,
                                 coord, zcorn,
                                 ijk,
                                 decomposition_change=True)
開發者ID:OPM,項目名稱:ResInsight,代碼行數:16,代碼來源:test_grid_generator.py

示例9: EclKW

 def test_numpy3D(self):
     nx = 10
     ny = 7
     nz = 5
     grid = GridGen.createRectangular((nx,ny,nz) , (1,1,1))
     kw = EclKW( "SWAT" , nx*ny*nz , EclDataType.ECL_FLOAT )
     numpy_3d = grid.create3D( kw )
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例10: test_oom_grid

    def test_oom_grid(self):
        nx = 2000
        ny = 2000
        nz = 2000

        with self.assertRaises(MemoryError):
            grid = GridGen.createRectangular( (nx,ny,nz), (1,1,1))
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例11: test_dims

    def test_dims(self):
        grid = GridGen.createRectangular( (10,20,30) , (1,1,1) )
        self.assertEqual( grid.getNX() , 10 )
        self.assertEqual( grid.getNY() , 20 )
        self.assertEqual( grid.getNZ() , 30 )
        self.assertEqual( grid.getGlobalSize() , 30*10*20 )

        self.assertEqual( grid.getDims() , (10,20,30,6000) )
開發者ID:,項目名稱:,代碼行數:8,代碼來源:

示例12: test_compressed_copy

 def test_compressed_copy(self):
     nx = 10
     ny = 10
     nz = 10
     grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) )
     kw1 = EclKW("KW" , 1001 , EclDataType.ECL_INT )
     with self.assertRaises(ValueError):
         cp = grid.compressedKWCopy( kw1 )
開發者ID:,項目名稱:,代碼行數:8,代碼來源:

示例13: test_concvex_cell_containment

    def test_concvex_cell_containment(self):
        points = [
            (10, 10, 10),
            (25, 5, 5),
            (5, 25, 5),
            (20, 20, 10),
            (5, 5, 25),
            (20, 10, 20),
            (10, 20, 20),
            (25, 25, 25)
            ]

        grid = GridGen.create_single_cell_grid(points)

        assertPoint = lambda p : self.assertTrue(
                grid.cell_contains(p[0], p[1], p[2], 0)
                )

        assertNotPoint = lambda p : self.assertFalse(
                grid.cell_contains(p[0], p[1], p[2], 0)
                )

        # Cell center
        assertPoint(average(points));

        # "Side" center
        assertPoint(average(points[0:4:]))
        assertPoint(average(points[4:8:]))
        assertPoint(average(points[1:8:2]))
        assertPoint(average(points[0:8:2]))
        assertPoint(average(points[0:8:4] + points[1:8:4]))
        assertPoint(average(points[2:8:4] + points[3:8:4]))

        # Corners
        for p in points:
            assertPoint(p)

        # Edges
        edges = ([(i, i+1) for i in range(0, 8, 2)] +
                 [(i, i+2) for i in [0, 1, 4, 5]] +
                 [(i, i+4) for i in range(4)] +
                 [(1,2), (2,7), (1,7), (4,7), (2,4), (4,1)])
        for a,b in edges:
            assertPoint(average([points[a], points[b]]))

        # Epsilon inside from corners
        middle_point = average(points)
        for p in points:
            assertPoint(average(20*[p] + [middle_point]))

        # Espilon outside
        middle_point[2] = 0
        for p in points[0:4:]:
            assertNotPoint(average(20*[p] + [middle_point]))

        middle_point[2] = 30
        for p in points[4:8:]:
            assertNotPoint(average(20*[p] + [middle_point]))
開發者ID:,項目名稱:,代碼行數:58,代碼來源:

示例14: test_cell_corner_containment_compatability

    def test_cell_corner_containment_compatability(self):
        grid = GridGen.createRectangular( (3,3,3), (1,1,1) )

        for x, y, z in itertools.product(range(4), repeat=3):
            for i in range(27):
                if grid.cell_contains(x, y, z, i):
                    self.assertEqual(
                            CORNER_HOME[(x,y,z)],
                            i
                            )
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例15: test_dxdydz

    def test_dxdydz(self):
        nx = 10
        ny = 10
        nz = 10
        grid = GridGen.createRectangular( (nx,ny,nz) , (2,3,4) )

        (dx,dy,dz) = grid.getCellDims( active_index = 0 )
        self.assertEqual( dx , 2 )
        self.assertEqual( dy , 3 )
        self.assertEqual( dz , 4 )
開發者ID:,項目名稱:,代碼行數:10,代碼來源:


注:本文中的ecl.grid.EclGridGenerator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。