discretisedfield.tools.neighbouring_cell_angle#
- discretisedfield.tools.neighbouring_cell_angle(field, /, direction, units='rad')#
Calculate angles between neighbouring cells.
This method calculates the angle between value vectors in all neighbouring cells. The calculation is only possible for vector fields of three dimensions (i.e.
nvdim=3
). Angles are computed in degrees ifunits='deg'
and in radians ifunits='rad'
.The resulting field has one discretisation cell less in the specified direction.
- Parameters:
field (discretisedfield.Field) – Vector field.
direction (str) – The spatial direction in which the angles are calculated.
units (str, optional) – Angles are computed in degrees if
units='deg'
and in radians ifunits='rad'
. Defaults to'rad'
.
- Returns:
A scalar field with angles. In the given direction the number of cells is reduced by one compared to the given field.
- Return type:
- Raises:
ValueError – If
field
is not a vector field, ordirection
orunits
is invalid.
Examples
Computing the angle between neighbouring cells in z-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=(0, 1, 0)) ... >>> dft.neighbouring_cell_angle(field, direction='z') Field(...)