discretisedfield.tools.count_large_cell_angle_regions#
- discretisedfield.tools.count_large_cell_angle_regions(field, /, min_angle, direction=None, units='rad')#
Count regions with large angles between neighbouring cells.
This method counts regions, where the angle between neighbouring cells is above the given threshold. If
direction
is not specified the maximum of all neighbouring cells is used, otherwise only neighbouring cells in the given direction are taken into account. The minimum angle can be specified both in radians and degrees, depending onunits
.- Parameters:
field (discretisedfield.Field) – Vector field.
min_angle (numbers.Real) – Minimum angle to count. Can be either radians or degrees depending on
units
.direction (str, optional) – Direction of neighbouring cells. Can be
None
or one of the geometric dimensions. IfNone
, all directions are taken into account. Defaults toNone
.units (str, optional) – Unit of
min_angle
. Can berad
for radians ordeg
for degrees. Defaults torad
.
- Returns:
Number of regions.
- Return type:
int
Examples
Counting regions depending on all directions.
>>> import discretisedfield as df >>> import discretisedfield.tools as dft ... >>> p1 = (0, 0, 0) >>> p2 = (100, 100, 100) >>> n = (10, 10, 10) >>> mesh = df.Mesh(p1=p1, p2=p2, n=n) >>> field = df.Field(mesh, nvdim=3, value=lambda p: (0, 0, 1) if p[0] < 50 else (0, 0, -1)) ... >>> dft.count_large_cell_angle_regions(field, min_angle=90, units='deg') 1
Counting regions depending on a single direction.
>>> import discretisedfield as df >>> import discretisedfield.tools as dft ... >>> p1 = (0, 0, 0) >>> p2 = (100, 100, 100) >>> n = (10, 10, 10) >>> mesh = df.Mesh(p1=p1, p2=p2, n=n) >>> field = df.Field(mesh, nvdim=3, value=lambda p: (0, 0, 1) if p[0] < 50 else (0, 0, -1)) ... >>> dft.count_large_cell_angle_regions(field, min_angle=90, units='deg', direction='x') 1 >>> dft.count_large_cell_angle_regions(field, min_angle=90, units='deg', direction='y') 0