示例#1
0
    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", 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)
示例#2
0
    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())
示例#3
0
 def setUp(self):
     self.test_base = [
         (list(GridGen.create_coord((4, 4, 4), (1, 1, 1))),
          list(GridGen.create_zcorn((4, 4, 4), (1, 1, 1), offset=0)),
          GridGen.create_grid((4, 4, 4), (1, 1, 1), offset=0)),
         (list(
             GridGen.create_coord((5, 5, 5), (1, 1, 1),
                                  translation=(10, 10, 0))),
          list(
              GridGen.create_zcorn((5, 5, 5), (1, 1, 1),
                                   offset=0.5,
                                   irregular_offset=True,
                                   concave=True,
                                   irregular=True)),
          GridGen.create_grid((5, 5, 5), (1, 1, 1),
                              offset=0.5,
                              irregular=True,
                              irregular_offset=True,
                              concave=True,
                              translation=(10, 10, 0)))
     ]
示例#4
0
    def test_extract_grid_invalid_bounds(self):
        dims = (3, 3, 3)
        zcorn = list(GridGen.create_zcorn(dims, (1, 1, 1), offset=0))
        coord = list(GridGen.create_coord(dims, (1, 1, 1)))

        with self.assertRaises(ValueError):
            GridGen.extract_subgrid_data(dims, coord, zcorn,
                                         ((-1, 0), (2, 2), (2, 2)))

        with self.assertRaises(ValueError):
            GridGen.extract_subgrid_data(dims, coord, zcorn,
                                         ((1, 6), (2, 2), (2, 2)))

        with self.assertRaises(ValueError):
            GridGen.extract_subgrid_data(dims, coord, zcorn,
                                         ((1, 2), (2, 0), (2, 2)))
示例#5
0
    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)
示例#6
0
    def test_extract_grid_decomposition_change(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_bounds in ijk_bounds:
            if decomposition_preserving(ijk_bounds):
                GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds)
            else:
                with self.assertRaises(ValueError):
                    GridGen.extract_subgrid_data(dims, coord, zcorn,
                                                 ijk_bounds)

            GridGen.extract_subgrid_data(dims,
                                         coord,
                                         zcorn,
                                         ijk_bounds,
                                         decomposition_change=True)
示例#7
0
    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)