transiflow.utils

compute_coordinate_vector_centers(vec)

Compute the centers of cells in the direction of the supplied coordinate vector.

Parameters:
vecarray_like

A coordinate vector

Returns:
xarray_like

A vector containing all of the cell centers.

compute_streamfunction(state, interface, axis=2)

Compute the stream function at the grid points in a plane.

Parameters:
statearray_like

The state vector to extract the velocities from.

interfaceInterface

Interface corresponding to the state vector.

axisint, optional

Axis along which we take the center point. Not necessary in case the problem is 2D.

Returns:
xarray_like

A 2D vector containing the stream function values.

compute_velocity_magnitude(state, interface, axis=2, position=None)

Compute the velocity magnitude at the grid points in a plane.

Parameters:
statearray_like

The state vector to extract the velocities from.

interfaceInterface

Interface corresponding to the state vector.

axisint, optional

Axis along which we take the center point, or a set position if provided. Not necessary in case the problem is 2D.

positionfloat, optional

Point along the provided axis at wich we take the plane.

Returns:
xarray_like

A 2D vector containing the velocity magnitudes.

compute_volume_averaged_kinetic_energy(state, interface)

Compute the volume averaged kinetic energy at the grid points.

Parameters:
statearray_like

The state vector to extract the velocities from.

interfaceInterface

Interface corresponding to the state vector.

Returns:
Escalar

The volume averaged kinetic energy.

compute_vorticity(state, interface, axis=2)

Compute the vorticity at the grid points in a plane.

Parameters:
statearray_like

The state vector to extract the velocities from.

interfaceInterface

Interface corresponding to the state vector.

axisint, optional

Axis along which we take the center point. Not necessary in case the problem is 2D.

Returns:
xarray_like

A 2D vector containing the vorticity values.

create_padded_state_mtx(state, nx=None, ny=None, nz=None, dof=None, x_periodic=True, y_periodic=True, z_periodic=True, interface=None)

Helper to create an (nx+2, ny+2, nz+2, dof) dimensional array out of a state vector that makes it easier to access the variables. The value from the other side of the domain is padded to each border in case the domain is periodic.

Parameters:
statearray_like

State vector that you want to convert.

nxint

Grid size in the x direction.

nyint

Grid size in the y direction.

nzint, optional

Grid size in the z direction.

dofint, optional

Degrees of freedom of the problem associated with the state vector.

x_periodicbool, optional

Use periodic borders in the x direction.

y_periodicbool, optional

Use periodic borders in the y direction.

z_periodicbool, optional

Use periodic borders in the z direction.

interfaceInterface, optional

Sets nx, ny, nz, dof, x_periodic, y_periodic, z_periodic to the right values if supplied.

Returns:
state_mtxarray_like

An (nx+2, ny+2, nz+2, dof) dimensional array.

create_state_mtx(state, nx=None, ny=None, nz=None, dof=None, interface=None)

Helper to create an (nx, ny, nz, dof) dimensional array out of a state vector that makes it easier to access the variables.

Parameters:
statearray_like

State vector that you want to convert.

nxint

Grid size in the x direction.

nyint

Grid size in the y direction.

nzint, optional

Grid size in the z direction.

dofint, optional

Degrees of freedom of the problem associated with the state vector.

interfaceInterface, optional

Sets nx, ny, nz, dof to the right values if supplied.

Returns:
state_mtxarray_like

An (nx, ny, nz, dof) dimensional array.

create_state_vec(state_mtx, nx=None, ny=None, nz=None, dof=None, interface=None)

Helper to create a state vector out of an array created with create_state_mtx().

Parameters:
statearray_like

State vector that you want to convert.

nxint

Grid size in the x direction.

nyint

Grid size in the y direction.

nzint, optional

Grid size in the z direction.

dofint, optional

Degrees of freedom of the problem associated with the state vector.

interfaceInterface, optional

Sets nx, ny, nz, dof to the right values if supplied.

Returns:
state_mtxarray_like

An nx * ny * nz * dof dimensional array.

create_stretched_coordinate_vector(start, end, nx, sigma)

Create coordinated vector that can be used in a Discretization with more cells near the boundaries. This uses a tanh for stretching.

Parameters:
startint

Start of the domain.

endint

End of the domain.

nxint

Amount of elements in this coordinate direction.

sigmafloat

Stretching factor.

Returns:
statearray_like

An array of size nx + 3. This includes padding for cells just outside of the domain.

create_stretched_coordinate_vector2(start, end, nx, sigma)

Create coordinated vector that can be used in a Discretization with more cells near the boundaries. This uses a sin for stretching.

Parameters:
startint

Start of the domain.

endint

End of the domain.

nxint

Amount of elements in this coordinate direction.

sigmafloat

Stretching factor.

Returns:
statearray_like

An array of size nx + 3. This includes padding for cells just outside of the domain.

create_uniform_coordinate_vector(start, end, nx)

Create a uniformly distributed vector that can be used as coordinate vector in a Discretization.

Parameters:
startint

Start of the domain.

endint

End of the domain.

nxint

Amount of elements in this coordinate direction.

Returns:
statearray_like

An array of size nx + 3. This includes padding for cells just outside of the domain.

dot(x, y)

Dot product between the vectors x and y that can be used for any backend

get_u_value(state, i, j, k, interface)

Get the value of u at a grid point.

Parameters:
statearray_like

The state vector to extract the velocities from.

iint

Index in the x direction.

jint

Index in the y direction.

kint

Index in the z direction.

interfaceInterface

Interface corresponding to the state vector.

Returns:
uscalar

Value at the grid point.

get_v_value(state, i, j, k, interface)

Get the value of v at a grid point.

Parameters:
statearray_like

The state vector to extract the velocities from.

iint

Index in the x direction.

jint

Index in the y direction.

kint

Index in the z direction.

interfaceInterface

Interface corresponding to the state vector.

Returns:
vscalar

Value at the grid point.

get_w_value(state, i, j, k, interface)

Get the value of w at a grid point.

Parameters:
statearray_like

The state vector to extract the velocities from.

iint

Index in the x direction.

jint

Index in the y direction.

kint

Index in the z direction.

interfaceInterface

Interface corresponding to the state vector.

Returns:
wscalar

Value at the grid point.

norm(x)

2-norm of the vector x that can be used for any backend

\[\]