find_neighbor_throats#
- Cubic.find_neighbor_throats(pores, mode='or', flatten=True, asmask=False)#
Returns a list of throats neighboring the given pore(s)
- Parameters:
pores (array_like) – Indices of pores whose neighbors are sought
flatten (bool, optional) – If
True
(default) a 1D array of unique throat indices is returned. IfFalse
the returned array contains arrays of neighboring throat indices for each input pore, in the order they were sent.mode (str) –
Specifies logic to filter the resulting list. Options are:
mode
meaning
’or’
(default) All neighbors of the input throats. Also accepts ‘any’ and ‘union’.
’xor’
Only neighbors of one and only one input throats. This is useful for counting the pores that are not shared by any of the input pores. Also accepts ‘exclusive_or’.
’xnor’
Neighbors that are shared by two or more input throats. This is equivalent to counting all neighbors with ‘or’, minus those found with ‘xor’, and is useful for finding neighbors that the inputs have in common.
’and’
Only neighbors shared by all input throats. Also accepts ‘intersection’ and ‘all’
asmask (boolean) – If
False
(default), the returned result is a list of the neighboring throats as indices. IfTrue
, the returned result is a boolean mask. (Useful for labelling)
- Returns:
If
flatten
isTrue
, returns a 1D array of throat indicesfiltered according to the specified mode. If
flatten
isFalse
, returns a list of lists, where each list contains theneighbors of the corresponding input pores.
Notes
The
logic
options are applied to neighboring bonds only, thus it is not possible to obtain bonds that are part of the global set but not neighbors. This is because (a) the list of global bonds might be very large, and (b) it is not possible to return a list of neighbors for each input site if global sites are considered.Examples
>>> import openpnm as op >>> pn = op.network.Cubic(shape=[5, 5, 5]) >>> Ts = pn.find_neighbor_throats(pores=[0, 1]) >>> print(Ts) [ 0 1 100 101 200 201] >>> Ts = pn.find_neighbor_throats(pores=[0, 1], flatten=False) >>> print(Ts[0]) [ 0 100 200] >>> print(Ts[1]) [ 0 1 101 201]