utilities.utils#

Functions#

animate_field(fields, domain, mapping[, ...])

Animate a sequence of scalar fields over a geometry.

is_real(x)

Determine whether the given input represents a real number.

refine_array_1d(x, n[, remove_duplicates])

Refines a 1D array by subdividing each interval (x[i], x[i+1]) into n identical parts.

roll_edges(domain, points)

If necessary, "roll" back intervals that cross boundary of periodic domain.

split_field(uh, spaces[, out])

Split a field into a list of fields that corresponds to the spaces.

split_space(Xh)

Split the flattened fem spaces into

unroll_edges(domain, xgrid)

If necessary, "unroll" intervals that cross boundary of periodic domain.

Details#

refine_array_1d(x, n, remove_duplicates=True)[source]#

Refines a 1D array by subdividing each interval (x[i], x[i+1]) into n identical parts.

Parameters:
xndarray

1D array to be refined.

nint

Number of subdivisions to be created in each interval (x[i], x[i+1]).

remove_duplicatesbool, default=True

If True, the refined array will not contain any duplicate points. If False, the original internal grid points x[1:-1] will appear twice: this may be useful to visualize fields that are discontinuous across cell boundaries.

Returns:
ndarray

Refined 1D array. The length of this array is n * (len(x) - 1) + 1 if remove_duplicates and (n + 1) * (len(x) - 1) if not.

unroll_edges(domain, xgrid)[source]#

If necessary, “unroll” intervals that cross boundary of periodic domain.

split_space(Xh)[source]#
Split the flattened fem spaces into

a list of spaces that corresponds to the symbolic function spaces.

Parameters:
XhProductFemSpace

The discrete space.

Returns:
Vh<list, FemSpace>

List of fem spaces.

split_field(uh, spaces, out=None)[source]#
Split a field into a list of fields that corresponds to the spaces.

The split field function will allocate new memory if out is not passed.

Parameters:
uhFemField

The fem field.

spaces: <list, FemSpace>

List of spaces that split the field.

out: optional, <list, FemField>

List of fields to write the results to.

Returns:
out<list, FemField>

List of fem fields.

animate_field(fields, domain, mapping, res=(150, 150), vrange=None, cmap=None, interval=35, progress=False, figsize=(14, 4))[source]#

Animate a sequence of scalar fields over a geometry.