Block¶
Storage and manipulation of flow field data for a single structured grid block.
This module defines the Block, our fundamental data structure for representing flow fields on structured grids with any number of dimensions. The class stores coordinates and conserved quantities, and provides properties for derived quantities such as velocity, stagnation pressure, and Mach number. There is also a store for scalar metadata related to
the entire field, such as reference frame angular velocity. All data flows are managed through setter methods that ensure validity and consistency of the flow field. The class also stores boundary patches to specify simulation boundary conditions in Block.patches.
Indexing and slicing¶
A Block supports numpy-style indexing and slicing over the spatial axes:
block[i] # scalar index -- reduces ndim by one
block[ist:ien] # slice -- preserves ndim
block[i, jst:jen, :] # mixed index tuple for 3D data
Indexing returns a new Block instance that shares the same underlying
backing array as the original (a zero-copy view). Writes to the indexing result
are visible in the original and vice versa.
Array methods¶
A Block provides a family of numpy-style array methods that reshape,
reorder, reduce or copy the block. They all act on the underlying raw
variables – the coordinates and conserved quantities – and not on derived
thermodynamic properties, which are recomputed from the transformed raw
data on the returned instance.
Views and copies:
Block.view()– new instance sharing the same data and metadataBlock.copy()– independent copy of the raw data.Block.empty()– fresh uninitialised instance with the same metadata
Reshaping and reordering (a zero-copy view where the layout allows, otherwise a copy):
Block.flat()– collapse all axes into oneBlock.reshape()– change the axes, keeping the total node countBlock.squeeze()– drop singleton axesBlock.transpose()– reorder the axes (reversed by default)Block.flip()– reverse indexing along an axis
Reduction over a spatial axis:
Block.mean()– arithmetic mean of the raw variablesBlock.nanmean()– as above, ignoring NaNs
Equations of state¶
Block does not implement an equation of state itself. It stores only
the conserved quantities at grid nodes and delegates every thermodynamic
relation to a ember.fluid equation of state attached by
Block.set_fluid(). The Block works in terms of density and internal energy, and the fluid performs to and from other thermodynamic properties as needed.
Reading a thermodynamic property such as static pressure Block.P first extracts internal energy Block.u from the conserved quantities Block.conserved by subtracting kinetic energy.
Then, density and internal energy are passed to ember.fluid.PerfectFluid.get_P() which evaluates the equation of state to calculate pressure. Temperature, entropy, and so on follow this same pattern.
Writing a thermodynamic state is the reverse of reading out a derived property, although by the two-property rule the set methods take two arguments.
Block.set_P_T() passes pressure
and temperature to ember.fluid.PerfectFluid.set_P_T(), which inverts the equation of state to find the corresponding density and internal energy.
Block then saves density directly, and updates the other conserved quantities to reflect the new thermodynamic state while preserving the velocity field.
This works even before any velocity has been set, because a new block starts with dummy initial values for density, radius, momenta, and energy. The kinetic energy therefore evaluates to zero on an uninitialised block, and the thermodynamic round-trip stays consistent once velocities are later supplied.
Reference scales¶
Block non-dimensionalisation follows the scheme described in
ember.fluid; see Reference scales.
Three raw scales are chosen by the user and passed to the working fluid constructor:
\(\rho_\mathrm{ref}\), \(V_\mathrm{ref}\), and \(R_\mathrm{ref}\).
Three derived thermodynamic scales are then formed:
\(p_\mathrm{ref} = \rho_\mathrm{ref} V_\mathrm{ref}^2\),
\(u_\mathrm{ref} = V_\mathrm{ref}^2\), and
\(T_\mathrm{ref} = V_\mathrm{ref}^2 / R_\mathrm{ref}\).
All six are accessible via the attached fluid at Block.fluid.
Spatial coordinates are normalised by a separate reference length
\(L_\mathrm{ref}\) [m], set via Block.set_L_ref() and
accessible as Block.L_ref. It defaults to 1.0 and is
independent of the fluid.
At rest, a Block stores the raw data in non-dimensional form,
although the reference scales all default to unity. Furthermore, changes to the
reference scales are handled by rescaling the raw data in place, so they do
not affect the dimensional properties of the block. This means that
the non-dimensional storage is completely transparent to the user.
Examples
Construct a scalar block, set coordinates, fluid, thermodynamic state, and velocity:
# example: construct
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()
b.set_fluid(fluid)
b.set_x(0.0).set_r(0.75).set_t(0.0)
b.set_P_T(1e5, 300.0)
b.set_Vx(100.0).set_Vr(0.0).set_Vt(0.0)
print(b.P) # 100000.0
print(b.T) # 300.0
print(b.Ma) # 0.28795615
print(b.ho) # 91142.84
Indexing and slicing return a view over a sub-region:
# example: indexing
from ember.block import Block
import numpy as np
b = Block((6,))
b.set_x(np.linspace(0.0, 0.5, 6))
print(b[2].x) # 0.2
print(b[-1].x) # 0.5
print(b[1:4].x) # [0.1 0.2 0.3]
b2 = Block((3, 2))
b2.set_x(np.arange(6, dtype=float).reshape(3, 2) * 0.1)
print(b2[0, :].x) # [0. 0.1]
print(b2[:, 1].x) # [0.1 0.3 0.5]
Setter methods return self and can be chained:
# example: chaining
from ember.block import Block
from ember.fluid import PerfectFluid
fluid = PerfectFluid(cp=1005.0, gamma=1.4, mu=1.8e-5, Pr=0.7)
b = Block().set_fluid(fluid).set_rho_u(1.1, 1e4)
print(b.T) # 313.93036
Block.copy() decouples the backing array so mutations do not propagate:
# example: copy
from ember.block import Block
b1 = Block()
b1.set_x(2.0)
b2 = b1.copy()
b2.set_x(-6.0)
print(b1.x) # 2.0
print(b2.x) # -6.0
- class ember.block.Block(shape=())[source]¶
Allocate a structured grid block.
This is the primary data container for flow fields. It stores coordinates and conserved variables, and provides properties for derived variables such as velocity, pressure and Mach number. All data flows are managed through setter methods that ensure validity and consistency of the flow field. The class also stores boundary patches to specify simulation boundary conditions in
Block.patches, and provides working arrays for solver computations atblock.working.The setters fall into two complementary families: thermodynamic setters (e.g.
set_P_T(),set_rho_u()) set the density and internal energy while preserving the velocity field, and velocity setters (set_Vx(),set_Vr(),set_Vt()) set the velocity while preserving the thermodynamic state. Because each family preserves what the other sets, the two may be called in either order to build up a complete flow field.- Parameters:
shape (tuple of int, optional) – Number of nodes in each dimension (ni, nj, nk, …). Any number of dimensions is supported. Defaults to (), giving a scalar block with no grid dimensions.
- set_conserved(conserved)[source]¶
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.
- set_fluid(fluid_new)[source]¶
Set equation of state preserving any existing flow field.
An equation of state, encapsulated in a
PerfectFluidinstance, 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.
- Returns:
self – To allow method chaining.
- Return type:
- set_h_s(h, s)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_L_ref(L_ref)[source]¶
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.ris actually stored as radius normalised by the reference length scale with the raw value accessible asBlock.r_nd.Note that the
Block.fluidinstance 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.
- set_mu_turb(mu_turb)[source]¶
Store turbulent viscosity.
See
Block.mu_turbfor more details.- Parameters:
mu_turb (array-like) – Turbulent viscosity [kg/m/s]. Must be >=0 and finite, and broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_Nb(Nb)[source]¶
Set number of blades in the row containing this block.
Used to determine circumferential periodicity.
- set_Omega(Omega)[source]¶
Set reference frame angular velocity.
Properties suffixed
_relare defined in the rotating reference frame spinning at this angular velocity.
- set_P_h(P, h)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_P_rho(P, rho)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_P_rho_nd(P_nd, rho_nd)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_P_s(P, s)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_P_T(P, T)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_r(r)[source]¶
Store radial coordinates.
- Parameters:
r (array-like) – Radial coordinates [m]. Must be >0 and finite, and broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_rho_s(rho, s)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_rho_u(rho, u)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_rho_u_Vxrt_nd(rho_nd, u_nd, Vx_nd, Vr_nd, Vt_nd)[source]¶
Write conserved variables from non-dimensional state and velocity.
Low-level, no-validation setter on the boundary-condition hot path: all inputs are non-dimensionalised by the fluid reference scales. The velocity components are supplied explicitly, so the internal energy follows from
\[e = u + \tfrac{1}{2}(V_x^2 + V_r^2 + V_\theta^2).\]Boundary conditions own the physics that produces
(rho, u)and the velocity vector (e.g.fluid.set_P_sorfluid.set_rho_sfollowed by a flow-angle or energy-equation reconstruction) and then call this primitive to store the result.- Parameters:
rho_nd (array-like) – Non-dimensional density. Must broadcast to block shape.
u_nd (array-like) – Non-dimensional specific internal energy. Must broadcast to block shape.
Vx_nd (array-like) – Non-dimensional axial velocity. Must broadcast to block shape.
Vr_nd (array-like) – Non-dimensional radial velocity. Must broadcast to block shape.
Vt_nd (array-like) – Non-dimensional tangential velocity. Must broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_rpm(rpm)[source]¶
Set reference frame angular velocity in revolutions per minute.
Converts to rad/s and calls
set_Omega().
- set_t(t)[source]¶
Store circumferential coordinates.
- Parameters:
t (array-like) – Circumferential coordinates [rad]. Must be finite and broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_T_s(T, s)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_V_Alpha_Beta(V, Alpha, Beta)[source]¶
Set the velocity vector from speed, yaw angle, and pitch angle.
The velocity components are
\[\begin{split}\begin{align} V_x &= V \cos\beta\cos\alpha \\ V_r &= V \sin\beta\cos\alpha \\ V_\theta &= V \sin\alpha \end{align}\end{split}\]where \(\alpha\) is the pitch angle and \(\beta\) is the yaw angle. Trigonometric identities are used to avoid the \(\tan(90°)\) singularity.
- Parameters:
V (array-like) – Velocity magnitude [m/s]. Must broadcast to block shape.
Alpha (array-like) – Pitch angle \(\alpha\) [deg]. Must broadcast to block shape.
Beta (array-like) – Yaw angle \(\beta\) [deg]. Must broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_Vr(Vr)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_Vt(Vt)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_Vx(Vx)[source]¶
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.
- Returns:
self – To allow method chaining.
- Return type:
- set_Vxrt(Vxrt)[source]¶
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.
- set_wdist(wdist)[source]¶
Store distance to nearest wall.
See
Block.wdistfor more details.- Parameters:
wdist (array-like) – Distance to nearest viscous wall [m]. Must be >=0 and finite, and broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_x(x)[source]¶
Store axial coordinates.
- Parameters:
x (array-like) – Axial coordinates [m]. Must be finite and broadcast to block shape.
- Returns:
self – To allow method chaining.
- Return type:
- set_xyz(xyz)[source]¶
Store Cartesian coordinates.
Converts to polar coordinates via:
\[ \begin{align}\begin{aligned}r = \sqrt{y^2 + z^2}\\\theta = \mathrm{arctan2}(-z,\, y)\end{aligned}\end{align} \]
- copy(keep_patches=True)[source]¶
Return an independent copy of this block.
All data arrays, metadata, and derived-property caches are copied so that modifications to the returned block do not affect the original. Patches are deep-copied by default so each block owns its own patch objects; pass
keep_patches=Falseto get a copy with an empty patch collection instead.
- flat()[source]¶
Flatten all axes into a single axis, returning a view rather than a copy.
On top of the base flattening, this copies the metadata dict and replaces the patches with an empty
BlockPatchCollection, since spatial patches have no meaning on a 1D flattened layout.
- masked(mask)[source]¶
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 whoseset_*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, and calls chain. 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,)).set_fluid(fluid) b.set_x(0.0).set_r(1.0).set_t(0.0) b.set_P_T(1e5, 300.0).set_Vx(5.0).set_Vr(0.0).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.]
- update_cached_conserved()[source]¶
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_nddirectly, as that bypasses the usual cache invalidation that happens in the setter methods.
- update_filter(cfl, delta)[source]¶
Evolve the SFD low-pass filter
conserved_filt_ndone step.First-order exponential moving average of the cell-centred conserved state toward the current cell state, with per-cell timestep
dt = cfl * dt_vol * vol.cflmay be the per-cell/per-equationworking.cflarray or a single scalar; the rank selects the matching kernel.deltais the filter time constant.Must run after the CFL and
dt_volfor the step are current. This is the lone per-step writer of the read-onlyconserved_filt_ndbuffer (the restart apply is the only other writer), so it owns theflags.writeabletoggle (mirrors the timestep writers).
- 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.
Cached on the conserved variables (same keys as
_u_nd_uninit, its only real dependency viau) so the reusable buffer is passed toget_aasoutand recomputed in place each stage rather than allocating a fresh array on the per-stage CFL/timestep path.
- 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 ao¶
Stagnation acoustic speed \(a_0\) [m/s], nodal array.
- 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 conserved¶
Stacked conserved variables \(U\), nodal array with 5 components on last axis.
\[\begin{split}U = \begin{bmatrix} \rho \\ \rho V_x \\ \rho V_r \\ \rho r V_\theta \\ \rho e \end{bmatrix}\end{split}\]
- property conserved_avg_nd¶
Time-averaged nodal nondimensional conserved variables, shape (ni, nj, nk, 5).
Running-mean accumulator built over the final
n_step_avgsteps of a march. LikeF_body_ndthis is a no-key cached buffer: allocated once, never invalidated, read-only to consumers. Zero-initialised here so accumulation starts from a clean slate; its owners (ember.grid.Grid.accumulate_avg()andember.grid.Grid.finalise_average()) toggleflags.writeablearound their in-place writes.
- property conserved_cell¶
Stacked cell-centered conserved variables \(U_\mathrm{cell}\), array with 5 components on last axis.
\[\begin{split}U_\mathrm{cell} = \begin{bmatrix} \rho \\ \rho V_x \\ \rho V_r \\ \rho r V_\theta \\ \rho e \end{bmatrix}\end{split}\]Each component is the 8-corner average of the corresponding nodal component, with shape
(ni-1, nj-1, nk-1, 5).
- property conserved_cell_nd¶
Stacked non-dimensional cell-centered conserved variables \(U^*_\mathrm{cell}\), array with 5 components on last axis.
\[\begin{split}U^*_\mathrm{cell} = \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}\]Each component is the 8-corner average of the corresponding nodal component of
conserved_nd, with shape(ni-1, nj-1, nk-1, 5).
- property conserved_filt_nd¶
Low-pass-filtered cell-centred conserved state, shape (ni-1, nj-1, nk-1, 5).
Stateful selective-frequency-damping scratch: seeded to the current cell-averaged conserved state on first access, then evolved each step by
adapt_cfland read by the SFD body force. The no-keycached_arrayallocates it once and never invalidates it; read-only to consumers, its writers (set_cfland the restart apply) toggleflags.writeablearound their writes.
- property conserved_nd¶
Stacked non-dimensional conserved variables \(U^*\), nodal array with 5 components on last axis.
\[\begin{split}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!
- property cp_nd¶
Non-dimensional specific heat at constant pressure \(c_p / R_\mathrm{ref}\) [-], nodal array.
- property dA_quad¶
Face area vectors for a 2D structured cut \(\delta A\) [m^2], shape (ni-1, nj-1, 3).
See Face areas for the calculation.
- property dA_tri¶
Face area vectors for a 2D unstructured cut \(\delta\!A\) [m^2], shape (ntri, 3).
See Face areas for the calculation.
- property dAi¶
Constant-i face area vectors of a 3D block \(\delta A_i\) [m^2], shape (ni, nj-1, nk-1, 3).
See
dAi_ndfor the nondimensional form and the geometry reference.
- property dAi_nd¶
Constant-i face area vectors of a 3D block \(\delta A_i / L_\mathrm{ref}^2\) [-], components on first axis.
See Face areas for the calculation.
- property dAj¶
Constant-j face area vectors of a 3D block \(\delta A_j\) [m^2], shape (ni-1, nj, nk-1, 3).
See
dAj_ndfor the nondimensional form and the geometry reference.
- property dAj_nd¶
Constant-j face area vectors of a 3D block \(\delta A_j / L_\mathrm{ref}^2\) [-], components on first axis.
See Face areas for the calculation.
- property dAk¶
Constant-k face area vectors of a 3D block \(\delta A_k\) [m^2], shape (ni-1, nj-1, nk, 3).
See
dAk_ndfor the nondimensional form and the geometry reference.
- property dAk_nd¶
Constant-k face area vectors of a 3D block \(\delta A_k / L_\mathrm{ref}^2\) [-], components on first axis.
See Face areas for the calculation.
- 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 dl_min¶
Minimum cell length \(\delta l_\mathrm{min}\) [m], cell array.
See
dl_min_ndfor the nondimensional form and the geometry reference.
- property dl_min_nd¶
Minimum nondimensional cell length \(\delta l_\mathrm{min} / L_\mathrm{ref}\) [-].
See Minimum length scale for the calculation.
- 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 dt_vol_nd¶
Unscaled volumetric time step (dt/vol) per cell, shape (ni-1, nj-1, nk-1).
Persistent scratch buffer, not a cache keyed on the conserved state: the no-key
cached_arrayallocates it once and never invalidates it, so the laggedrfrelaxation in its writer can blend the new value into the previous one. Like every cached property it is read-only to consumers; its writer (ember.grid.Grid.update_timestep()) togglesflags.writeablearound the write (mirrorsF_body_nd).
- 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 ell¶
Anisotropic smoothing length-scale ratios, nodal array of shape (ni, nj, nk, 3).
See Smoothing length scales for the calculation.
- property F_body_nd¶
Cell-volume-integrated body force, shape (ni-1, nj-1, nk-1, 5).
Scratch accumulator, not a cached physical field: it is zeroed and rebuilt every pre-step (viscous + polar + prescribed + SFD). The no-key
cached_arrayallocates the buffer once and never invalidates it. Like every cached property it is read-only to consumers; its owners (Grid.update_sourcesand the FAS coarse-forcing assembly) toggleflags.writeablearound their writes. Components are the cell-volume-integrated source terms(rho, rho*Vx, rho*Vr, rho*r*Vt, rho*E).
- property fluid¶
PerfectFluidobject for equation of state calculations.
- 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}\) [-].
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 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 i_cusp¶
1-based start and end node indices of the cusp patch, (start, end).
Returns (0, 0) if the block has no cusp patches.
- property i_perk¶
1-based (i_LE, i_TE) bounding the k-periodic intervals of an H-mesh.
For a block periodic to itself in k (k=1 coincident with k=nk) over an upstream interval at the leading edge and a downstream interval at the trailing edge, returns the inclusive end i of the upstream interval and the inclusive start i of the downstream interval. These bound the two streamwise ranges (1..i_LE and i_TE..ni) over which the k=1/k=nk faces are periodic to self; in between (the bladed region) they are not.
Derived from k-face PeriodicPatches (const_dim == 2): a patch starting at i=0 sets the upstream end, a patch ending at i=ni-1 sets the downstream start. Returns (0, 0) if the block has no k-face PeriodicPatch.
Cached: patches must not be modified after first access.
- property ijk_wall_conv¶
Per-face wall indicator dict for the convective (inviscid) kernel.
Treats all PERMEABLE_TYPES as non-wall. Keys walli1, wallni, wallj1, wallnj, wallk1, wallnk, each a float32 array (0.0=wall, 1.0=free) for splatting into the inviscid Fortran kernel call (
set_residual()).Cached: patches must not be modified after first access.
- property ijk_wall_visc¶
Per-face wall indicator dict for the viscous kernel.
Like the inviscid
ijk_wall_conv, but treats slip (frictionless) patches as non-wall in addition to all PERMEABLE_TYPES, so slip walls carry zero shear. Keys walli1, wallni, wallj1, wallnj, wallk1, wallnk, each a float32 array (0.0=wall, 1.0=free) for splatting into the viscous Fortran kernel call.Cached: patches must not be modified after first access.
- property L_ref¶
Reference length for non-dimensionalisation \(L_\mathrm{ref}\) [m].
- property label¶
String label describing the block.
- 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 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.
- property mu_turb¶
Turbulent viscosity \(\mu_\mathrm{turb}\) [kg/m/s].
- 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 Omega_wall_nd¶
Per-face wall angular velocity dict (nondimensional).
Keys Omega_walli1_nd, Omega_wallni_nd, etc., each a float32 array of the same shape as the corresponding wall array. Defaults to Omega_nd on all faces; overridden by RotatingPatch faces.
- property P_nd¶
Nondimensional static pressure \(p^*\) [-], nodal array.
\[p^* = \frac{p}{p_\mathrm{ref}}\]
- property P_offset_nd¶
Nondimensional pressure datum for the flux/source kernels [-], scalar.
Mean nondimensional pressure, computed once on first access and then frozen (no data keys, so the cache never invalidates). The flux divergence (residual.f90) and the polar source (polar.f90) both subtract this datum from the pressure, so a uniform offset cancels exactly and only reduces float32 round-off; the converged solution is independent of its value, which is why a fixed datum is fine and recomputing it every iteration would be needless cost. Returned as a 0-d array so it can be locked read-only like other cached properties.
- 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 patches¶
Boundary conditions for the block.
- property pitch¶
Circumferential pitch [rad].
\[\Delta\theta = \frac{2\pi}{N_\mathrm{b}}\]
- property Po¶
Stagnation pressure \(p_0\) [Pa], nodal array.
- property Po_rel¶
Relative-frame stagnation pressure \(p_0^\mathrm{rel}\) [Pa], nodal array.
- 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
_midrather than the_refsuffix 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 residual_nd¶
Unintegrated net-flow residual + body forces, shape (ni-1, nj-1, nk-1, 5).
Sign convention: the residual is the net flux into the control volume (sum of face flows entering minus those leaving) plus body-force sources, i.e. the rate of accumulation \(\mathrm{d}U/\mathrm{d}t\) of each conserved quantity within the cell. It is unintegrated – not yet scaled by the local timestep or cell volume.
Because it points in the direction of accumulation, the increment is added to (never subtracted from) the conserved variables to take a time step:
conserved_nd += cfl * dt_vol_nd * residual_nd
At steady state the residual tends to zero. See
scree.advanceandscree.advance_rk_stage_mgfor the integrators that consume it.
- property rho¶
Mass density \(\rho\) [kg/m^3], 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 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 rpm¶
Reference frame revolutions per minute [rpm]
- property rt¶
Pseudo-Cartesian circumferential coordinate \(r\theta\) [m], nodal array.
- 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.
- property scratch¶
Reusable nodal scratch buffer, shape (ni, nj, nk, 5).
WARNING – PURE TRANSIENT SCRATCH. This is shared, throwaway kernel workspace, NOT a cached value. Its contents are meaningless between kernel calls: every consumer overwrites it on entry and nothing may rely on what it holds after a kernel returns. Do not read it expecting a consistent value; do not stash a reference and assume it survives.
Owned writeable workspace for Fortran kernels that need transient per-node scratch, allocated once and never invalidated. Left writeable (see
scratch_array()), so callers pass it straight to anintent(inout)kernel without togglingflags.writeable. Current consumers (all sequential, none overlapping):viscous face-flux scratch (slots 0-3) in
ember.grid.Grid.update_sources();inviscid
flowbuffer (all 5 slots) inresidual_nd, and the per-step increment buffer inscree.scree_step/scree.advance_rk_stage_mg.
Because nothing persists, each consumer owns the whole buffer for the duration of its own call and may treat it as freshly-allocated private memory – the consumer list above is NOT a claim that the slots carry distinct, coexisting meanings, only a record of who currently borrows it. Two consumers never overlap in time, so the same slots are reused freely.
DO NOT, however, route a second array into the same kernel call that already takes this buffer as scratch, by aliasing it onto this storage. Within one call the kernel reads and writes its scratch slots freely, so any other argument (e.g. an accumulation target) sharing this memory is silently corrupted. Concretely: do not point a kernel’s output/inout argument at
scratchwhile that same call also receivesscratchas its workspace. If you need a transient buffer that must survive alongside this one within a single kernel call or assembly phase, allocate a separate one – do not carve it out ofscratch.
- property sinBeta¶
Sine of pitch angle \(\sin\beta\) [-], nodal array.
\[\sin\beta = \frac{V_r}{V_m}\]
- property store¶
Persistent cross-step solver buffer, nodal shape (ni, nj, nk, 5).
Counterpart to
scratch: a buffer that DOES carry meaning between kernel calls. UNLIKEscratchits value must survive across calls, so no consumer may treat it as throwaway. It is sized to the nodal shape and serves two mutually exclusive scree integrators (selected byScreeConfig.n_stage):Denton lagged march (
n_stage == 0): holds the(dF/dt)_{n-1}term of the scree extrapolation (scree.advance) – written at the end of one step and read at the start of the next. That term is cell-shaped, soadvancetakes a leading(ni-1, nj-1, nk-1, 5)F-order view of this buffer (zero copy) and feeds it toscree_advance.Jameson RK march (
n_stage >= 1): holds the nodal conserved snapshotU^(0)taken at the start of each step; every stage marches off it (scree.advance_rk_stage_mg).
Uses the
scratch_array()mechanism (allocated once, never invalidated, left writeable for theintent(inout)kernel write).Seeded to zeros so the first Denton step is a pure (doubled) forward step, matching multall’s zero-initialised residual history. (The RK path overwrites it with the conserved snapshot before first use.)
- property t¶
Circumferential coordinate \(\theta\) [rad], nodal array.
- property T_nd¶
Nondimensional temperature \(T / T_\mathrm{ref}\) [-].
- 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 tau_q_halo¶
Halo-padded viscous stress / heat-flux scratch, shape (ni+1, nj+1, nk+1, 9).
WARNING – PURE TRANSIENT SCRATCH. This is throwaway kernel workspace, NOT a cached value. Its contents are valid only within a single viscous pass and only in the slots that pass refreshes: the tau/q phase writes the owned cells,
exchange_halosfills the periodic neighbour slots, then the face-flux phase reads them back – all sequentially, within oneember.grid.Grid.update_sources(). Nothing may rely on what it holds after that. (Verified: the viscous force is bit-identical even if the entire buffer is poisoned before the pass, because the pass re-derives every slot it reads.)Unlike
scratch, the slots DO carry coordinated meaning within a single viscous pass: the three sub-steps cooperate on the same data (writer -> halo fill -> reader), so the tau/q layout documented below is real for the duration of that pass. That coordination does not extend beyond the pass – once it ends the buffer is pure private scratch again.Because it carries no state between passes, the flat buffer doubles as the coarse block-sum accumulator and separable-prolong scratch in
scree.advance_rk_stage_mg(see that function’s docstring), where the (i,j,k) layout inside is irrelevant – only the element count matters. Each borrower (a viscous pass, or one RK-stage multigrid call) owns the whole buffer for its own duration and may treat it as freshly-allocated private memory; two borrowers never overlap in time.DO NOT alias a second array onto this storage and pass both into the same kernel call that already takes this buffer (as scratch or as the tau/q workspace): the kernel writes these slots freely, so any other argument sharing the memory is silently corrupted. If you need a buffer that must survive alongside this one, allocate a separate one – do not carve it out of
tau_q_halo.Left writeable (see
scratch_array()), so the viscous passes and the periodic exchange write through it without togglingflags.writeable.- Returns:
Slots 0-5: tau_cell (6 components), slots 6-8: q_cell (3 components). Owned cells occupy indices [1:ni+1, 1:nj+1, 1:nk+1] (0-based), i.e. Fortran indices 2..ni, 2..nj, 2..nk. Halo slots at index 0 and ni (etc.) are reserved for periodic neighbour exchange.
- Return type:
Array, shape (ni+1, nj+1, nk+1, 9)
- 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 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; for the uninitialised-tolerant form see
_u_nd_uninit.
- 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.
- property V¶
Absolute velocity magnitude \(V\) [m/s], 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 Vm_nd¶
Nondimensional meridional velocity magnitude \(V_m^*\) [-].
\[V_m^* = V_m / V_\mathrm{ref}\]
- property vol¶
Volume elements for a 3D block \(\delta \mathcal{V}\) [m^3], cell array.
See
vol_ndfor the nondimensional form and the geometry reference.
- property vol_nd¶
Nondimensional volume elements for a 3D block \(\delta \mathcal{V}^*\) [-], cell array.
\[\delta \mathcal{V}^* = {\delta \mathcal{V}}/{L_\mathrm{ref}^3}\]See Cell volumes for the calculation.
- 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], nodal array of three components.
- property Vxrt_nd¶
Stacked nondimensional polar velocity \(\mathbf{V}/V_\mathrm{ref}\) [-], nodal array of three components.
- 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 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 xlen_sq_nd¶
Mixing-length squared \((\kappa w)^2\) [-], cell-shaped.
The turbulent mixing length is \(\kappa w\) with von Karman constant \(\kappa = 0.41\) and \(w\) the cell-averaged wall distance. Any mixing-length cap is baked into
wdist_ndupstream bycalculate_wdist(), so none is applied here. Cached against thewdistdata key: recomputed only when the wall distance changes.
- property xr¶
Stacked meridional coordinates \((x, r)\) [m, m], nodal array of two components.
- property xrrt¶
Stacked pseudo-Cartesian coordinates \((x, r, r\theta)\) [m, m, m], nodal array of three components.
- property xrt¶
Stacked polar coordinates \((x, r, \theta)\) [m, m, rad], nodal array of three components.
- 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\]
- property cp¶
Specific heat at constant pressure \(c_p\) [J/kg/K], nodal array.
\[c_p = \frac{\partial h}{\partial T}\Bigg|_p\]
- property cv¶
Specific heat at constant volume \(c_v\) [J/kg/K], nodal array.
\[c_v = \frac{\partial u}{\partial T}\Bigg|_\rho\]
- 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 mu¶
Dynamic viscosity \(\mu\) [kg/m/s], nodal array.
- property P¶
Static pressure \(p\) [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 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 T¶
Temperature [K].
- __getitem__(key)¶
Index or slice the spatial axes, returning a view.
Accepts the same index expressions as numpy (integer, slice, or a tuple thereof). Returns a new instance sharing the backing array with the original; writes to raw variables in the result are visible in the original and vice versa. A scalar index on an axis removes that axis (
ndimdecreases by one); a slice preserves it.
- clear_cache()¶
Clear all cached property values.
This forces all cached properties to recalculate on next access.
- empty(shape=())¶
Create a new uninitialised instance with the same metadata.
Returns a fresh object of the same class with all data set to NaN. Metadata is shallow-copied from the original; beware that mutable metadata values are shared.
- Parameters:
shape (tuple, optional) – Shape of the new array. Defaults to scalar.
- Returns:
out – A new uninitialised instance with copied metadata.
- Return type:
same type as
self
- flip(axis)¶
Reverse indexing along the specified axis, not a copy.
Returns a new instance sharing metadata and data with the original via numpy reversed-stride views. Writes through either object are visible in the other.
- Parameters:
axis (int) – Axis along which to reverse indexing.
- Returns:
out – A new instance with reversed indexing along the given axis.
- Return type:
same type as
self
- mean(axis=0, keepdims=False)¶
Calculate mean along specified axis, creating a new object.
- Parameters:
axis (int) – Axis along which to calculate mean. Must be less than ndim. Default is 0 (first spatial dimension).
- Returns:
out (same type as
self) – New object with averaged data along specified axis.The mean is taken over the underlying raw data variables, not derived
properties. Which variables are present depends on the subclass.
- nanmean(axis=0)¶
Calculate nanmean along specified axis, ignoring NaN values.
- Parameters:
axis (int) – Axis along which to calculate nanmean. Must be less than ndim. Default is 0 (first spatial dimension).
- Returns:
out (same type as
self) – New object with averaged data along specified axis, ignoring NaN values.The mean is taken over the underlying raw data variables, not derived
properties. Which variables are present depends on the subclass.
- 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.
- reshape(shape)¶
Reshape the data axes, not a copy.
Returns a new instance sharing metadata with the original. The output data is a zero-copy view where possible (contiguous input); otherwise numpy makes a copy. The total number of spatial points must be unchanged.
- Parameters:
shape (tuple) – New shape. Must contain the same number of elements as the original.
- Returns:
out – A new instance with the specified shape.
- Return type:
same type as
self
- 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 size¶
Total number of spatial points.
- squeeze()¶
Remove singleton axes.
Returns a new instance sharing metadata and data with the original; this is a zero-copy view. Writes through either object are visible in the other.
- Returns:
out – A new instance with all length-1 axes removed.
- Return type:
same type as
self
- transpose(axes=None)¶
Reorder the data axes, defaulting to reversal.
Returns a new instance sharing metadata with the original. The data is a zero-copy view where possible (contiguous input); otherwise numpy makes a copy. Writes through a view are visible in the original.
- Parameters:
axes (tuple, optional) – New order of the axes. If None, the axes order is reversed.
- Returns:
out – A new instance with axes reordered as specified.
- Return type:
same type as
self
- property triangulated¶
Whether the data represents a triangulated mesh.
- view()¶
Create a new view onto the original data, 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 (e.g. writing to a variable 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
- ember.block.memory_usage(block)[source]¶
Return memory usage of a block’s data, metadata, and cached properties.
- Parameters:
block (Block) – The block to measure.
- Returns:
data_usage (dict) – Bytes per data key (equal share of the contiguous _data array).
metadata_usage (dict) – Bytes per metadata key (nbytes for arrays, sys.getsizeof for others).
cache_usage (dict) – Bytes per cached property in _store (nbytes for arrays, sys.getsizeof for others).