Unstructured blocks

Flow data on an unstructured triangulated surface.

An UnstructuredBlock holds flow data at a set of vertices together with the triangular faces that join them. It is what ember.cut.unstructured() returns, and it is accepted by the integrals and averages in ember.average alongside a structured 2D cut.

Each vertex is stored once, however many faces share it. Every flow property of a Block is available, evaluated per vertex, with shape (n_vert,); face quantities have shape (n_face, ...).

Construction mirrors Block: the constructor sizes the vertex data, and setters fill it in, connectivity included:

u = UnstructuredBlock(n_vert)
u.set_faces(faces)  # int, shape (n_face, 3)
u.set_xrt(xrt)  # shape (n_vert, 3)
u.set_fluid(fluid)
u.set_P_T(P, T)
u.set_Vxrt(Vxrt)

UnstructuredBlock(n_vert)

Allocate flow data at the vertices of an unstructured surface.

class unstructured.UnstructuredBlock(n_vert)[source]

Allocate flow data at the vertices of an unstructured surface.

The vertex data hold every variable a Block does, and are set and read through the same methods and properties. The triangles joining the vertices are set with set_faces().

Each face is a triple of vertex indices \((A, B, C)\). Its area vector, dA, follows the right-hand rule around \(A \to B \to C\) in the pseudo-Cartesian space \((x, r, r\theta)\), the same sense as the face areas of a structured cut.

The vertices form a one-dimensional array, so the inherited ndim is 1 whatever the dimension of the surface. Operations that reorder or regroup the vertices (indexing, flip(), reshape() and the like) raise, because they would leave the faces pointing at the wrong vertices.

A volume mesh would extend this class rather than replace it: each face would also store the cells either side of it, and the cells, their volumes and their vertex lists would be derived from those.

Parameters:

n_vert (int) – Number of vertices.

set_faces(faces)[source]

Set the triangles joining the vertices.

The array is copied and stored read-only; set new faces to change them.

Parameters:

faces (array_like of int, shape (n_face, 3)) – Indices of the three vertices of each face, each in [0, n_vert). Their order sets the direction of the face’s area vector by the right-hand rule.

empty()[source]

Create an uninitialised block on the same mesh.

Returns a fresh UnstructuredBlock with the same vertices, faces and metadata and all data set to NaN, as numpy.empty_like() keeps the type and shape of its argument. A block of another shape is made with the Block constructor and setters.

Returns:

out – A new uninitialised block sharing this one’s faces and metadata.

Return type:

UnstructuredBlock

flip(axis)[source]

Raise: flipping would reorder the vertices.

mean(axis=0, keepdims=False)[source]

Raise: use the face-weighted averages in ember.average.

nanmean(axis=0)[source]

Raise: use the face-weighted averages in ember.average.

reshape(shape)[source]

Raise: reshaping would regroup the vertices.

squeeze()[source]

Raise: squeezing would regroup the vertices.

transpose(axes=None)[source]

Raise: transposing would reorder the vertices.

property dA

Face area vectors \(\delta\!A\) [m^2], shape (n_face, 3).

See dA_nd for the nondimensional form and the geometry reference.

property dA_nd

Face area vectors \(\delta\!A / L_\mathrm{ref}^2\) [-], shape (n_face, 3).

Pseudo-Cartesian components \((x, r, r\theta)\) on the trailing axis, directed by the right-hand rule around each face’s vertices.

See Face areas for the calculation.

property faces

Vertex indices of each face, read-only int32, shape (n_face, 3).

property n_face

Number of faces.

property n_vert

Number of vertices.

property Alpha

Absolute yaw angle \(\alpha\) [deg], nodal array.

Yaw is the angle between the absolute velocity and its projection onto the meridional (x-r) plane, i.e. the out-of-plane swirl angle.

\[\tan\alpha = \frac{V_\theta}{V_m}\]
property Alpha_rel

Relative-frame yaw angle \(\alpha^\mathrm{rel}\) [deg], nodal array.

\[\tan\alpha^\mathrm{rel} = \frac{V_\theta^\mathrm{rel}}{V_m}\]
property Beta

Pitch angle \(\beta\) [deg], nodal array.

Pitch is the angle between the meridional velocity and the axial direction, i.e. the inclination of the flow in the x-r plane.

\[\tan\beta = \frac{V_r}{V_x}\]
property I

Rothalpy \(I\) [J/kg], nodal array.

\[I = h_0 - U V_\theta = h_0^\mathrm{rel} - \frac{1}{2}U^2\]

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(I\) are physically meaningful. See Datum state.

property L_ref

Reference length for non-dimensionalisation \(L_\mathrm{ref}\) [m].

property Ma

Absolute Mach number \(\mathit{M\kern-0.1ema}\) [-], nodal array.

property Ma_rel

Relative-frame Mach number \(\mathit{M\kern-0.1ema}^\mathrm{rel}\) [-], nodal array.

property Mam

Meridional Mach number \(\mathit{M\kern-0.1ema}_m\) [-], nodal array.

property Max

Axial Mach number \(\mathit{M\kern-0.1ema}_x\) [-], nodal array.

property Nb

Number of blades in the row containing this block \(N_\mathrm{b}\) [-], scalar int.

property Omega

Reference frame angular velocity \(\Omega\) [rad/s], scalar float.

property Omega_nd

Nondimensional angular velocity \(\Omega^*\) [–], scalar float.

\[\Omega^* = \frac{\Omega L_\mathrm{ref}}{V_\mathrm{ref}}\]
property P

Static pressure \(p\) [Pa], nodal array

property P_nd

Nondimensional static pressure \(p^*\) [-], nodal array.

\[p^* = \frac{p}{p_\mathrm{ref}}\]
property P_rot

Rotation-corrected static pressure \(p_\mathrm{rot}\) [Pa], nodal array.

Accounts for the pressure changes due to centrifugal and Coriolis forces in a rotating frame. Calculated by subtracting \(\frac{1}{2}U^2\) from static enthalpy and then using the equation of state to get the corresponding pressure in an isentropic process.

property Po

Stagnation pressure \(p_0\) [Pa], nodal array.

property Po_rel

Relative-frame stagnation pressure \(p_0^\mathrm{rel}\) [Pa], nodal array.

property Pr

Prandtl number [-], nodal array.

\[\mathit{Pr} = \frac{c_p \mu}{k}\]
property Rgas

Specific gas constant [J/kg/K].

property T

Temperature [K], nodal array.

property T_nd

Nondimensional temperature \(T / T_\mathrm{ref}\) [-], nodal array.

property To

Stagnation temperature \(T_0\) [K], nodal array.

property To_rel

Relative-frame stagnation temperature \(T_0^\mathrm{rel}\) [K], nodal array.

property U

Blade speed \(U\) [m/s], nodal array.

\[U = \Omega r\]
property V

Absolute velocity magnitude \(V\) [m/s], nodal array.

property V_nd

Nondimensional absolute velocity magnitude \(V/V_\mathrm{ref}\) [-], nodal array.

property V_rel

Relative velocity magnitude \(V^\mathrm{rel}\) [m/s], nodal array.

\[V^\mathrm{rel} = \sqrt{V_x^2 + V_r^2 + (V_\theta - \Omega r)^2}\]
property Vm

Meridional velocity magnitude \(V_m\) [m/s], nodal array.

\[V_m = \sqrt{V_x^2 + V_r^2}\]
property Vr

Radial velocity [m/s].

property Vr_nd

Non-dimensional radial velocity \(V_r^*\) [-], nodal array.

\[V_r^* = \frac{V_r}{V_\mathrm{ref}}\]
property Vt

Tangential velocity \(V_\theta\) [m/s], nodal array.

property Vt_nd

Non-dimensional tangential velocity \(V_\theta/V_\mathrm{ref}\) [-], nodal array.

property Vt_rel

Relative-frame tangential velocity \(V_\theta^\mathrm{rel}\) [m/s], nodal array.

\[V_\theta^\mathrm{rel} = V_\theta - \Omega r\]
property Vt_rel_nd

Non-dimensional relative tangential velocity \((V_\theta - \Omega r)/V_\mathrm{ref}\) [-], nodal array.

property Vx

Axial velocity \(V_x\) [m/s], nodal array.

property Vx_nd

Non-dimensional axial velocity \(V_x/V_\mathrm{ref}\) [-], nodal array.

property Vxrt

Stacked polar velocity vector \(\mathbf{V}\) [m/s, m/s, m/s], three-component nodal array.

property Vxrt_nd

Stacked nondimensional polar velocity \(\mathbf{V}/V_\mathrm{ref}\) [-], three-component nodal array.

property Vxrt_rel

Stacked relative-frame velocity vector \(\mathbf{V}^\mathrm{rel}\) [m/s, m/s, m/s], nodal array of three components.

property Vy

Cartesian y-velocity \(V_y\) [m/s], nodal array.

\[V_y = V_r \cos\theta - V_\theta \sin\theta\]
property Vz

Cartesian z-velocity \(V_z\) [m/s], nodal array.

\[V_z = -V_r \sin\theta - V_\theta \cos\theta\]
property a

Acoustic speed \(a\) [m/s], nodal array.

\[a^2 = \frac{\partial p}{\partial \rho}\Bigg|_s\]
property a_nd

Nondimensional acoustic speed \(a/V_\mathrm{ref}\) [-], nodal array.

Derived, not cached: each access allocates. The equation of state call is cheap next to a nodal buffer that would live for the whole run, and the solver’s one whole-block consumer, ember.grid.Grid.update_timestep(), does not come through here – it writes the same expression into scratch instead. What is left are the patch-average consumers (the mixing planes, the nonreflecting boundaries and the ember.perturbation matrices they drive), whose blocks are a surface rather than a volume. Do not put this in a per-node loop over a full block.

property ao

Stagnation acoustic speed \(a_0\) [m/s], nodal array.

clear_cache()

Clear all cached property values.

This forces all cached properties to recalculate on next access.

property conserved

Stacked conserved variables \(\mathcal{U}\), five-component nodal array.

\[\begin{split}\mathcal{U} = \begin{bmatrix} \rho \\ \rho V_x \\ \rho V_r \\ \rho r V_\theta \\ \rho e \end{bmatrix}\end{split}\]

Shape (ni, nj, nk, 5) with components over the last axis.

property conserved_nd

Stacked non-dimensional conserved variables \(\mathcal{U}^*\), nodal array with 5 components on last axis.

\[\begin{split}\mathcal{U}^* = \begin{bmatrix} \rho / \rho_\mathrm{ref} \\ \rho V_x / \rho_\mathrm{ref} V_\mathrm{ref} \\ \rho V_r / \rho_\mathrm{ref} V_\mathrm{ref} \\ \rho r V_\theta / \rho_\mathrm{ref} L_\mathrm{ref} V_\mathrm{ref} \\ \rho e / \rho_\mathrm{ref} u_\mathrm{ref} \end{bmatrix}\end{split}\]

Note that this property is a writable view onto the raw storage array, so modifying it will change the flow field without flushing the cache of derived properties or performing any validation. It is the low-level access point used by the CFD solver hot paths, so it is designed for speed rather than safety. Use with caution!

copy()

Take an independent copy of the data.

Data and metadata dicts are shallow-copied. Beware: mutable metadata values (e.g. arrays) edited in place are shared with the original.

Returns:

out – A new instance with copied data.

Return type:

same type as self

property cp

Specific heat at constant pressure \(c_p\) [J/kg/K], nodal array.

\[c_p = \frac{\partial h}{\partial T}\Bigg|_p\]
property cp_nd

Non-dimensional specific heat at constant pressure \(c_p / R_\mathrm{ref}\) [-], nodal array.

Derived, not cached, like mu_nd and kappa_nd; see mu_nd for why the three of them are not kept.

property cv

Specific heat at constant volume \(c_v\) [J/kg/K], nodal array.

\[c_v = \frac{\partial u}{\partial T}\Bigg|_\rho\]
property dhdP_rho_nd

Nondimensional derivative of enthalpy wrt. pressure at constant density \((\partial h/\partial p)_\rho \, \rho_\mathrm{ref}\) [-].

property dhdrho_P_nd

Nondimensional derivative of enthalpy wrt. density at constant pressure \((\partial h/\partial \rho)_p \, \rho_\mathrm{ref} / V_\mathrm{ref}^2\) [-].

property dsdP_rho_nd

Nondimensional derivative of entropy wrt. pressure at constant density \((\partial s/\partial p)_\rho \, p_\mathrm{ref} / R_\mathrm{ref}\) [-].

property dsdrho_P_nd

Nondimensional derivative of entropy wrt. density at constant pressure \((\partial s/\partial \rho)_p \, \rho_\mathrm{ref} / R_\mathrm{ref}\) [-].

property dudP_rho_nd

Nondimensional derivative of internal energy wrt. pressure at constant density \((\partial u/\partial p)_\rho \, \rho_\mathrm{ref}\) [-].

property dudrho_P_nd

Nondimensional derivative of internal energy wrt. density at constant pressure \((\partial u/\partial \rho)_p \, \rho_\mathrm{ref} / V_\mathrm{ref}^2\) [-].

property fac_lam

Prescribed laminar fraction \(f_\mathrm{lam}\) [-], nodal array.

A turbulence prescription, 1 fully laminar and 0 fully turbulent, and zero unless set_fac_lam() has been called. The viscous kernels weight both halves of the turbulence model by it, linearly:

\[\mu_\mathrm{turb} = (1 - f_\mathrm{lam})\,\mu_\mathrm{mix}, \qquad c_f = f_\mathrm{lam}\,\frac{2}{Re} + (1 - f_\mathrm{lam})\,c_{f,\mathrm{law}},\]

with the mixing-length viscosity taken at the cell (eight-corner mean) and the skin friction at the wall face (four-corner mean). Weighting the wall shear as well as the eddy viscosity is what makes a region prescribed laminar actually laminar: suppressing the mixing length alone leaves a log-law wall shear under a laminar layer.

Dimensionless, so it has no _nd counterpart and, unlike wdist, does not rescale with L_ref. A block unpickled from before the field existed reads zeros.

property flat

Flatten all axes into a single axis, not a copy.

Returns a new instance sharing metadata and data with the original via a numpy reshaped view. Writes through either object are visible in the other.

Points are ordered Fortran-style, with the first axis varying fastest, matching the column-major layout of the backing array. This is what makes the result a view rather than a copy; a C-ordered flattening of the same data would have to copy. Any code that flattens a block and later reshapes the result back must therefore pass order="F".

Returns:

out – A new instance with all points in a single dimension.

Return type:

same type as self, shape (npoints,)

Raises:

ValueError – If this instance is a non-contiguous view (for example a strided slice of a larger object) that cannot be flattened without copying. Freshly allocated instances are always flattenable.

property fluid

PerfectFluid object for equation of state calculations.

freeze()

Return a read-only copy, whose data and metadata cannot be set.

A frozen instance is a value. The setters refuse, and the backing array is marked read-only, which also closes the writeable views handed out for solver hot paths (ember.block.Block.conserved_nd) – those bypass the setters entirely, so a guard written in Python alone would not cover them. Derived properties remain readable and cached.

Freezing copies, so the original stays writeable and code holding it cannot reach into what has been handed on. Views taken from the result are frozen with it, because they share its array; copy() and empty() allocate a new one and are writeable, which is how a frozen state becomes the starting point for the next one.

Returns:

out – A read-only copy of this instance.

Return type:

same type as self

property frozen

Whether this instance is read-only, from freeze().

Read off the backing array’s writeable flag rather than stored alongside it, so the two cannot disagree. Every view shares that array and so reports frozen with it, while copy(), empty() and the reductions allocate their own and report writeable.

property gamma

Ratio of specific heats \(\gamma\) [-].

\[\gamma = \frac{c_p}{c_v}\]
property h

Static enthalpy \(h\) [J/kg], nodal array.

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(h\) are physically meaningful, so \(h \neq c_p T\). See Datum state.

property ho

Stagnation enthalpy \(h_0\) [J/kg], nodal array.

\[h_0 = h + \frac{1}{2}V^2\]

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(h_0\) are physically meaningful, so \(h_0 \neq c_p T_0\). See Datum state.

property ho_nd

Nondimensional stagnation enthalpy \(h_0/u_\mathrm{ref}\) [-].

Derived, not cached: each access allocates. The solver’s one whole-block consumer, set_residual, does not come through here – it forms the same quantity at the face corners it is already walking, from the conserved state and the pressure it is already handed:

\[h_0 = u + p/\rho + \tfrac{1}{2}V^2 = e + p/\rho = (\rho e + p) / \rho\]

which is exact for any fluid, \(h = u + p/\rho\) being the definition of enthalpy rather than an approximation of it. What is left here are the patch-average and post-processing readers, whose blocks are a surface rather than a volume. Do not put this in a per-node loop over a full block.

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes are physically meaningful. See Datum state.

property ho_rel

Relative-frame stagnation enthalpy \(h_0^\mathrm{rel}\) [J/kg], nodal array.

\[h_0^\mathrm{rel} = h + \frac{1}{2}{V^\mathrm{rel}}^2\]

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(h_0^\mathrm{rel}\) are physically meaningful, so \(h_0^\mathrm{rel} \neq c_p T_0^\mathrm{rel}\). See Datum state.

property kappa

Thermal conductivity \(\kappa\) [W/m/K], nodal array.

property kappa_nd

Non-dimensional thermal conductivity \(\kappa^*\) [–], nodal array.

\[\kappa^* = \frac{\kappa} {\rho_\mathrm{ref} V_\mathrm{ref} R_\mathrm{ref} L_\mathrm{ref}}\]

The scaling that leaves \(\mathit{Pr} = \mu^* c_p^* / \kappa^*\) dimensionless, so this is what the viscous kernel’s heat flux takes in place of the viscosity and Prandtl number it used to be handed.

Derived, not cached, like mu_nd and cp_nd; see mu_nd for why the three of them are not kept.

property label

String label describing the block.

masked(mask)

Confine subsequent setters to the nodes where mask is True.

Boolean indexing a block (block[mask]) cannot be used to write back into the original, because numpy advanced indexing returns a copy rather than a view. This method works around that: it returns a proxy whose set_* methods apply to the whole block and then roll back every node outside the mask, so only masked nodes are changed and all other state (including the velocity field preserved by thermodynamic setters) is untouched.

Any setter is supported. The proxy snapshots this block’s backing array on each setter call, so to keep the copy cheap on a large block, narrow it first with a basic-index slice – a slice is a view, so writes still propagate to the parent:

block[0].masked(mask).set_P_T(1e5, 600.0)
Parameters:

mask (array-like of bool) – Boolean array matching the block shape. Setters modify only the nodes where it is True.

Returns:

Proxy whose set_* methods are confined to the masked nodes.

Return type:

_MaskedBlock

Examples

Heat only the cold nodes, leaving the rest of the field alone:

# example: masked
from ember.block import Block
from ember.fluid import PerfectFluid
import numpy as np

fluid = PerfectFluid(cp=1005.0, gamma=1.4, mu=1.8e-5, Pr=0.7)
b = Block((4,))
b.set_fluid(fluid)
b.set_x(0.0)
b.set_r(1.0)
b.set_t(0.0)
b.set_P_T(1e5, 300.0)
b.set_Vx(5.0)
b.set_Vr(0.0)
b.set_Vt(0.0)
b.masked(np.array([True, False, True, False])).set_P_T(1e5, 600.0)
print(b.T)   # [600. 300. 600. 300.]
print(b.Vx)  # [5. 5. 5. 5.]
memory_usage()

Return memory usage of this block’s data, metadata, and cached properties.

Returns:

  • data_usage (dict) – Bytes per data key (equal share of the contiguous backing array).

  • metadata_usage (dict) – Bytes per metadata key (nbytes for arrays, sys.getsizeof for others).

  • cache_usage (dict) – Bytes per cached property (nbytes for arrays, sys.getsizeof for others).

property mu

Dynamic viscosity \(\mu\) [kg/m/s], nodal array.

property mu_nd

Non-dimensional dynamic viscosity \(\mu^*\) [–], nodal array.

\[\mu^* = \frac{\mu}{\rho_\mathrm{ref} V_\mathrm{ref} L_\mathrm{ref}}\]

May be thought of as a reciprocal Reynolds number based on the reference scales.

Nodal rather than one number for the block, because a real gas’s viscosity is a surface over the field. A perfect gas fills the same array with one repeated constant, as it already does for cp_nd.

Derived, not cached: each access allocates. The transport trio (this, kappa_nd and cp_nd) is read in one phase of the step and nowhere else – the two viscous kernels of ember.grid.Grid.update_sources() – and that phase borrows all three from the scratch arena instead of coming through here, so caching them meant three nodal volumes sitting allocated for a whole run to serve nothing but diagnostics. What is left here are those diagnostics and the tests. Do not put this in a per-node loop over a full block.

property mu_turb

Turbulent viscosity \(\mu_\mathrm{turb}\) [kg/m/s].

property ndim

Number of spatial dimensions.

property ni

Number of points along first axis.

property nj

Number of points along second axis.

property nk

Number of points along third axis.

property nvar

Number of variables stored at each spatial point.

property pitch

Circumferential pitch [rad].

\[\Delta\theta = \frac{2\pi}{N_\mathrm{b}}\]
property r

Radial coordinate \(r\) [m], nodal array.

property r_mid_nd

Midspan nondimensional radius, \(\tfrac12(\min r_\mathrm{nd} + \max r_\mathrm{nd})\) [-].

Derived from the block’s own coordinates (a representative radius for this block), not a user-set reference scale – hence _mid rather than the _ref suffix carried by the arbitrary fluid/length scales. Used to rescale the angular-momentum (rhorVt) residual by a radius so its magnitude is comparable to the linear-momentum residuals.

Cached once: the block geometry is fixed for the lifetime of a solve.

property r_nd

Nondimensional radial coordinate \(r / L_\mathrm{ref}\) [-], nodal array

property rho

Mass density \(\rho\) [kg/m^3], nodal array.

property rhoVm

Meridional mass flux \(\rho V_m\) [kg/m^2/s], nodal array.

property rhoVr

Volumetric radial momentum \(\rho V_r\) [kg/m^2/s], nodal array.

property rhoVx

Volumetric axial momentum \(\rho V_x\) [kg/m^2/s], nodal array.

property rho_nd

Non-dimensional mass density \(\rho/\rho_\mathrm{ref}\) [-], nodal array.

property rhoe

Volumetric total energy \(\rho e\) [J/m^3], nodal array.

\[e = u + \tfrac{1}{2}(V_x^2 + V_r^2 + V_\theta^2)\]
property rhoo

Stagnation density \(\rho_0\) [kg/m^3], nodal array.

property rhoo_rel

Relative-frame stagnation density \(\rho_0^\mathrm{rel}\) [kg/m^3], nodal array.

property rhorVt

Volumetric angular momentum \(\rho r V_\theta\) [kg/m^2/s], nodal array.

property rpm

Reference frame revolutions per minute [rpm]

property rt

Pseudo-Cartesian circumferential coordinate \(r\theta\) [m], nodal array.

property s

Specific entropy \(s\) [J/kg/K], nodal array.

Defined relative to an arbitrary datum where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(s\) are physically meaningful. See Datum state.

property s_nd

Nondimensional entropy \(s / R_\mathrm{ref}\) [-].

Defined relative to an arbitrary datum where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes are physically meaningful. See Datum state.

set_L_ref(L_ref)

Set reference length scale preserving existing dimensional values.

The underlying block data is stored in a nondimensional form for reasons of numerical precision. For example, Block.r is actually stored as radius normalised by the reference length scale with the raw value accessible as Block.r_nd.

Note that the Block.fluid instance specifies additional reference scales needed to make thermodynamic properties non-dimensional.

This method sets a new reference length, rescaling stored nondimensional coordinates and angular momentum so that dimensional values are preserved.

Parameters:

L_ref (float) – Reference length scale [m]. Should be scalar, positive, and finite.

set_Nb(Nb)

Set number of blades in the row containing this block.

Used to determine circumferential periodicity.

Parameters:

Nb (int) – Number of blades in the row containing this block [-].

set_Omega(Omega)

Set reference frame angular velocity.

Properties suffixed _rel are defined in the rotating reference frame spinning at this angular velocity.

Parameters:

Omega (float) – Angular velocity of the rotating reference frame [rad/s].

set_P_T(P, T)

Store static pressure and temperature.

Set the thermodynamic state by specifying static pressure and temperature. The velocity field, if present, is preserved.

Parameters:
  • P (array-like) – Static pressure [Pa]. Must be positive, finite, and broadcast to block shape.

  • T (array-like) – Temperature [K]. Must be positive, finite, and broadcast to block shape.

set_P_h(P, h)

Store static pressure and enthalpy.

Set the thermodynamic state by specifying static pressure and specific static enthalpy. The velocity field, if present, is preserved.

Parameters:
  • P (array-like) – Static pressure [Pa]. Must be positive, finite, and broadcast to block shape.

  • h (array-like) – Specific static enthalpy [J/kg]. Must be finite and broadcast to block shape.

set_P_rho(P, rho)

Store static pressure and density.

Set the thermodynamic state by specifying static pressure and density. The velocity field, if present, is preserved.

Parameters:
  • P (array-like) – Static pressure [Pa]. Must be positive, finite, and broadcast to block shape.

  • rho (array-like) – Density [kg/m^3]. Must be positive, finite, and broadcast to block shape.

set_P_rho_nd(P_nd, rho_nd)

Store static pressure and density, nondimensional inputs.

Set the thermodynamic state by specifying nondimensional static pressure and density. The velocity field, if present, is preserved.

Parameters:
  • P_nd (array-like) – Static pressure normalised by fluid.P_ref [–]. Should be positive and finite; no validation is performed as this setter is on the hot path for boundary condition application.

  • rho_nd (array-like) – Density normalised by fluid.rho_ref [–]. Should be positive and finite; no validation is performed.

set_P_s(P, s)

Store static pressure and entropy.

Set the thermodynamic state by specifying static pressure and entropy per unit mass. The velocity field, if present, is preserved.

Parameters:
  • P (array-like) – Static pressure [Pa]. Must be positive, finite, and broadcast to block shape.

  • s (array-like) – Specific entropy [J/kg/K]. Must be finite and broadcast to block shape.

set_T_s(T, s)

Store temperature and entropy.

Set the thermodynamic state by specifying static temperature and entropy per unit mass. The velocity field, if present, is preserved.

Parameters:
  • T (array-like) – Temperature [K]. Must be positive, finite, and broadcast to block shape.

  • s (array-like) – Specific entropy [J/kg/K]. Must be finite and broadcast to block shape.

set_V_Alpha_Beta(V, Alpha, Beta)

Set the velocity vector from speed, yaw angle, and pitch angle.

The velocity components are

\[\begin{split}\begin{aligned} V_x &= V \cos\beta\cos\alpha \\ V_r &= V \sin\beta\cos\alpha \\ V_\theta &= V \sin\alpha \end{aligned}\end{split}\]

where \(\alpha\) is the yaw angle and \(\beta\) is the pitch angle. Trigonometric identities are used to avoid the \(\tan 90^\circ\) singularity.

Parameters:
  • V (array-like) – Velocity magnitude [m/s]. Must broadcast to block shape.

  • Alpha (array-like) – Yaw angle \(\alpha\) [deg]. Must broadcast to block shape.

  • Beta (array-like) – Pitch angle \(\beta\) [deg]. Must broadcast to block shape.

set_Vr(Vr)

Store radial velocity.

The thermodynamic state (density and internal energy) is preserved, so this may be called before or after a thermodynamic setter such as set_P_T() when building up a flow field.

If you are setting all three velocity components, prefer set_Vxrt(), which updates the internal energy only once instead of three times for all components.

Parameters:

Vr (array-like) – Radial velocity [m/s]. Must be finite and broadcast to block shape.

set_Vt(Vt)

Store circumferential velocity.

The thermodynamic state (density and internal energy) is preserved, so this may be called before or after a thermodynamic setter such as set_P_T() when building up a flow field.

If you are setting all three velocity components, prefer set_Vxrt(), which updates the internal energy only once instead of three times for all components.

Parameters:

Vt (array-like) – Circumferential velocity [m/s]. Must be finite and broadcast to block shape.

set_Vx(Vx)

Store axial velocity.

The thermodynamic state (density and internal energy) is preserved, so this may be called before or after a thermodynamic setter such as set_P_T() when building up a flow field.

If you are setting all three velocity components, prefer set_Vxrt(), which updates the internal energy only once instead of three times for all components.

Parameters:

Vx (array-like) – Axial velocity [m/s]. Must be finite and broadcast to block shape.

set_Vxrt(Vxrt)

Store polar velocity components from a single array.

More efficient than three separate set_Vx(), set_Vr(), set_Vt() calls as the energy update is performed only once.

The thermodynamic state (density and internal energy) is preserved, so this may be called before or after a thermodynamic setter such as set_P_T() when building up a flow field.

Parameters:

Vxrt (array-like, shape (..., 3)) – Polar velocity components [m/s], with Vx, Vr, Vt along the last axis. Must be finite and broadcast to block shape.

set_conserved(conserved)

Store conserved variables.

The conserved variables are density, axial momentum, radial momentum, angular momentum, and total energy:

\[\begin{split}\mathcal{U} = \begin{bmatrix} \rho \\ \rho V_x \\ \rho V_r \\ \rho r V_\theta \\ \rho e \end{bmatrix}\end{split}\]

where \(e = u + \frac{1}{2}(V_x^2 + V_r^2 + V_\theta^2)\) is the total specific energy.

Together, the five conserved variables uniquely determine the thermodynamic state and velocity field, and being most convenient for computational fluid dynamics calculations, are the primary data stored in the block. Other variables like pressure and temperature are computed from the conserved variables via the equation of state in Block.fluid.

Parameters:

conserved (array-like, shape (..., 5)) – Dimensional conserved variables with components along the last axis. Each component must broadcast to block shape and be finite. Density must be >0.

set_fac_lam(fac_lam)

Store the prescribed laminar fraction.

See Block.fac_lam for more details.

Parameters:

fac_lam (array-like) – Laminar fraction [-], 1 fully laminar and 0 fully turbulent. Must lie in [0, 1] and broadcast to block shape.

set_fluid(fluid_new)

Set equation of state preserving any existing flow field.

An equation of state, encapsulated in a PerfectFluid instance, must be set before any thermodynamic properties can be computed.

If an old fluid is already set, dimensional density, temperature, and velocities are read out, the fluid instance is swapped, and the stored flow field is rewritten using the new fluid’s reference scales and datum levels.

Parameters:

fluid_new (Fluid) – New fluid / equation of state object.

See also

ember.grid.Grid.set_fluid

Apply to every block in a Grid at once. Prefer this when the block is part of a Grid, rather than looping over blocks and calling this method individually.

set_h_s(h, s)

Store enthalpy and entropy.

Set the thermodynamic state by specifying static enthalpy and entropy per unit mass. The velocity field, if present, is preserved.

Parameters:
  • h (array-like) – Specific static enthalpy [J/kg]. Must be finite and broadcast to block shape.

  • s (array-like) – Specific entropy [J/kg/K]. Must be finite and broadcast to block shape.

set_label(label)

Set a string label describing the block.

Parameters:

label (str) – Descriptive label for the block.

set_mu_turb(mu_turb)

Store turbulent viscosity.

See Block.mu_turb for more details.

Parameters:

mu_turb (array-like) – Turbulent viscosity [kg/m/s]. Must be >=0 and finite, and broadcast to block shape.

set_r(r)

Store radial coordinates.

Parameters:

r (array-like) – Radial coordinates [m]. Must be >0 and finite, and broadcast to block shape.

set_rho_s(rho, s)

Store density and entropy.

Set the thermodynamic state by specifying density and entropy per unit mass. The velocity field, if present, is preserved.

Parameters:
  • rho (array-like) – Density [kg/m^3]. Must be positive, finite, and broadcast to block shape.

  • s (array-like) – Specific entropy [J/kg/K]. Must be finite and broadcast to block shape.

set_rho_u(rho, u)

Store density and internal energy.

Set the thermodynamic state by specifying density and internal energy per unit mass. The velocity field, if present, is preserved.

Parameters:
  • rho (array-like) – Density [kg/m^3]. Must be positive, finite, and broadcast to block shape.

  • u (array-like) – Specific internal energy [J/kg]. Must be finite and broadcast to block shape.

set_rpm(rpm)

Set reference frame angular velocity in revolutions per minute.

Converts to rad/s and calls set_Omega().

Parameters:

rpm (float) – Angular velocity of the rotating reference frame [rpm].

set_t(t)

Store circumferential coordinates.

Parameters:

t (array-like) – Circumferential coordinates [rad]. Must be finite and broadcast to block shape.

set_wdist(wdist)

Store distance to nearest wall.

See Block.wdist for more details.

Parameters:

wdist (array-like) – Distance to nearest viscous wall [m]. Must be >=0 and finite, and broadcast to block shape.

set_x(x)

Store axial coordinates.

Parameters:

x (array-like) – Axial coordinates [m]. Must be finite and broadcast to block shape.

set_xrt(xrt)

Store polar coordinates from a single array.

Parameters:

xrt (array-like, shape (..., 3)) – Polar coordinates, with x [m], r [m], t [rad] along the last axis. Must be finite and broadcast to block shape.

set_xyz(xyz)

Store Cartesian coordinates, converted to polar on write.

Converts to polar coordinates via:

\[ \begin{align}\begin{aligned}r = \sqrt{y^2 + z^2}\\\theta = \mathrm{arctan2}(-z,\, y)\end{aligned}\end{align} \]
Parameters:

xyz (array-like, shape (..., 3)) – Cartesian coordinates [m], with x, y, z along the last axis. Must be finite and broadcast to block shape.

property shape

Shape of the grid points.

property shape_cell

Shape of cell-centred arrays (ni-1, nj-1, nk-1).

property shape_iface

Shape of i-face arrays (ni, nj-1, nk-1).

property shape_jface

Shape of j-face arrays (ni-1, nj, nk-1).

property shape_kface

Shape of k-face arrays (ni-1, nj-1, nk).

property sinBeta

Sine of pitch angle \(\sin\beta\) [-], nodal array.

\[\sin\beta = \frac{V_r}{V_m}\]
property size

Total number of spatial points.

property t

Circumferential coordinate \(\theta\) [rad], nodal array.

property tanAlpha

Tangent of absolute yaw angle \(\tan\alpha\) [-], nodal array.

\[\tan\alpha = \frac{V_\theta}{V_m}\]
property tanAlpha_rel

Tangent of relative-frame yaw angle \(\tan\alpha^\mathrm{rel}\) [-], nodal array.

\[\tan\alpha^\mathrm{rel} = \frac{V_\theta^\mathrm{rel}}{V_m}\]
property tanBeta

Tangent of pitch angle \(\tan\beta\) [-], nodal array.

\[\tan\beta = \frac{V_r}{V_x}\]
property u

Specific internal energy \(u\) [J/kg], nodal array.

Defined relative to an arbitrary datum where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(u\) are physically meaningful, so \(u \neq c_v T\). See Datum state.

property u_nd

Nondimensional specific internal energy \(u/u_\mathrm{ref}\) [-], nodal array.

Raises if the thermodynamic state is unset.

property uo

Stagnation internal energy \(u_0\) [J/kg], nodal array.

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(u_0\) are physically meaningful, so \(u_0 \neq c_v T_0\). See Datum state.

property uo_rel

Relative-frame stagnation internal energy \(u_0^\mathrm{rel}\) [J/kg], nodal array.

Carries an offset dependent on the arbitrary datum state where \(u = s = 0\) at \((p_\mathrm{dtm}, T_\mathrm{dtm})\); only changes in \(u_0^\mathrm{rel}\) are physically meaningful, so \(u_0^\mathrm{rel} \neq c_v T_0^\mathrm{rel}\). See Datum state.

update_cached_conserved()

Refresh caches that depend on the conserved variables.

Bumps the conserved-variable versions so every cached property keyed on them recomputes on next access. Only needed if you modify conserved_nd directly, as that bypasses the usual cache invalidation that happens in the setter methods.

Unlike clear_cache(), this does not clear cached geometry such as vol_nd.

view()

Create a new instance sharing the same data and metadata, not a copy.

Returns a new instance of the same class sharing the underlying data array, metadata dict, and version counters with the original. Mutations to data (i.e. writing to the array) are visible through both objects. Derived properties are held in a separate per-instance cache, so each view starts cold.

Returns:

out – A new instance sharing all data and metadata with the original.

Return type:

same type as self

property wdist

Distance to nearest wall \(w\) [m], nodal array.

Defined as the distance from each grid node to the nearest viscous wall. Used by the turbulence models to compute turbulent viscosity; only required for viscous runs. Usually populated automatically by calculate_wdist() rather than called directly.

property wdist_nd

Nondimensional distance to nearest wall \(w/L_\mathrm{ref}\) [-], nodal array.

property x

Axial coordinate \(x\) [m], nodal array.

property xr

Stacked meridional coordinates \((x, r)\) [m, m], two-component nodal array.

property xrrt

Stacked pseudo-Cartesian coordinates \((x, r, r\theta)\) [m, m, m], three-component nodal array.

property xrt

Stacked polar coordinates \((x, r, \theta)\) [m, m, rad], three-component nodal array.

property xrt_nd

Stacked nondimensional polar coordinates \((x/L_\mathrm{ref}, r/L_\mathrm{ref}, \theta)\) [-, -, rad], nodal array of three components.

property y

Cartesian y-coordinate \(y\) [m], nodal array.

\[y = r \cos\theta\]
property z

Cartesian z-coordinate \(z\) [m], nodal array.

\[z = -r \sin\theta\]