def test_basic(self): lo = np.array([1, 2]) hi = np.array([3, 4]) ans = np.array([1, 2, 2, 3]) assert np.array_equal(mcolon(lo, hi), ans)
def test_stride(self): lo = np.array([1, 2]) hi = np.array([6, 14]) s = np.array([2, 3]) ans = np.array([1,3,5, 2,5,8,11]) assert np.array_equal(mcolon(lo, hi, s), ans)
def boundaryFaceIndices(G, side, I0, I1, I2): """ Retrieve face indices belonging to a subset of global outer faces. Synopsis: ix = boundaryFaceIndices(G, side, I0, I1, I2) Arguments: G (Grid): pyrst.gridprocessing.Grid side (str): Global side from which to extract face indices. String. Must (case insensitively) match one of six alias groups: 0) ["west", "xmin", "left" ] 1) ["east", "xmax", "right" ] 2) ["south", "ymin", "back" ] 3) ["north", "ymax", "front" ] 4) ["upper", "zmin", "top" ] 5) ["lower", "zmax", "bottom"] These groups correspond to the cardinal directions mentiond as the first alternative in each group. I0, I1 (list or ndarray): Index ranges for local (in-plane) axes one and two, respectively. No index range given (I1 or I2 is None) is interpreted as covering the entire corresponding local axis of `side` in the grid `G`. The local axes on a side in G are ordered `X` before `Y` before `Z`. I2 (list or ndarray): Index range for global axis perpendicular to `side`. The primary purpose of this parameter is to exclude faces *within* a reservoir from being added to the return value `ix`. Such faces typically occur in faulted reservoirs where a given face may be considered external by virtue of being connected to a single reservoir cell only. Returns: ix - Required face indices as a column array. Note: This function is mainly intended for internal use in this file. Its calling interface may change more frequently than functions in the BoundaryCondition class. See also: prst.params.wells_and_bc.BoundaryCondition """ try: I0 = I0.ravel() except AttributeError: pass try: I1 = I1.ravel() except AttributeError: pass try: I2 = I2.ravel() except AttributeError: pass ## Extract all faces of cells within the given subset. cells, faceTag, isOutF = _boundaryCellsSubset(G, side, I0, I1, I2) fIX = G.cells.facePos hfIX = mcolon(fIX[cells], fIX[cells + 1]) faces = G.cells.faces[hfIX, 0] tags = G.cells.faces[hfIX, 1] ix = faces[np.logical_and(isOutF[faces], tags == faceTag)] # return as column array return ix[:, np.newaxis]