to_mask¶
- AdvectionDiffusion.to_mask(pores=None, throats=None)¶
Convert a list of pore or throat indices into a boolean mask of the correct length.
- Parameters
pores (array_like) – List of pore indices. Only one of these can be specified at a time, and the returned result will be of the corresponding length.
throats (array_like) – List of throat indices. Only one of these can be specified at a time, and the returned result will be of the corresponding length.
- Returns
A boolean mask of length Np or Nt with
True
in the specified pore or throat locations.- Return type
ndarray
See also
Examples
>>> import openpnm as op >>> pn = op.network.Cubic(shape=[5, 5, 5]) >>> mask = pn.to_mask(pores=[0, 10, 20]) >>> sum(mask) # 3 non-zero elements exist in the mask (0, 10 and 20) 3 >>> len(mask) # Mask size is equal to the number of pores in network 125 >>> mask = pn.to_mask(throats=[0, 10, 20]) >>> len(mask) # Mask is now equal to number of throats in network 300