Diagnostics

CoarseGrainingEnergyFluxes.Diagnostics.AbstractSpectrumPolicy — Type
AbstractSpectrumPolicy

What to do when a filtering spectral density is asked for with a kernel whose |Ĝ(k)|² is not monotone decreasing — AutoSpectrum, StrictSpectrum, ForceSpectrum or NoSpectrum.

Sadek & Aluie (2018) eq. (21) guarantees Ẽ(k_ℓ) ≥ 0 when d|Ĝ(k)|²/dk ≤ 0, a sufficient condition. TopHatKernel's |Ĝ|² falls to zero at kℓ ≈ 7.66 and rises to 0.0175 at kℓ ≈ 10.27: its violation lies in the sub-filter tail, below 2% of the DC value.

Π and the cumulative energy carry no such condition and are unaffected by this choice.

source
CoarseGrainingEnergyFluxes.Diagnostics.BandWorkspace — Type
BandWorkspace(grid, kernel, scales, w = nothing; maps = nothing, filter_plans = nothing, execution = AutoBackend(),
              mask_strategy = ZeroFill(), method = nothing, vector_filter = nothing, transform = AutoSpectralBackend())

What band_energies! reads and writes on grid for kernel at scales, in ascending order: the sweep's filter plans and those of the fields after the first band, or on a sphere the generalized convolution's transforms; the placement; the running fields and their filtered squares; and the band maps under maps = BandMaps(). w is the vertical velocity the calls will give, or nothing; only its type is read. Keywords as for band_energies.

source
CoarseGrainingEnergyFluxes.Diagnostics.EnergyWorkspace — Type
EnergyWorkspace(grid, batch_size = (), w = nothing; execution = SerialBackend(), vector_filter = nothing,
                transform = AutoSpectralBackend(), nufft = AutoSpectralBackend())

Scratch for the diagnostics that read only the filtered velocity, cumulative_energy! and through it filtering_spectrum, in the memory of execution (see Placement): two buffers, three when w, the vertical velocity or nothing, is an array. Interchangeable with ΠWorkspace wherever only the velocity buffers are used.

On the surface of a sphere it holds the vector filter's transforms as ΠWorkspace does. Under CartesianComponents on a grid of non-Cartesian geometry it also holds the ambient Cartesian components, ux/uy/uz, and all three filtered buffers.

source
CoarseGrainingEnergyFluxes.Diagnostics.FavreWorkspace — Type
FavreWorkspace(grid; execution = SerialBackend())

Scratch for compressible_flux!, in the memory of execution (see Placement): the filtered density and pressure, the Favre velocities, the unweighted velocities, the three Favre stress components, the two unweighted mass-flux components, the four velocity gradients, the two pressure gradients, scratch and product buffers, and the three output fields.

source
CoarseGrainingEnergyFluxes.Diagnostics.HighPass — Type
HighPass()

The cumulative energy of the residual u′_ℓ = u − ū_ℓ, E′(ℓ) = ½⟨|u′_ℓ|²⟩, and its spectrum E′(k_ℓ) = −dE′/dk_ℓ = −(ℓ²/L)⟨u′_ℓ·∂_ℓū_ℓ⟩ (Zhao & Aluie 2025, eqs. 6 and 18). A kernel with p vanishing moments recovers a k^{−α} spectrum for α < 2p + 3: k⁻⁵ for a top-hat or a Gaussian. u is zero on an inactive cell, the value the filter reads there, and the residual's energy is summed over the cells the filtered velocity's is. Where |Ĝ|² is monotone decreasing Ĝ is too, so E′ ≥ 0 wherever the low-pass spectrum is guaranteed non-negative.

References

  • Zhao & Aluie (2025), J. Renewable Sustainable Energy 17, 013303; arXiv:2412.11891.
source
CoarseGrainingEnergyFluxes.Diagnostics.LowPass — Type
LowPass()

The cumulative energy of the filtered velocity, Ē(ℓ) = ½⟨|ū_ℓ|²⟩, and its spectrum Ẽ(k_ℓ) = dĒ/dk_ℓ (Sadek & Aluie 2018, eqs. 14–15). A kernel with p vanishing moments recovers a k^{−α} spectrum for α < p + 2.

source
CoarseGrainingEnergyFluxes.Diagnostics.PiDecomposed3DWorkspace — Type
PiDecomposed3DWorkspace(grid; execution = SerialBackend())

Scratch for the true-3D compute_Π_decomposed!, in the memory of execution (see Placement): the three divergent components, the two filtered velocity triples, six product buffers, the six independent components of each of the three stress tensors and the two strain tensors, and the four flux fields. Tensor components are stored in the order (xx, xy, xz, yy, yz, zz).

source
CoarseGrainingEnergyFluxes.Diagnostics.Placement — Type
Placement(grid; execution = SerialBackend())

Where a diagnostic workspace lives: the local backend its loops run under, and copies of grid, as given and with every cell active, held in that backend's memory. On a sphere or a spheroid it also holds the frame plan (FlowGeometries.Operators.frame_plan) of each copy, which the rotations between the local and the ambient Cartesian frame read; nothing on any other geometry. Under MPIBackend each rank runs its inner backend; a DistributedBackend's caller holds host memory, and runs a device inner backend's loops serially.

source
CoarseGrainingEnergyFluxes.Diagnostics.SeriesStrain — Type
SeriesStrain(gradient, spectra)

The derivative route of a diagnostic whose filtered fields are differentiated from their filter's own series (Derivatives.SpectralDerivative), in the place of a derivative plan; a sweep passes it as deriv_plan once resolved. gradient is the plan's Filtering.series_gradient, and spectra the analyses the diagnostic's filtered fields are synthesized from (Filtering.analyze_buffers for fields of its shape, added as a call asks for more), or nothing where the filter keeps its own. Both hold buffers, so each concurrent caller resolves its own route.

source
CoarseGrainingEnergyFluxes.Diagnostics.Slopes — Type
Slopes()

The slope d ln Ẽ/d ln k_ℓ of the filtering spectrum at each scale. On an exact route of the scale_derivative it is −(2⟨ū·a⟩ + ⟨a·a⟩ + ⟨ū·b⟩)/⟨ū·a⟩ with a = ℓ∂_ℓū and b = ℓ²∂²_ℓū, the filter's second derivative in its width taken as its first is; on the difference route the quadratic through the three nearest scales' ln Ẽ in ln k_ℓ.

source
CoarseGrainingEnergyFluxes.Diagnostics.SpectrumMaps — Type
SpectrumMaps()

The local filtering spectrum Ẽ(x, k_ℓ) = −(ℓ/L) ū·ℓ∂_ℓū at every cell and scale, whose area mean is the filtering spectrum, shaped like Π; with Slopes its slope d ln Ẽ/d ln k_ℓ per cell as well. On the difference route each cell's ½|ū|² differenced across the scales as the spectrum is.

source
CoarseGrainingEnergyFluxes.Diagnostics.SphericalAnalysis — Type
SphericalAnalysis

Marker that ws.ux/uy/uz already hold the ambient Cartesian velocity components for this sweep, for a plan with no forward transform of its own.

The rotation into ambient Cartesian components depends on (u, v, w, grid) alone, and the per-scale path does not write those three buffers, so one rotation serves the whole sweep.

source
CoarseGrainingEnergyFluxes.Diagnostics.SphericalFavreWorkspace — Type
SphericalFavreWorkspace(grid; execution = SerialBackend(), vector_filter = nothing,
                        transform = AutoSpectralBackend(), nufft = AutoSpectralBackend())

Scratch for the spherical compressible_flux!, in the memory of execution (see Placement): the ambient Cartesian velocity, the mass flux and the Favre velocity in those components, six product buffers, the six components of the Favre stress, the local velocity pairs, the resolved strain, the two pressure gradients and the three output fields.

On the surface of a sphere the workspace holds the transforms of the vector filter vector_filter names, as ΠWorkspace does. Under the generalized convolution, the default, it holds no ambient triples, four product buffers and the Favre stress's three local components.

source
CoarseGrainingEnergyFluxes.Diagnostics.SphericalPiDecomposedWorkspace — Type
SphericalPiDecomposedWorkspace(grid; execution = SerialBackend(), vector_filter = nothing,
                               transform = AutoSpectralBackend(), nufft = AutoSpectralBackend())

Scratch for the spherical compute_Π_decomposed!, in the memory of execution (see Placement): the two ambient Cartesian velocity triples and their filtered forms, six product buffers, the six components of each of the three stresses, the local filtered velocity pair of each part, the two strains, and the four flux fields.

On the surface of a sphere the workspace holds the transforms of the vector filter vector_filter names, as ΠWorkspace does. Under the generalized convolution, the default, it holds the divergent tangent pair in place of the ambient triples and their filtered forms, two scratch arrays for the strains, and each stress's three local components.

source
CoarseGrainingEnergyFluxes.Diagnostics.SphericalTracerFluxWorkspace — Type
SphericalTracerFluxWorkspace(grid; execution = SerialBackend(), vector_filter = nothing,
                             transform = AutoSpectralBackend(), nufft = AutoSpectralBackend())

Scratch for the spherical tracer_variance_flux!, in the memory of execution (see Placement): the ambient Cartesian velocity, its filter, the three velocity–tracer products and their filter, the filtered tracer, the local subfilter flux pair and the resolved tracer gradient.

On the surface of a sphere the workspace holds the transforms of the vector filter vector_filter names, as ΠWorkspace does. Under the generalized convolution, the default, it holds the filtered tangent velocity in place of the ambient triples.

source
CoarseGrainingEnergyFluxes.Diagnostics.SpinFilter — Type
SpinFilter

A workspace's Filtering.GeneralizedConvolution on its spherical grid: the spin transforms and the least-squares fit its analysis takes (nothing for the quadrature), a complex field in the workspace's memory, with a host copy where the transforms run on the host and that memory is a device's, five coefficient arrays and one to scale in, the transfer Ĝ(n) of the scale last set, the transfer of a derivative of the filtered field, and the quadrature that computes Ĝ(n).

source
CoarseGrainingEnergyFluxes.Diagnostics.Sym3TauWorkspace — Type
Sym3TauWorkspace(grid; execution = SerialBackend(), vector_filter = nothing, transform = AutoSpectralBackend(),
                 nufft = AutoSpectralBackend())

Scratch for the three-component tau_decomposition!, in the memory of execution (see Placement): a velocity triple and its residual, their filtered and double-filtered forms, six product buffers, and the six independent components of each of L, C and R.

A spherical tangent split returns the first three local components of each tensor and a true-3-D split all six; the rotation to the local frame writes over each tensor's leading slots, and the returned components alias them. On the surface of a sphere the workspace holds the transforms of the vector filter vector_filter names, as ΠWorkspace does; under the generalized convolution, the default, the velocity has its two tangent components, no product buffers are held, and each tensor its three local components.

source
CoarseGrainingEnergyFluxes.Diagnostics._Residual — Type
_Residual(raw, ū, mask, ncell)

The residual u′ = u − ū of a HighPass sweep, formed entry by entry: raw the velocity components as given, read as zero where the input grid's mask is off, ū the filtered components, ncell the cells of one slice, which entry k of a batch-shaped array maps to cell (k − 1) % ncell + 1 of.

source
CoarseGrainingEnergyFluxes.Diagnostics._SeriesRate — Type
_SeriesRate

The rate route of a spectral plan: ∂_ℓū = synth(F̂) − ū · synth(M̂) through each scale's Filtering.rate_plan, M̂ the analysis of a field of ones where the plan divides by a window mass (nothing otherwise); buffers for ∂_ℓū per filtered component, for synth(M̂), and for the velocity's analysis where the sweep holds none; and for the second derivative out2, dM2 (nothing where no slope is asked for).

source
CoarseGrainingEnergyFluxes.Diagnostics._SpectrumOutputs — Type
_SpectrumOutputs(rates, slopes, spectrum_map, slope_map, L, pass)

Where an exact rate route writes a scale, from the filtered velocity ū, a = ℓ∂_ℓū and b = ℓ²∂²_ℓū, with x the velocity the AbstractFilterPass pass names, ū or u′ = u − ū, and σ = ℓ∂_ℓx·a/a·a, 1 for ū and −1 for u′: rates[i] = ⟨x·∂_ℓū⟩, slopes[i] the spectrum's slope d ln Ẽ/d ln k_ℓ = −(2⟨x·a⟩ + σ⟨a·a⟩ + ⟨x·b⟩)/ ⟨x·a⟩, and per cell spectrum_map the local spectrum −(ℓ/L) x·a with slope_map its slope −(2x·a + σa·a + x·b)/ (x·a). A destination left nothing is not computed. i is the scale of a sweep's result, or the slice of a batch's entries at one scale.

source
CoarseGrainingEnergyFluxes.Diagnostics._SpinRate — Type
_SpinRate

The rate route of the generalized convolution: a = ℓ∂_ℓū per filtered component, synthesized with ℓ∂_ℓĜ(n), and b = ℓ²∂²_ℓū with ℓ²∂²_ℓĜ(n) where a slope is asked for (nothing otherwise).

source
CoarseGrainingEnergyFluxes.Diagnostics._WindowRate — Type
_WindowRate

The rate route of a real-space family: each scale's Filtering.scale_rate, giving ℓ∂_ℓū = A − ū·B, and buffers for one rate filter's output per analyzed field, for A per filtered component, and for the second derivative's A (nothing where no slope is asked for).

source
CoarseGrainingEnergyFluxes.Diagnostics.ΠWorkspace — Method
ΠWorkspace(grid, batch_size = (), w = nothing; execution = SerialBackend(), vector_filter = nothing,
           transform = AutoSpectralBackend(), nufft = AutoSpectralBackend())

Scratch for a flux computation, in the memory of execution, whose loops the flux runs under (see Placement). batch_size sizes every buffer as (spatial..., batch...), holding a whole batch of slices at once. w is the vertical velocity the flux will be given, or nothing; only its type is read.

On the surface of a sphere the workspace holds the transforms of the vector filter vector_filter names (Filtering.resolve_vector_filter under ZeroFill): GeneralizedConvolution's spin transforms, chosen by transform and nufft, by default. A plan filtering under Deformable needs vector_filter = Filtering.CartesianComponents().

Only the buffers the configuration reaches are allocated, fixed by the grid, the vector filter and w; the stress τ_* occupies the filtered products' buffers:

configurationfull-size buffers
2-D Cartesian, or a sphere under GeneralizedConvolution, no w12
either with w (the 2.5-D path), or true 3-D Cartesian22
CartesianComponents on another geometry (a sphere, a spheroid, a shell)24

A workspace built for w = nothing throws when given a w. The last row and true-3-D grids always carry the vertical set.

source
CoarseGrainingEnergyFluxes.Diagnostics._derived_plan — Method
_derived_plan(plan, grid, og, kernel, scale) -> plan

The plan for a field the first filter produced, on plan's backend. Under ZeroFill that field is defined at every cell of the output grid og, land included, so it is filtered with every cell active (a Germano moment's second filter reads ū over land); where og holds the same cells as grid, plan serves.

source
CoarseGrainingEnergyFluxes.Diagnostics._flux_setup — Method
_flux_setup(grid, Π, w, workspace, filter_plan, build; execution, mask_strategy, vector_filter, transform)
    -> (workspace, plan)

The workspace a flux runs on, workspace or one built for the vector filter vector_filter resolves to and the batch shape of Π, and the plan it reads (_plan_for); build() builds a plan.

source
CoarseGrainingEnergyFluxes.Diagnostics._pair_moments! — Method
_pair_moments!(Maa, Mab, Mbb, a, b, ā, b̄, pr, plan)

The three generalized second moments of a velocity pair, in the frame the pair is given in:

M(a,a) ,   M(a,b) + M(b,a) ,   M(b,b) ,   M(x,y)_ij = (x_i y_j)‾ − x̄_i ȳ_j .

ā, b̄ are the filtered triples and pr six scratch buffers. The filter is linear, so the cross moment filters the one product a_i b_j + b_i a_j per component.

source
CoarseGrainingEnergyFluxes.Diagnostics._plan_for — Method
_plan_for(spin, filter_plan, strategy, build) -> plan or strategy

The plan a diagnostic on a workspace whose generalized convolution is spin reads: filter_plan when given, otherwise strategy where spin filters every field, which reads no plan, and build() where spin is nothing.

source
CoarseGrainingEnergyFluxes.Diagnostics._rate_fields — Method
_rate_fields(ws, plan, u, v, w) -> (ins, filtered, local, frames)

What a rate reads on a workspace: the fields the plan analyzes, their filtered values, the filtered velocity in the local frame that Ē integrates, and the frames that turn ambient Cartesian components local (nothing on a plane, where the analyzed fields are the velocity's own).

source
CoarseGrainingEnergyFluxes.Diagnostics._rate_route — Method
_rate_route(scale_derivative, kernel, ws, plans, u, v, w, order) -> rate route

How a sweep takes ⟨ū·∂_ℓū⟩ per scale, with the second derivative where order is Filtering.ScaleCurvatures(), resolved once from its plans (or the mask strategy where the workspace's generalized convolution filters): from the generalized convolution's transfer (_SpinRate), from a spectral family's rate plans (_SeriesRate), from a real-space family's rate filters and window masses (_WindowRate), or by differences across the scales (_DifferenceRate).

source
CoarseGrainingEnergyFluxes.Diagnostics._rotate_moments_to_local! — Method
_rotate_moments_to_local!(tensors, frames, ::Val{NC}, be)

Rotate each symmetric ambient Cartesian tensor, its six components in _SYM3 order, into the local frame over its own leading slots: (λλ, λφ, φφ) for NC = 3, a tangent split, and (λλ, λφ, λr, φφ, φr, rr) for NC = 6, a volume. Zero on inactive cells. Each cell reads all six ambient components before it writes; frames is a frame plan held where the backend be runs.

source
CoarseGrainingEnergyFluxes.Diagnostics._sph_pair_moments! — Method
_sph_pair_moments!(Maa, Mab, Mbb, a, b, ā, b̄, pr, plan, frames, be)

The three generalized second moments of an ambient Cartesian velocity pair,

M(a,a) ,   M(a,b) + M(b,a) ,   M(b,b) ,   M(x,y)_ij = (x_i y_j)‾ − x̄_i ȳ_j ,

each rotated from the ambient 3×3 into the local (east, north) frame, over slots 1–3 of its own tensor. ā, b̄ are the filtered triples and pr six scratch buffers; frames is the frame plan of the cells the moments are read on, held where the backend be runs.

source
CoarseGrainingEnergyFluxes.Diagnostics.active_area — Method
active_area(grid) -> T

Total measure of the active cells, FlowGeometries.Grids.covered_area: the denominator of every spatial average here. A ZeroFill output is summed over every cell of the grid, land included, and divided by this water area (Storer et al. 2022); a Deformable one over the active cells.

source
CoarseGrainingEnergyFluxes.Diagnostics.analyze_sweep — Method
analyze_sweep(u, v, w, grid, ws, plan) -> analysis or nothing

Forward-transform the raw inputs of a flux computation once, for reuse across every scale of a sweep.

A spectral filter is analyze → multiply by Ĝ(|k|, ℓ) → synthesize; only the multiply depends on the scale, and every field a flux computation filters (the velocities and their pairwise products) is raw input.

Returns nothing for an engine with no shareable analysis, such as a real-space filter; the caller then runs the per-scale path. plan may be any one of the sweep's per-scale plans; they share a forward transform. On a sphere the workspace's generalized convolution analyzes the velocity and its products, and plan may be the mask strategy alone.

source
CoarseGrainingEnergyFluxes.Diagnostics.band_energies! — Method
band_energies!(ws::BandWorkspace, u, v, w = nothing) -> (; bands, resolved, total, band_maps, resolved_map)

band_energies through ws, which allocates nothing per call beyond the result tuple: the returned arrays are the workspace's own, overwritten by its next call. w is nothing or an array, as the workspace was built for.

source
CoarseGrainingEnergyFluxes.Diagnostics.band_energies — Method
band_energies(u, v, w, grid, kernel, scales; maps=nothing, filter_plans=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=nothing, vector_filter=nothing, transform=AutoSpectralBackend())
    -> (; bands, resolved, total, band_maps, resolved_map)

Split the kinetic energy into contributions from each scale band, using the repeated-filter generalization of the Germano identity.

With scales in ascending order ℓ₁ < ℓ₂ < … < ℓ_N, define the repeatedly filtered fields

f₀ = u ,   f_n = G_{ℓ_n} * f_{n-1} ,

so f_n has had every scale below ℓ_n removed, successively. Band n holds the energy the n-th application removed, which is the generalized second moment at that level:

k_n = ½ τ_{ℓ_n}(f_{n-1}; f_{n-1}) = ½[ (|f_{n-1}|²)‾_{ℓ_n} − |f_n|² ] ,

and the decomposition is exact:

½⟨|u|²⟩ = Σ_{n=1}^N ⟨k_n⟩ + ½⟨|f_N|²⟩ .

The sum telescopes because each ⟨G * x⟩ = ⟨x⟩: the filter conserves the integral over the grid its output is read on. Under ZeroFill every cell of that grid is summed, land included, and divided by the water area, so on a periodic grid, masked or not, the identity holds to the accuracy the discrete kernel conserves its mass. Past a bounded edge the filtered field leaves the grid, and the identity carries a residual, ½ Σₙ (⟨(|f_{n-1}|²)‾⟩ − ⟨|f_{n-1}|²⟩), of order ℓ/L. Deformable renormalizes over the active cells, which does not conserve the integral.

On a grid of non-Cartesian geometry f_n is the filtered velocity compute_Π! uses. On the surface of a sphere vector_filter (Filtering.resolve_vector_filter) filters it: by default the generalized convolution of Aluie (2019), which multiplies the degree-n part of f and of the scalar |f|² by the same Ĝ(n), its spin transforms chosen by transform; it reads no scalar filter plan, and none is built for it. Filtering.CartesianComponents(), and every spheroid, takes the local part of the filtered ambient Cartesian components of f_{n-1} and filters |f|² as a scalar.

The second-moment form has no cross terms between bands (Aluie & Eyink 2009). Under a scalar or Cartesian-component convolution k_n ≥ 0 pointwise iff the kernel is non-negative: use a positive kernel (TopHatKernel, GaussianKernel, SmoothHatKernel, HyperGaussianKernel); a signed one such as Kernels.HighOrderKernel can give negative band energies. The generalized convolution filters the parts of f with the spectrally shifted kernels of its eqs. 59–60, which may take either sign, so its map k_n may too. On the whole sphere its average is proportional to Σ_l (1 − Ĝ(l)²)|f̂_l|² over the degree-l parts f̂_l of f_{n-1}, non-negative when every |Ĝ(l)| ≤ 1, which a non-negative kernel meets.

maps = BandMaps() also returns the N per-band maps in band_maps, which is otherwise nothing; resolved_map is always returned. filter_plans accepts a prebuilt sweep family. The maps live in the memory of the plans' backend, whose loops compute them. A BandWorkspace holds the plans, transforms and buffers for repeated calls on one grid, through band_energies!.

Returns the per-band domain-averaged energies bands (length N), the energy left in f_N (resolved), their sum total, and the corresponding pointwise maps.

References

  • Germano, M. (1992). J. Fluid Mech. 238, eq. (33).
  • Aluie, H., & Eyink, G. L. (2009). Localness of energy cascade in hydrodynamic turbulence. Phys. Fluids 21, 115108, Appendix 2.
source
CoarseGrainingEnergyFluxes.Diagnostics.compressible_flux! — Method
compressible_flux!(ws, u, v, ρ, P, grid, kernel, scale; filter_plan=nothing, deriv_plan=nothing, ...)
    -> (; Π, Λ, pressure_dilatation, ρ̄, P̄, ũ, ṽ)

In-place compressible_flux. Returns views of ws's buffers, valid until the next call on the same workspace. With ws, filter_plan and deriv_plan = derivative_route(grid, filter_plan, u) (derivative_route) supplied, a repeated evaluation allocates no field.

source
CoarseGrainingEnergyFluxes.Diagnostics.compressible_flux! — Method
compressible_flux!(ws::SphericalFavreWorkspace, u, v, ρ, P, grid, kernel, scale; ...)

In-place spherical compressible_flux, by the workspace's vector filter. Returns views of ws's buffers, valid until the next call on the same workspace. The generalized convolution reads no filter plan, and none is built for it when filter_plan is not given.

source
CoarseGrainingEnergyFluxes.Diagnostics.compressible_flux — Method
compressible_flux(u, v, w, ρ, P, grid::StructuredGrid{T,G,3}, kernel, scale; ...)
    -> (; Π, Λ, pressure_dilatation, ρ̄, P̄, ũ, ṽ, w̃)

The variable-density (Favre) budget in a volume: the three terms of the 2-D methods over all six components of the Favre stress and of the resolved strain, vertical derivatives included:

Π = −ρ̄ S̃_ij τ̃(u_i,u_j) ,   Λ = (1/ρ̄) ∂_j P̄ · τ̄(ρ,u_j) ,   P̄ ∇·ū

On a Cartesian volume the components are (x, y, z) as given. On a spherical shell every quantity carrying a direction is filtered in ambient Cartesian components and rotated to the local (east, north, up) frame, and the strain carries the shell's curvature terms. ∇·ū is the trace of the unweighted strain and carries them too.

source
CoarseGrainingEnergyFluxes.Diagnostics.compressible_flux — Method
compressible_flux(u, v, ρ, P, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> (; Π, Λ, pressure_dilatation, ρ̄, P̄, ũ, ṽ)

The variable-density (Favre) cross-scale energy budget of Aluie (2013). Returns the three terms of that budget which act on the large-scale kinetic energy ρ̄|ũ|²/2, plus the filtered fields they are built from.

Favre filtering

f̃ ≡ (ρf)‾/ρ̄ is the density-weighted filter, under which the filtered continuity equation closes exactly, ∂_tρ̄ + ∂_i(ρ̄ũ_i) = 0. It is linear but does not commute with derivatives, and the budget reads both filters.

The three terms

Π = −ρ̄ ∂_j ũ_i τ̃(u_i,u_j) ,   τ̃(u_i,u_j) = (ρu_iu_j)‾/ρ̄ − ũ_iũ_j        deformation work
Λ = (1/ρ̄) ∂_j P̄ · τ̄(ρ,u_j) ,  τ̄(ρ,u_j)   = (ρu_j)‾ − ρ̄ū_j              baropycnal work
                                                                        (τ̄ unweighted)
P̄ ∇·ū                                                                   pressure dilatation

All three are per unit volume, W m⁻³ with ρ in kg m⁻³ and P in Pa; at a constant ρ₀, Π is ρ₀ times the specific flux compute_Π! returns.

Π and Λ pair a large-scale field with small-scale fluctuations and transfer energy across scales. P̄∇·ū involves the large scales alone: a conversion between kinetic and internal energy at the resolved scale. The pressure term takes the unweighted divergence; the form P̄∇·ũ plus a transport term absorbs Λ.

Masked and bounded grids

Under ZeroFill a masked cell and the domain exterior hold no fluid, so ρ̄ is the fluid mass under the kernel: the Favre fields are density-weighted means over the fluid, zero where none lies under the kernel. Constant ρ collapses the budget to ρ·Π wherever the fluid fills the kernel, which under Deformable is every active cell. ρ is read, and must be positive, on active cells only.

Asymptotics

For a smooth field, Lees & Aluie (2019) give Λ ≈ (C₂ℓ²/ρ̄)·c_d·[∇P̄·S̄·∇ρ̄ + ½ ω̄·(∇ρ̄ × ∇P̄)] with C₂ the kernel's second moment: a strain-generation part and a baroclinic part present in solenoidal flow too. Both vanish with C₂, as for the kernels of Kernels.HighOrderKernel.

References

  • Aluie, H. (2013). Scale decomposition in compressible turbulence. Physica D 247, 54–65.
  • Lees, A., & Aluie, H. (2019). Baropycnal work: a mechanism for energy transfer across scales. Fluids 4, 92. doi:10.3390/fluids4020092
source
CoarseGrainingEnergyFluxes.Diagnostics.compressible_flux — Method
compressible_flux(u, v, ρ, P, grid::AbstractGrid{<:SphericalGeometry}, kernel, scale; vector_filter=nothing, transform=AutoSpectralBackend(), ...)
    -> (; Π, Λ, pressure_dilatation, ρ̄, P̄, ũ, ṽ)

Spherical form of the variable-density (Favre) budget, on any grid resolving two tangent directions, with the three terms of the Cartesian method. The vectors u and ρu and the tensor ρu⊗u, from which the Favre velocity ũ, the Favre stress τ̃ and the unweighted subscale mass flux τ̄(ρ,u_j) are built, are filtered by vector_filter (Filtering.resolve_vector_filter). By default that is the generalized convolution of Aluie (2019), whose spin transforms transform chooses; ρ̄ and P̄ are then their spin-0 transforms with the same Ĝ(n), so the budget reads one operator, of global support, and the filter plan is not built. Filtering.CartesianComponents() filters the ambient Cartesian components and rotates them to the local frame, and the filter plan filters ρ and P. The resolved Favre strain and the unweighted divergence carry the local frame's curvature,

∇·ū = ∂ū_e/∂x + ∂v̄_n/∂y − v̄_n tanφ/R ,

the divergence taken as the trace of the unweighted strain.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π! — Method
compute_Π!(Π::AbstractArray{T,3}, u, v, w, grid::StructuredGrid{T,Cartesian,3}, kernel, scale; workspace=nothing, filter_plan=nothing, deriv_plan=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace())

Cross-scale energy flux Π = -S̄ij τij in a Cartesian volume, every strain component from derivatives along all three axes and the mask applied per cell: S̄:τ = S_xx τ_xx + S_yy τ_yy + S_zz τ_zz + 2(S_xy τ_xy + S_xz τ_xz + S_yz τ_yz). A reusable workspace, a ΠWorkspace, serves every call.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π! — Method
compute_Π!(Π::AbstractArray{T,3}, u, v, w, grid::StructuredGrid{T,Spherical,3}, kernel, scale; workspace=nothing, filter_plan=nothing, deriv_plan=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace())

Cross-scale energy flux Π = -S̄ij τij in a spherical shell, the grid's third axis the radius r from the sphere's centre. The velocity is filtered in ambient Cartesian components (Aluie 2019) and rotated back to the local (east, north, up) frame, where, with scale factors h_λ = r cos φ, h_φ = r, h_r = 1,

S_ee = d_λū_e − v̄_n tan φ/r + w̄_r/r
S_nn = d_φv̄_n + w̄_r/r
S_rr = ∂w̄_r/∂r
S_en = ½(d_λv̄_n + d_φū_e + ū_e tan φ/r)
S_er = ½(d_λw̄_r + ∂ū_e/∂r − ū_e/r)
S_nr = ½(d_φw̄_r + ∂v̄_n/∂r − v̄_n/r)

with d_λ = (1/(r cos φ))∂/∂λ and d_φ = (1/r)∂/∂φ at each cell's own radius. A cell on a pole, where cos φ = 0, is zero. A reusable workspace serves every call.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π! — Method
compute_Π!(Π, u, v, w, grid, kernel, scale; workspace=nothing, deriv_plan=nothing, filter_plan=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), vector_filter=nothing, transform=AutoSpectralBackend(), derivative=AutoDerivative(), analyzed=nothing)

Cross-scale kinetic energy flux Π = -S̄ij τij on a grid with no structured axes — a FlowGeometries.Grids.CurvilinearGrid, an UnstructuredGrid or a sphere pixelization — with the physics of the StructuredGrid 2-D method, its vector filter on a sphere included. The grid resolves two tangent directions, or on a Cartesian node set given w three. derivative (Derivatives.AbstractDerivative) takes the strain: by default the derivative of the filter's own series where its output is one (method = Spectral(), and the generalized convolution on a sphere) and the least-squares gradient of Derivatives.derivative_plan otherwise. Fields may carry trailing batch axes past the grid's own. RealSpace() applies the kernel as written, with compact support; a transform's support is global. A prebuilt deriv_plan = Derivatives.derivative_plan(output_grid(grid, mask_strategy)) (see output_grid) and a reusable workspace serve every call of a scale sweep.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π! — Method
compute_Π!(Π, u, v, w, grid, kernel, scale; workspace=nothing, filter_plan=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), vector_filter=nothing, transform=AutoSpectralBackend(), deriv_plan=nothing, derivative=AutoDerivative(), analyzed=nothing)

The cross-scale kinetic energy flux Π = −S̄_ij τ_ij at filter scale scale (Aluie, Hecht & Vallis 2018): positive where energy passes from scales larger than scale to smaller ones.

S̄_ij = ½(∂ū_i/∂x_j + ∂ū_j/∂x_i) is the strain rate of the filtered velocity and τ_ij = (u_i u_j)‾ − ū_i ū_j the subfilter stress. derivative (Derivatives.AbstractDerivative) takes the strain: by default the derivative of the filter's own series where its output is one (method = Spectral(), and the generalized convolution on a sphere) and differences of the filtered field otherwise (a 5-node stencil on a StructuredGrid, the least-squares gradient elsewhere), by deriv_plan when given. On a sphere the velocity ū and the stress (u_i u_j)‾ are filtered by vector_filter (Filtering.resolve_vector_filter): by default the generalized convolution of Aluie (2019) under ZeroFill, which commutes with the surface derivatives, its spin transforms chosen by transform; Filtering.CartesianComponents() filters the ambient Cartesian components and rotates them back to the local frame. vector_filter and transform build the workspace when workspace is not given. The generalized convolution reads no scalar filter plan, and none is built for it when filter_plan is not given.

u and v are the eastward and northward components. A given w is the vertical velocity of a thin layer: S_xz = ½∂w̄/∂x, S_yz = ½∂w̄/∂y and S_zz = 0, with no vertical derivative, the thin-layer scaling of Vallis (2017, §5) and Pedlosky (1987, ch. 6). Vertical structure is this method applied level by level (Aluie, Hecht & Vallis 2018; Buzzicotti et al. 2023), as Pipeline.coarse_grain_profile does; a 3-D grid takes the method that differentiates along all three axes.

Fields may carry trailing batch axes past the grid's two. Under mask_strategy = ZeroFill() the kernel is the same at every position, so filtering commutes with derivatives; Filtering.filter_field! describes each strategy at a boundary. execution, mask_strategy and method build the filter plan when filter_plan is not given. A prebuilt filter_plan, deriv_plan (Derivatives.derivative_plan(output_grid(grid, mask_strategy))) and workspace serve repeated calls; the workspace lives in the memory of the plan's backend (ΠWorkspace) and the flux's own loops run under the workspace's. Π and the fields live there too. analyzed takes a sweep's analyze_sweep result.

Returns Π, the specific flux in m² s⁻³ (velocity in m s⁻¹, lengths in m); ρ₀Π is the flux per unit volume, W m⁻³.

Example

Π = zeros(100, 100)
compute_Π!(Π, u, v, nothing, grid, TopHatKernel(), 30000.0)

References

  • Aluie, Hecht & Vallis (2018), J. Phys. Oceanogr. 48(2): https://doi.org/10.1175/JPO-D-17-0100.1
  • Aluie (2019): https://doi.org/10.1007/s13137-019-0123-9
  • Buzzicotti, Storer, Khatri, Griffies & Aluie (2023), J. Adv. Model. Earth Syst.: https://doi.org/10.1029/2021MS002583
  • Vallis, Atmospheric and Oceanic Fluid Dynamics, 2nd ed., Cambridge University Press, 2017.
  • Pedlosky, Geophysical Fluid Dynamics, 2nd ed., Springer, 1987.
source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π! — Method
compute_Π!(Π::AbstractVector, u, grid::StructuredGrid{T,Cartesian,1}, kernel, scale; workspace=nothing, filter_plan=nothing, deriv_plan=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), derivative=AutoDerivative())

Cross-scale energy flux Π = -S̄xx τxx on a one-dimensional grid, from its single velocity component u, derivative taking S̄_xx as on the plane.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_decomposed! — Method
compute_Π_decomposed!(ws::PiDecomposed3DWorkspace, u, v, w, u_rot, v_rot, w_rot, grid, kernel, scale;
                      filter_plan=nothing, deriv_plan=nothing, ...)
    -> (; total, rotational, cross, divergent)

In-place true-3D compute_Π_decomposed. Returns views of ws's buffers, valid until the next call on the same workspace. With ws, filter_plan and deriv_plan = derivative_route(grid, filter_plan, u) (derivative_route) supplied, a repeated evaluation allocates no field.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_decomposed! — Method
compute_Π_decomposed!(ws::SphericalPiDecomposedWorkspace, u, v, u_rot, v_rot, grid, kernel, scale; ...)
    -> (; total, rotational, cross, divergent)

In-place spherical compute_Π_decomposed, by the workspace's vector filter. Returns views of ws's buffers, valid until the next call on the same workspace. The generalized convolution reads no scalar filter plan, and none is built for it when filter_plan is not given.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_decomposed — Method
compute_Π_decomposed(u, v, w, u_rot, v_rot, w_rot, grid::StructuredGrid{T,<:SphericalGeometry,3}, kernel, scale; ...)
    -> (; total, rotational, cross, divergent)

The rotational/divergent split in a spherical shell. The three stresses are generalized second moments in ambient Cartesian components rotated to the local (east, north, up) frame, and each part's strain carries the shell's curvature terms, so the channels sum to the flux of the volumetric compute_Π!.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_decomposed — Method
compute_Π_decomposed(u, v, u_rot, v_rot, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> (; total, rotational, cross, divergent)

Split the cross-scale flux Π = −S̄:τ on a plane into rotational–rotational Π_RR, divergent–divergent Π_DD and interaction Π_X parts, the last the stimulated-cascade channel of Barkan, Srinivasan & McWilliams (2024), by splitting both sides of the contraction.

(u_rot, v_rot) is the rotational (divergence-free) part of (u, v), and the divergent part is the rest, (u, v) − (u_rot, v_rot). With u = uʳ + uᵈ the strain is linear, S̄ = S̄ʳ + S̄ᵈ, and the stress bilinear, τ(u,u) = τʳʳ + τᵈᵈ + τ_X with τ_X = τ(uʳ,uᵈ) + τ(uᵈ,uʳ), so

Π_RR = −S̄ʳ:τʳʳ
Π_DD = −S̄ᵈ:τᵈᵈ
Π_X  = −(S̄ʳ:τᵈᵈ + S̄ᵈ:τʳʳ + S̄ʳ:τ_X + S̄ᵈ:τ_X)

and Π = Π_RR + Π_X + Π_DD exactly, each channel built from its own terms.

Returns specific flux maps (m² s⁻³): rotational = ΠRR, divergent = ΠDD, cross = Π_X.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_decomposed — Method
compute_Π_decomposed(u, v, u_rot, v_rot, grid::AbstractGrid{<:SphericalGeometry}, kernel, scale; vector_filter=nothing, transform=AutoSpectralBackend(), ...)
    -> (; total, rotational, cross, divergent)

Spherical form of the rotational/divergent split, on any grid resolving two tangent directions, with the channels and the identity Π = Π_RR + Π_X + Π_DD of the planar method. Each part's strain carries the local frame's tanφ/R curvature terms. The stresses τʳʳ, τᵈᵈ and τ_X are generalized second moments under vector_filter (Filtering.resolve_vector_filter): by default the generalized convolution of Aluie (2019), which keeps each filtered part rotational or divergent (Proposition 2) and reads no scalar filter plan, its spin transforms chosen by transform; Filtering.CartesianComponents() forms them in ambient Cartesian components rotated to the local frame.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_strain_convergence! — Method
compute_Π_strain_convergence!(ws, u, v, grid, kernel, scale; filter_plan=nothing, deriv_plan=nothing, ...)
    -> (; total, strain, convergence, divergence, strain_magnitude)

In-place compute_Π_strain_convergence. Returns views of ws's buffers, valid until the next call on the same workspace. With ws, filter_plan and deriv_plan = derivative_route(grid, filter_plan, u) (derivative_route) supplied, a repeated evaluation allocates no field.

source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_strain_convergence — Method
compute_Π_strain_convergence(u, v, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> (; total, strain, convergence, divergence, strain_magnitude)

Split the 2D cross-scale flux into the two production terms of Srinivasan, Barkan & McWilliams (2023), eq. (10), by diagonalizing the filtered strain tensor. With

δ̄   = ū_x + v̄_y            divergence         (rotation invariant)
σ̄_n = ū_x − v̄_y            normal strain
σ̄_s = ū_y + v̄_x            shear strain
ᾱ   = √(σ̄_n² + σ̄_s²)       strain magnitude   (rotation invariant)

the flux separates into

Π = Π_α − Π_δ ,   Π_α = (τ_vv − τ_uu) σ̄_n/2 − τ_uv σ̄_s ,   Π_δ = (τ_vv + τ_uu) δ̄/2 ,

with Π_α the deformation (shear) production, energy transferred by straining, and Π_δ the convergence production, zero for a non-divergent field. Setting δ̄ = 0 recovers Polzin (2010); the equivalent Π = E′(γᵖ ᾱ − δ̄) form with E′ = (τ_vv + τ_uu)/2 recovers Jing et al. (2017), and |γᵖ| ≤ 1 gives the bound |Π_α| ≤ ᾱ E′.

total = Π_α − Π_δ equals the Π = −S̄:τ̄ of compute_Π!: both expand to −τ_uu ū_x − τ_uv(ū_y + v̄_x) − τ_vv v̄_y.

Returns specific flux maps (m² s⁻³) and the two rotation invariants, divergence = δ̄ and strain_magnitude = ᾱ.

References

  • Srinivasan, K., Barkan, R., & McWilliams, J. C. (2023). A forward energy flux at submesoscales driven by frontogenesis. J. Phys. Oceanogr. 53(1), 287–305. doi:10.1175/JPO-D-22-0001.1
source
CoarseGrainingEnergyFluxes.Diagnostics.compute_Π_strain_convergence — Method
compute_Π_strain_convergence(u, v, grid::AbstractGrid{<:SphericalGeometry}, kernel, scale; ...)
    -> (; total, strain, convergence, divergence, strain_magnitude)

Spherical form of the strain/convergence split, on any grid resolving two tangent directions, with the invariants of the local-frame filtered strain:

δ̄ = S̄_ee + S̄_nn        σ̄_n = S̄_ee − S̄_nn        σ̄_s = 2·S̄_en

Π_α − Π_δ = −S̄:τ̄ holds on any metric. S̄ carries the local frame's tan φ/R terms and τ̄ is filtered by vector_filter (Filtering.resolve_vector_filter), the generalized convolution by default; both are those of compute_Π!, so total is its flux. workspace is a ΠWorkspace; vector_filter and transform build it when it is not given.

source
CoarseGrainingEnergyFluxes.Diagnostics.cumulative_energy! — Method
cumulative_energy!(spectrum, u, v, w, grid, kernel, scales; workspace=nothing, filter_plans=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), vector_filter=nothing, transform=AutoSpectralBackend(), pass=LowPass())

In-place cumulative_energy: writes into the caller-supplied spectrum vector and, when workspace (a ΠWorkspace or EnergyWorkspace, in the memory of the plans' backend) is supplied, filters through its buffers.

On a grid of non-Cartesian geometry the filtered velocity is the one compute_Π! uses, and E(ℓ) is the energy of its tangent part (with the radial one when w is given), equal to what coarse_grain reports. On the surface of a sphere vector_filter (Filtering.resolve_vector_filter) filters it: by default the generalized convolution of Aluie (2019), whose spin transforms transform chooses and which reads no scalar filter plan, so none is built when filter_plans is not given. Filtering.CartesianComponents(), and every spheroid, filters the ambient Cartesian components and rotates them back to the local frame. A given workspace carries its own vector filter.

source
CoarseGrainingEnergyFluxes.Diagnostics.cumulative_energy — Method
cumulative_energy(u, v, w, grid, kernel, scales; workspace=nothing, filter_plans=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), vector_filter=nothing, transform=AutoSpectralBackend(), pass=LowPass())

Cumulative coarse-grained kinetic energy E(ℓ) = 0.5 ⟨|ū_ℓ|²⟩ at each filter scale (Sadek & Aluie 2018, PRF, Eq. 15), or under pass = HighPass() the residual's E′(ℓ) = 0.5 ⟨|u − ū_ℓ|²⟩ (Zhao & Aluie 2025, eq. 6; HighPass). The filtering spectral density, comparable to a Fourier energy spectrum, is its derivative with respect to the filtering wavenumber: see Diagnostics.filtering_spectrum. Allocating form of cumulative_energy!.

Examples

scales = collect(10000.0:10000.0:100000.0)  # 10-100 km
E = cumulative_energy(u, v, nothing, grid, TopHatKernel(), scales)
# E[i] is the cumulative coarse KE at scale scales[i]

References

  • Sadek & Aluie (2018), Phys. Rev. Fluids 3, 124610 — extracting the spectrum by filtering.
source
CoarseGrainingEnergyFluxes.Diagnostics.derivative_route — Method
derivative_route(grid, filter_plan, field; derivative = Derivatives.AutoDerivative()) -> deriv_plan

The deriv_plan a diagnostic on grid filtered by filter_plan differentiates by, for fields shaped like field, built once for every call that passes it: under derivative's choice, a derivative plan of output_grid, or for a filter whose output is a series the SeriesStrain route holding the spectra and the gradient synthesis its calls read. A route holds buffers, so each concurrent caller builds its own.

source
CoarseGrainingEnergyFluxes.Diagnostics.energy_from_filtered — Method
energy_from_filtered(ws, plan, has_w, total_area) -> E(ℓ)

E(ℓ) = ½⟨|ū_ℓ|²⟩ read from the filtered velocities already in ws, summed over the active cells of the grid plan's outputs are read on (output_grid) and divided by total_area. Call it after compute_Π! with plan on the same ws, which leaves the filtered velocities there; plan may be the mask strategy that call read in its place.

source
CoarseGrainingEnergyFluxes.Diagnostics.enstrophy_flux! — Method
enstrophy_flux!(Z, ws, u, v, grid, kernel, scale; filter_plan=nothing, deriv_plan=nothing, curl_plan=nothing, ...) -> Z

In-place enstrophy_flux. curl_plan takes the vorticity of (u, v) on grid; deriv_plan differences ω̄ on output_grid. Where the two grids hold the same cells, deriv_plan serves both. With ws and every plan supplied, a repeated evaluation allocates nothing.

source
CoarseGrainingEnergyFluxes.Diagnostics.enstrophy_flux — Method
enstrophy_flux(u, v, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill(), vector_filter=nothing, transform=AutoSpectralBackend()) -> Z

Cross-scale enstrophy flux (Rivera, Aluie & Ecke 2014, eq. 16),

Z_ℓ = −∂_j ω̄_ℓ · τ_ℓ(u_j, ω) ,   τ_j = (u_j ω)‾ − ū_j ω̄ ,   ω = ∂v/∂x − ∂u/∂y ,

the enstrophy analogue of compute_Π!: positive means enstrophy moving to smaller scales.

Gauge

This is the deformation (subtracted) form, the gauge Π uses: the resolved product ū_j ω̄ is subtracted, and the flux is pointwise Galilean-invariant. The unsubtracted −∂_j ω̄ (u_j ω)‾ differs from it by a transport divergence; the two share a spatial mean on a homogeneous domain and "differ qualitatively as well as quantitatively" on an inhomogeneous or masked one (Aluie 2011; Aluie, Hecht & Vallis 2018).

Z is tracer_variance_flux with θ = ω from vorticity!; on a sphere vector_filter and transform choose how it filters the vector u ω. derivative takes ∇ω̄ as the tracer flux takes ∇θ̄. ω differences the unfiltered velocity under every derivative, at its node count: a series of the raw field is exact only for an unmasked periodic band-limited one, and on a masked grid rings at the coast.

References

  • Rivera, M. K., Aluie, H., & Ecke, R. E. (2014). The direct enstrophy cascade of two-dimensional soap film flows. Phys. Fluids 26, 055105. doi:10.1063/1.4873579
source
CoarseGrainingEnergyFluxes.Diagnostics.filtering_spectrum — Method
filtering_spectrum(u, v, w, grid, kernel, scales; L=1, workspace=nothing, filter_plans=nothing, execution=AutoBackend(), mask_strategy=ZeroFill(), method=RealSpace(), vector_filter=nothing, transform=AutoSpectralBackend(), policy=StrictSpectrum(), scale_derivative=AutoScaleDerivative(), pass=LowPass())
    -> (k_ℓ, Ẽ)

Filtering spectral density (Sadek & Aluie 2018, PRF, Eq. 14): the derivative of the cumulative coarse-grained KE (cumulative_energy, Eq. 15) with respect to the filtering wavenumber k_ℓ = L/ℓ,

Ẽ(k_ℓ) = d/dk_ℓ [ ½⟨|ū_ℓ|²⟩ ] = -(ℓ²/L) d/dℓ[ ½⟨|ū_ℓ|²⟩ ].

Under pass = HighPass() it is the spectrum of the residual u′_ℓ = u − ū_ℓ (Zhao & Aluie 2025, eq. 18; HighPass),

E′(k_ℓ) = -d/dk_ℓ [ ½⟨|u′_ℓ|²⟩ ] = (ℓ²/L) d/dℓ[ ½⟨|u′_ℓ|²⟩ ] = -(ℓ²/L)⟨u′_ℓ·∂_ℓū_ℓ⟩.

scales need not be uniform. Returns the filtering wavenumbers k_ℓ and the density Ẽ per scale.

Wavenumber convention

k_ℓ = L/ℓ with L the region length is the Sadek–Aluie convention: in their Fourier series f(x) = Σ_k f̂(k) e^{i(2π/L)k·x}, k is a dimensionless index. The default L = 1 gives k_ℓ = 1/ℓ, the convention of Storer et al. (2022, 2023); L = 2π gives k_ℓ = 2π/ℓ (Rivera, Aluie & Ecke 2014).

Under k_ℓ = C/ℓ the density carries the Jacobian dℓ/dk_ℓ = -ℓ²/C, so Ẽ scales as 1/C and k_ℓ as C: amplitudes and peak locations compare across spectra only under one convention. cumulative_energy is independent of C.

Limits

  • Slope ceiling. Sadek & Aluie eq. (18): a kernel with p vanishing moments recovers a k^{-α} spectrum only for α < p + 2, and otherwise saturates at k^{-(p+2)}. TopHatKernel and GaussianKernel have p = 1, so the measured slope saturates at k⁻³, the enstrophy-range slope of 2-D and QG turbulence. The high-pass spectrum recovers α < 2p + 3 (Zhao & Aluie 2025), k⁻⁵ for these kernels. The flux Π has no such ceiling.
  • Kernel admissibility. Ẽ(k_ℓ) ≥ 0 is guaranteed only when d|Ĝ(k)|²/dk ≤ 0, which also guarantees E′(k_ℓ) ≥ 0. By default this function throws for a kernel that fails it; pass policy = ForceSpectrum() to compute it anyway. See AbstractSpectrumPolicy and Kernels.transfer_monotone.

References

  • Sadek & Aluie (2018), Phys. Rev. Fluids 3, 124610.
  • Zhao & Aluie (2025), J. Renewable Sustainable Energy 17, 013303; arXiv:2412.11891.
source
CoarseGrainingEnergyFluxes.Diagnostics.finish_slopes! — Method
finish_slopes!(outputs, g, k, policy, rate) -> outputs

A outputs's slopes and maps once its density g over the wavenumbers k is filled: NaN under NoSpectrum; on the difference route the slope of ln Ẽ in ln k by the three-point quadratic of spectral_density!, and the spectrum map as dC/dk of each cell's ½|ū|² (−dC/dk of its ½|u′|² under HighPass), its slope likewise; an exact route stored them per scale.

source
CoarseGrainingEnergyFluxes.Diagnostics.output_grid — Method
output_grid(grid, mask_strategy) -> grid
output_grid(grid, plan) -> grid

The grid a filter's outputs are read on. ZeroFill defines the filtered field at every cell, so its outputs are differenced, rotated and contracted with every cell active; under Deformable a masked cell is zero, and the outputs keep the grid's mask. The inputs a filter reads keep the mask either way.

A deriv_plan passed to a diagnostic differences filtered fields, so it is built on this grid: Derivatives.derivative_plan(output_grid(grid, mask_strategy)).

source
CoarseGrainingEnergyFluxes.Diagnostics.spectral_density — Method
spectral_density(C, k) -> dC/dk

Derivative of cumulative values C with respect to k, at each k: the slope of the quadratic through the three nearest points, centred in the interior and one-sided at the ends, so second order on any spacing and exact for a quadratic C(k). Two points give their secant; with fewer there is no derivative, and the result is NaN.

source
CoarseGrainingEnergyFluxes.Diagnostics.tau_decomposition! — Method
tau_decomposition!(ws::Sym3TauWorkspace, u, v, grid, kernel, scale; filter_plan=nothing, derived_plan=nothing, ...)
    -> (; L, C, R)

In-place spherical tau_decomposition, by the workspace's vector filter. Returns views of ws's buffers, valid until the next call on the same workspace. The generalized convolution reads no scalar filter plan, and none is built for it when filter_plan is not given.

source
CoarseGrainingEnergyFluxes.Diagnostics.tau_decomposition! — Method
tau_decomposition!(ws::TauWorkspace, u, v, grid, kernel, scale; filter_plan=nothing, derived_plan=nothing, ...) -> (; L, C, R)

In-place tau_decomposition. Writes into ws and returns views of its component buffers, so the result is valid until the next call on the same workspace. filter_plan filters u and v; derived_plan filters what that produces, which under ZeroFill is defined over land too (see _derived_plan). Supplying both makes a repeated decomposition allocation-free.

source
CoarseGrainingEnergyFluxes.Diagnostics.tau_decomposition — Method
tau_decomposition(u, v, w, grid::StructuredGrid{T,G,3}, kernel, scale; ...) -> (; L, C, R)

True three-dimensional Germano split: the same generalized central moments as the 2-D methods, over all six independent components of the 3×3 subfilter stress. Each tensor comes back as (; xx, xy, xz, yy, yz, zz), and L + C + R = τ holds componentwise.

On a Cartesian metric the components are (x, y, z) as given. On a spherical volumetric shell the moments are formed in ambient Cartesian components and rotated back, so the components are local (east, north, radial).

source
CoarseGrainingEnergyFluxes.Diagnostics.tau_decomposition — Method
tau_decomposition(u, v, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> (; L, C, R)

Split the 2D subfilter-scale stress τ_ij = ⟨u_i u_j⟩ - ū_i ū_j into Leonard, Cross, and Reynolds contributions (Germano 1992, JFM 238); each is a generalized central moment and is Galilean-invariant. With ū = G * u the filtered velocity and u' = u - ū the residual, and the generalized second moment M(f, g) = (fg)‾ - f̄ ḡ:

  • Leonard L_ij = M(ū_i, ū_j) (resolved–resolved),
  • Cross C_ij = M(ū_i, u'_j) + M(u'_i, ū_j),
  • Reynolds R_ij = M(u'_i, u'_j) (subfilter–subfilter; backscatter),

with L + C + R = τ exactly. Returns a named tuple of named tuples, each holding the symmetric 2D components (; xx, xy, yy) as arrays.

source
CoarseGrainingEnergyFluxes.Diagnostics.tau_decomposition — Method
tau_decomposition(u, v, grid::AbstractGrid{<:SphericalGeometry}, kernel, scale; vector_filter=nothing, transform=AutoSpectralBackend(), ...) -> (; L, C, R)

The Germano split on a sphere, on any grid resolving two tangent directions — structured, curvilinear, a scattered node set or a sphere pixelization. The velocity and each product tensor are filtered by vector_filter (Filtering.resolve_vector_filter): by default the generalized convolution of Aluie (2019), whose spin transforms transform chooses and which reads no scalar filter plan. Filtering.CartesianComponents() forms the moments in ambient Cartesian components and rotates each symmetric 3×3 tensor linearly to the local frame. Both filters are linear, so L + C + R = τ holds exactly. Each tensor comes back as its local (; xx, xy, yy) components: east–east, east–north and north–north.

source
CoarseGrainingEnergyFluxes.Diagnostics.tracer_variance_flux — Method
tracer_variance_flux(u, v, w, θ, grid::StructuredGrid{T,G,3}, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> Πθ

The tracer-variance flux in a volume: the subfilter flux has a vertical component τ_z = ⟨wθ⟩ - w̄θ̄, and the resolved gradient ∂_j θ̄ all three components, the vertical derivative included. On a spherical shell the velocity is filtered in ambient Cartesian components and the filtered flux rotated to the local (east, north, up) frame.

source
CoarseGrainingEnergyFluxes.Diagnostics.tracer_variance_flux — Method
tracer_variance_flux(u, v, θ, grid, kernel, scale; execution=AutoBackend(), mask_strategy=ZeroFill())
    -> Πθ

Cross-scale flux of the tracer variance ½⟨θ'²⟩ at filter scale ℓ (the scalar analog of the kinetic energy flux Π; Aluie & Eyink):

Πθ(x) = -∂_j θ̄ · τ_j(u, θ),   τ_j = ⟨u_j θ⟩ - ū_j θ̄  (the subfilter tracer flux),

with the same sign convention as compute_Π!: Πθ > 0 is a forward cascade of tracer variance toward small scales, Πθ < 0 an inverse cascade.

With θ the buoyancy b = -g ρ'/ρ₀ this is the cross-scale transfer of buoyancy variance, tied to available potential energy. This method serves a plane; a sphere and a volume have their own. The result lives in the memory of execution.

source
CoarseGrainingEnergyFluxes.Diagnostics.tracer_variance_flux — Method
tracer_variance_flux(u, v, θ, grid::AbstractGrid{<:SphericalGeometry}, kernel, scale; vector_filter=nothing, transform=AutoSpectralBackend(), ...) -> Πθ

The tracer-variance flux on a sphere, on any grid resolving two tangent directions — structured, curvilinear, a scattered node set or a sphere pixelization. The velocity and the vector uθ of the subfilter flux τ_j = ⟨u_j θ⟩ - ū_j θ̄ are filtered by vector_filter (Filtering.resolve_vector_filter). By default that is the generalized convolution of Aluie (2019), whose spin transforms transform chooses; θ̄ is then their spin-0 transform with the same Ĝ(n), so the flux reads one operator, and the filter plan is not built. Filtering.CartesianComponents() forms τ in ambient Cartesian components and rotates it to the local (east, north) frame, where its radial component drops, and the filter plan filters θ. τ is contracted against ∂_j θ̄.

source
CoarseGrainingEnergyFluxes.Diagnostics.vorticity! — Method
vorticity!(ω, u, v, grid[, deriv_plan]; scratch = nothing, execution = SerialBackend()) -> ω

The vertical component of the relative vorticity on a grid resolving two tangent directions — structured, curvilinear, a scattered node set or a sphere pixelization — zero on masked cells: the curl in the local frame, ∂v/∂x − ∂u/∂y on a plane and

ζ = (1/(R cos φ))[∂v/∂λ − ∂(u cos φ)/∂φ] = ∂v/∂x − ∂u/∂y + u tan φ/R

on a sphere, with ∂/∂x, ∂/∂y derivatives per unit distance. A cell on a pole is zero. scratch is two arrays the size of ω; with it and deriv_plan supplied, a call allocates nothing. The arrays live in the memory of execution, whose loops take the curl; grid and deriv_plan are moved there on each call unless they are there already.

source
CoarseGrainingEnergyFluxes.Filtering.analysis_status — Method
analysis_status(sf::SpinFilter) -> FlowTransformBindings.SolverResult

The worst outcome of the least-squares fits the filter has run since it was built. A filter whose analysis is the quadrature or an exact transform fits nothing and has no method.

source
CoarseGrainingEnergyFluxes.Filtering.worker_copy — Method
worker_copy(ws::ΠWorkspace) -> ΠWorkspace
worker_copy(ws::EnergyWorkspace) -> EnergyWorkspace

A workspace a concurrent worker sweeps on beside ws: the placement's grid copies and frame plans and the generalized convolution's node tables shared; every buffer, and the convolution's transform and fit scratch, its own. Fields that share a buffer in ws share one in the copy.

source