def _trim_external_pores(self, shape):
        r'''
        '''
        # Find all pores within the domain
        Ps = topotools.isoutside(coords=self['pore.coords'], shape=shape)
        self['pore.external'] = False
        self['pore.external'][Ps] = True

        # Find which internal pores are delaunay
        Ps = (~self['pore.external'])*self['pore.delaunay']

        # Find all pores connected to an internal delaunay pore
        Ps = self.find_neighbor_pores(pores=Ps, include_input=True)

        # Mark them all as keepers
        self['pore.keep'] = False
        self['pore.keep'][Ps] = True

        # Trim all bad pores
        topotools.trim(network=self, pores=~self['pore.keep'])

        # Now label boundary pores
        self['pore.boundary'] = False
        self['pore.boundary'] = self['pore.delaunay']*self['pore.external']

        # Label Voronoi pores on boundary
        Ps = self.find_neighbor_pores(pores=self.pores('boundary'))
        Ps = self['pore.voronoi']*self.tomask(pores=Ps)
        self['pore.boundary'][Ps] = True

        # Label Voronoi and interconnect throats on boundary
        self['throat.boundary'] = False
        Ps = self.pores('boundary')
        Ts = self.find_neighbor_throats(pores=Ps, mode='xnor')
        self['throat.boundary'][Ts] = True

        # Trim throats between Delaunay boundary pores
        Ps = self.pores(labels=['boundary', 'delaunay'], mode='xnor')
        Ts = self.find_neighbor_throats(pores=Ps, mode='xnor')
        topotools.trim(network=self, throats=Ts)

        # Move Delaunay boundary pores to centroid of Voronoi facet
        Ps = self.pores(labels=['boundary', 'delaunay'], mode='xnor')
        for P in Ps:
            Ns = self.find_neighbor_pores(pores=P)
            Ns = Ps = self['pore.voronoi']*self.tomask(pores=Ns)
            coords = sp.mean(self['pore.coords'][Ns], axis=0)
            self['pore.coords'][P] = coords

        self['pore.internal'] = ~self['pore.boundary']
        Ps = self.pores('internal')
        Ts = self.find_neighbor_throats(pores=Ps, mode='xnor')
        self['throat.internal'] = False
        self['throat.internal'][Ts] = True

        # Label surface pores and throats between boundary and internal
        Ts = self.throats(['boundary', 'internal'], mode='not')
        self['throat.surface'] = False
        self['throat.surface'][Ts] = True
        surf_pores = self['throat.conns'][Ts].flatten()
        surf_pores = sp.unique(surf_pores[~self['pore.boundary'][surf_pores]])
        self['pore.surface'] = False
        self['pore.surface'][surf_pores] = True
        # Clean-up
        del self['pore.external']
        del self['pore.keep']
def _trim_external_pores ( self , shape ) : Ps = topotools . isoutside ( coords = self [ 'pore.coords' ] , shape = shape ) self [ 'pore.external' ] = False self [ 'pore.external' ] [ Ps ] = True Ps = ( ~ self [ 'pore.external' ] ) * self [ 'pore.delaunay' ] Ps = self . find_neighbor_pores ( pores = Ps , include_input = True ) self [ 'pore.keep' ] = False self [ 'pore.keep' ] [ Ps ] = True topotools . trim ( network = self , pores = ~ self [ 'pore.keep' ] ) self [ 'pore.boundary' ] = False self [ 'pore.boundary' ] = self [ 'pore.delaunay' ] * self [ 'pore.external' ] Ps = self . find_neighbor_pores ( pores = self . pores ( 'boundary' ) ) Ps = self [ 'pore.voronoi' ] * self . tomask ( pores = Ps ) self [ 'pore.boundary' ] [ Ps ] = True self [ 'throat.boundary' ] = False Ps = self . pores ( 'boundary' ) Ts = self . find_neighbor_throats ( pores = Ps , mode = 'xnor' ) self [ 'throat.boundary' ] [ Ts ] = True Ps = self . pores ( labels = [ 'boundary' , 'delaunay' ] , mode = 'xnor' ) Ts = self . find_neighbor_throats ( pores = Ps , mode = 'xnor' ) topotools . trim ( network = self , throats = Ts ) Ps = self . pores ( labels = [ 'boundary' , 'delaunay' ] , mode = 'xnor' ) for P in Ps : Ns = self . find_neighbor_pores ( pores = P ) Ns = Ps = self [ 'pore.voronoi' ] * self . tomask ( pores = Ns ) coords = sp . mean ( self [ 'pore.coords' ] [ Ns ] , axis = 0 ) self [ 'pore.coords' ] [ P ] = coords self [ 'pore.internal' ] = ~ self [ 'pore.boundary' ] Ps = self . pores ( 'internal' ) Ts = self . find_neighbor_throats ( pores = Ps , mode = 'xnor' ) self [ 'throat.internal' ] = False self [ 'throat.internal' ] [ Ts ] = True Ts = self . throats ( [ 'boundary' , 'internal' ] , mode = 'not' ) self [ 'throat.surface' ] = False self [ 'throat.surface' ] [ Ts ] = True surf_pores = self [ 'throat.conns' ] [ Ts ] . flatten ( ) surf_pores = sp . unique ( surf_pores [ ~ self [ 'pore.boundary' ] [ surf_pores ] ] ) self [ 'pore.surface' ] = False self [ 'pore.surface' ] [ surf_pores ] = True del self [ 'pore.external' ] del self [ 'pore.keep' ]
r'''