def test_clone_pores_mode_isolated(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left'), mode='isolated') assert net.Np == 150 assert net.Nt == 300
def test_clone_pores_with_labels(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left'), labels=['test1', 'test2']) assert net.num_pores('test1') == 25 assert net.num_pores('test2') == 25
def add_boundary_pores( self, labels=["top", "bottom", "front", "back", "left", "right"], spacing=None): r""" Add pores to the faces of the network for use as boundary pores. Pores are offset from the faces by 1/2 a lattice spacing such that they lie directly on the boundaries. Parameters ---------- labels : string or list of strings The labels indicating the pores defining each face where boundary pores are to be added (e.g. 'left' or ['left', 'right']) spacing : scalar or array_like The spacing of the network (e.g. [1, 1, 1]). This should be given since it can be quite difficult to infer from the network, for instance if boundary pores have already added to other faces. """ if isinstance(labels, str): labels = [labels] x, y, z = self["pore.coords"].T if spacing is None: spacing = self._get_spacing() else: spacing = np.array(spacing) if spacing.size == 1: spacing = np.ones(3) * spacing Lcx, Lcy, Lcz = spacing offset = {} shape = self.settings['shape'] offset["front"] = offset["left"] = offset["bottom"] = [0, 0, 0] offset["right"] = [Lcx * shape[0], 0, 0] offset["back"] = [0, Lcy * shape[1], 0] offset["top"] = [0, 0, Lcz * shape[2]] scale = {} scale["left"] = scale["right"] = [0, 1, 1] scale["front"] = scale["back"] = [1, 0, 1] scale["bottom"] = scale["top"] = [1, 1, 0] for label in labels: try: Ps = self.pores(label) topotools.clone_pores(network=self, pores=Ps, labels=label + "_boundary", mode='parents') # Translate cloned pores ind = self.pores(label + "_boundary") coords = self["pore.coords"][ind] coords = coords * scale[label] + offset[label] self["pore.coords"][ind] = coords except KeyError: logger.warning("No pores labelled " + label + " were found, skipping boundary addition")
def test_clone_pores_mode_sibings(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left'), mode='siblings') assert net.Np == 150 assert net.Nt == 340
def add_boundary_pores(self, labels=['top', 'bottom', 'front', 'back', 'left', 'right'], spacing=None): r""" Add pores to the faces of the network for use as boundary pores. Pores are offset from the faces by 1/2 a lattice spacing such that they lie directly on the boundaries. Parameters ---------- labels : string or list of strings The labels indicating the pores defining each face where boundary pores are to be added (e.g. 'left' or ['left', 'right']) spacing : scalar or array_like The spacing of the network (e.g. [1, 1, 1]). This should be given since it can be quite difficult to infer from the network, for instance if boundary pores have already added to other faces. """ if type(labels) == str: labels = [labels] x, y, z = self['pore.coords'].T if spacing is None: spacing = self._get_spacing() else: spacing = sp.array(spacing) if spacing.size == 1: spacing = sp.ones(3)*spacing Lcx, Lcy, Lcz = spacing offset = {} offset['front'] = offset['left'] = offset['bottom'] = [0, 0, 0] offset['back'] = [Lcx*self._shape[0], 0, 0] offset['right'] = [0, Lcy*self._shape[1], 0] offset['top'] = [0, 0, Lcz*self._shape[2]] scale = {} scale['front'] = scale['back'] = [0, 1, 1] scale['left'] = scale['right'] = [1, 0, 1] scale['bottom'] = scale['top'] = [1, 1, 0] for label in labels: try: Ps = self.pores(label) topotools.clone_pores(network=self, pores=Ps, labels=label+'_boundary') # Translate cloned pores ind = self.pores(label+'_boundary') coords = self['pore.coords'][ind] coords = coords*scale[label] + offset[label] self['pore.coords'][ind] = coords except KeyError: logger.warning('No pores labelled ' + label + ' were found, ' + 'skipping boundary addition')
def test_clone_pores_mode_parents(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left')) assert net.Np == 150 assert net.Nt == 325
def test_clone_pores_mode_isolated(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left'), mode='isolated') assert net.Np == 150 assert net.Nt == 300
def test_clone_pores_mode_sibings(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left'), mode='siblings') assert net.Np == 150 assert net.Nt == 340
def test_clone_pores_mode_parents(self): net = op.network.Cubic(shape=[5, 5, 5]) topotools.clone_pores(network=net, pores=net.pores('left')) assert net.Np == 150 assert net.Nt == 325