当前位置: 首页>>代码示例>>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;未经允许,请勿转载。