Example #1
0
 def _left(self, obs):
     s = self._xmask[obs.ix[0] - 1, obs.sz]
     tmp = _np.argwhere(s == 0).ravel()
     if len(tmp) > 0:
         lst = _utils.split_discontinuous(tmp + obs.iz[0])
         for idz in lst:
             self._extrude_left(obs, idz)
Example #2
0
 def _bottom(self, obs):
     s = self._zmask[obs.sx, obs.iz[0] - 1]
     tmp = _np.argwhere(s == 0).ravel()
     if len(tmp) > 0:
         lst = _utils.split_discontinuous(tmp + obs.ix[0])
         for idx in lst:
             self._extrude_bottom(obs, idx)
Example #3
0
    def _periodic_bounds(bot, top):

        bot_rigid = list(set(top).difference(set(bot)))
        top_rigid = list(set(bot).difference(set(top)))

        if any(bot_rigid):
            bot_rigid = _utils.split_discontinuous(bot_rigid)
        else:
            bot_rigid = []

        if any(top_rigid):
            top_rigid = _utils.split_discontinuous(top_rigid)
        else:
            top_rigid = []

        return bot_rigid, top_rigid
Example #4
0
    def _split_indexes(self, index, axis):

        if axis == 0:
            r = getattr(self, 'rz')
            c = getattr(self, 'iz')
        elif axis == 1:
            r = getattr(self, 'rx')
            c = getattr(self, 'ix')
        else:
            raise ValueError('axis must be 0 or 1')

        if isinstance(index, int):

            if c[1] == index:
                return [(c[0], c[1]), (c[1], c[1])]

            if c[0] <= index < c[1]:
                return [(c[0], index), (index + 1, c[1])]

            raise ValueError('index must be in the subdomain')

        elif isinstance(index, (tuple, list)):

            if len(index) == 2:
                index = tuple(sorted(list(index)))
                index_set = set(range(index[0], index[1] + 1))
                domain_set = set(r)

                if index_set.issubset(domain_set):
                    remaining = list(domain_set.difference(index_set))
                    lst = _utils.split_discontinuous(remaining)
                    lst.append(index)
                    lst.sort()
                    return lst

                raise ValueError('indexes must be in the domain')

            else:
                raise ValueError('index must be of length 2')
        else:
            raise ValueError('index must be int, list, or tuple')