Filtering engines
The real-space engines. The spectral plans are on Spectral plans.
CoarseGrainingEnergyFluxes.Filtering.BandTable — Type
BandTable{VI,VT}The banded engine's taps by band. Band b holds runs ptr[b]:ptr[b+1]-1, and run s covers the consecutive axis-1 offsets di0[s] + t − 1 at axis-2 offset dj[s], with weights w[start[s] + t − 1] for t = 1:(start[s+1] − start[s]).
CoarseGrainingEnergyFluxes.Filtering.BandedScratch — Type
BandedScratch{T,MT,VM} <: AbstractFilterScratchPer-apply buffers for the banded engine: the masked input mask · field, one per field in flight.
Empty on an unmasked grid, where the engine convolves the caller's array directly. Slots are added on demand for a batched apply and reused by later applies.
CoarseGrainingEnergyFluxes.Filtering.FilterFootprint — Type
FilterFootprint{T,BT,MT,SC,MS}Precomputed convolution footprint for a structured grid + kernel + scale whose axis 1 is uniform. The in-support neighbour offsets and their geometric weights w = kernel_weight(distance) * cell_area are held in a BandTable, grouped into axis-2 (y) bands. A Cartesian grid uniform in both directions is translation-invariant, a single band; otherwise the footprint is invariant along axis 1 only, one band per row.
The offsets and weights depend on the geometry alone. invden, the reciprocal window mass, also depends on the mask, the mask strategy and where a domain edge cuts the window; _banded_build_invden accumulates it at plan build.
CoarseGrainingEnergyFluxes.Filtering.ListedBandRows — Type
ListedBandRows(di, dj, w, ptr)Taps already listed by row, ptr[j]:ptr[j+1]-1 for row j, served one row at a time (_row_taps!).
CoarseGrainingEnergyFluxes.Filtering.SphereBandRows — Type
SphereBandRows(grid, kernel, scale, rad)The taps of a sphere of uniform longitude, one latitude row at a time (_row_taps!): each row's window from metric_window, which holds every row its ball reaches (a row nearer a pole spans more longitude at the same radius), as longitude offsets (_banded_lon_offsets) and a latitude half-width, and havλ[k + 1] the sin²(k·dλ/2) of each longitude offset ±k.
CoarseGrainingEnergyFluxes.Filtering._band_table — Method
_band_table(di, dj, w, ptr) -> BandTableThe flat per-tap lists a builder produces (band b's taps ptr[b]:ptr[b+1]-1) grouped into runs: each band's taps ordered by axis-2 then axis-1 offset, a run broken wherever the axis-2 offset changes or the axis-1 offset skips.
CoarseGrainingEnergyFluxes.Filtering._banded_build_invden — Method
_banded_build_invden(grid, taps, nbands, strategy, periodic_x, periodic_y, exterior) -> invdenThe reciprocal window mass, accumulated once per plan by running _banded_row_accumulate! over a mass field:
ZeroFillcounts every in-support tap whether or not its source cell is active, so its mass field is1everywhere, and addsexterior, the mass past a bounded edge: the kernel's full mass. Anexteriorvector is that full mass per row, and is the denominator itself.Deformabledrops inactive cells from both sums, so its mass field is the mask, and an inactive target gets zero.
CoarseGrainingEnergyFluxes.Filtering._banded_cartesian_rows! — Method
_banded_cartesian_rows!(di, dj, w, ptr, grid, kernel, scale, rad) -> nothingOne offset/weight band per row of a Cartesian grid uniform along x and stretched along y, appended to di, dj, w, ptr. A periodic y tiles: a band reaches every row image inside the support, each at its own displacement, and the apply maps a raw row offset back onto the grid with mod1.
CoarseGrainingEnergyFluxes.Filtering._banded_lon_offsets — Method
_banded_lon_offsets(dl, Nx, dλ, periodic) -> NTuple{3,UnitRange{Int}}The longitude offsets a latitude row's taps are drawn from, for a window of dl steps of dλ. A ring contributes each column once: -dl:dl capped at one turn, the antipodal column of an even ring taken from one side. A regional box takes the near offsets |Δi| ≤ dl and the far ones that come back within the window across its seam, |Δi|·|dλ| ≥ 2π − dl·|dλ|, up to Nx − 1; longitude identifies, so the distance between two columns is taken the short way round.
CoarseGrainingEnergyFluxes.Filtering._banded_row_accumulate! — Method
_banded_row_accumulate!(oc, src, taps::BandTable, b, periodic_x, periodic_y, Nx, Ny, j) -> ocAdd output row j's weighted tap sum over band b into oc, the taps of each run by _run_accumulate!. src is mask · field for the numerator at apply time and the mass field for invden at plan build. On a bounded axis 1 a tap covers the columns whose source index stays in range.
CoarseGrainingEnergyFluxes.Filtering._banded_source — Function
_banded_source(fp, field, slot = 1) -> srcThe array the tap loop convolves: on a masked grid the scratch slot slot, which _banded_fill_source! must have filled with mask · field; otherwise field itself.
CoarseGrainingEnergyFluxes.Filtering._banded_unit_mass! — Method
_banded_unit_mass!(den, taps::BandTable, nbands, periodic_x, periodic_y) -> den_banded_row_accumulate! over a mass field of ones, into a zeroed den, from the runs' weights alone. On a periodic axis 1 every target of a row takes every tap, so the row is one sum, added in the order the accumulation adds it. On a bounded axis 1 a target takes the part of each run whose sources stay on the row, a difference of the run's prefix sums. Cost O(taps) per row on a periodic axis 1 and O(runs·Nx) on a bounded one.
CoarseGrainingEnergyFluxes.Filtering._row_taps! — Method
_row_taps!(f, rows, j) -> mass or nothingCall f(di, dj, w) for every tap of latitude row j: its longitude and latitude offsets and weight, the same for every target of the row. Returns the row's whole support mass where the taps leave part of it out (the cells past a bounded latitude), nothing otherwise.
CoarseGrainingEnergyFluxes.Filtering._run_accumulate! — Method
_run_accumulate!(oc, fc, w, k0, k1, d0, periodic, n) -> ococ[i] += w[k] · fc[i + d0 + k] for the taps k0:k1 of one run, tap by tap, each a contiguous pass over the line, wrapped where the line is periodic.
CoarseGrainingEnergyFluxes.Filtering._sphere_band_rows — Method
_sphere_band_rows(grid, kernel, scale, rad) -> (di, dj, w, ptr)The taps of a sphere of uniform longitude by latitude row: row j's entries ptr[j]:ptr[j+1]-1 hold the longitude and latitude offsets of the cells within great-circle distance rad of a target in row j and their weights kernel_weight(d)·area. Uniform longitude makes them the same for every target of a row.
CoarseGrainingEnergyFluxes.Filtering._structured_footprint — Method
_structured_footprint(::Tuple{UniformSpacing,Any}, grid, kernel, scale; mask_strategy = ZeroFill()) -> FilterFootprintThe banded engine, for a 2-D grid whose axis 1 is uniform: constant spacing along axis 1 makes the footprint invariant under a shift along it, so each row of targets shares one offset/weight list. A Cartesian grid uniform in both directions has one list for every row; otherwise each row has its own (nbands = Ny), on a stretched Cartesian y and on any latitude axis of a sphere.
CoarseGrainingEnergyFluxes.Filtering._structured_footprint — Method
_structured_footprint(::Tuple{UniformSpacing,Any}, grid::StructuredGrid{T,<:AbstractSphericalGeometry,2}, kernel::HighOrderKernel, scale; kwargs...)A HighOrderKernel on a latitude–longitude grid of uniform longitude, any latitude axis: the banded engine with one correction per row (_highorder_rows), or the per-cell plan where the targets of a row do not share one.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint! — Method
apply_footprint!(out, field, grid, fp, strategy, periodic_x, periodic_y)Convolve field with a precomputed fp into out, applying the mask strategy. out and field are 2D (a single layer). Periodicity comes from fp; periodic_x/periodic_y are unused.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint_row! — Method
apply_footprint_row!(out, field, grid, fp, strategy, periodic_x, periodic_y, j, sc = nothing)Fill output row j (out[:, j]) from a precomputed footprint, as one contiguous axpy per tap scaled by the plan's invden. Writes every entry of out[:, j] and nothing else, so rows may run concurrently once prepare_row_apply! has run. The banded rows query nothing, so sc is unused.
CoarseGrainingEnergyFluxes.Filtering.prepare_row_apply! — Method
prepare_row_apply!(fp, field, grid) -> nothing
prepare_row_apply_batch!(fp, fields, grid) -> nothingWhole-grid work an engine needs done once before any of its per-row applies run: the banded engine materializes its mask · field source, one slot per field for the batch form; the other engines need nothing. A row-parallel backend calls apply_footprint_row! / apply_footprint_row_batch! directly, so it must call this first.
Call it before opening a parallel region, never inside one: it writes the whole buffer.
CoarseGrainingEnergyFluxes.Filtering.BinnedEdgeCells — Type
BinnedEdgeCells{T,VV,C}A curvilinear mesh's cells under a Kernels.CellOverlap top-hat of radius R, for the binned engine: each point's four cell vertices in bin order (vx, vy, at the point's own image), and the squared radii rin2 = (R − ρ)² within which a cell lies wholly inside the disk and rout2 = (R + ρ)² beyond which it lies wholly outside, ρ the farthest any vertex lies from its cell's centre. A cell between weighs its fraction inside; cache holds those fractions per target in bin order, (ptr, src, frac) with src a point in bin order, or is nothing where an apply computes them.
CoarseGrainingEnergyFluxes.Filtering.BinnedPoints — Type
BinnedPoints{D,T}A Cartesian point set binned on a lattice of nb boxes of widths h from lo, axis 1 fastest: bin b's points are order[ptr[b]:ptr[b+1]-1], and x, measure and mask hold the points in that order. Along a periodic direction the lattice tiles the period, and x is reduced into [lo, lo + period).
CoarseGrainingEnergyFluxes.Filtering.BinnedTopHatPlan — Type
BinnedTopHatPlan{D,T}The top-hat of radius rad over a BinnedPoints set: per offset lines[q] of a line of bins across axes 2…D, the half-widths win[q] of its run of bins inside the ball for any target in the bin (-1 for none) and wout[q] of the bins that may reach it; the per-apply buffers, one (values, scan, sums) triple per field in flight (the weighted values in bin order, the compensated scan of the bin totals along axis 1, and each target's window sum in bin order), added on demand by a batched apply; and invden, the reciprocal window mass under strategy per point in the grid's order, zero where the window is empty or, under Deformable, the target inactive. bound is whether the two strategies' denominators differ, which they do on a masked grid. edge is nothing where each point counts by the centre test (a node set, or a mesh under Kernels.CellCentre), the BinnedEdgeCells of a mesh under CellOverlap.
CoarseGrainingEnergyFluxes.Filtering._binned_csr — Method
_binned_csr(grid, kernel, scale, backend) -> (nbrs, w, ptr)Every cell's neighbours within kernel_radius of a Cartesian point set and their weights, kernel_weight · measure, as CSR in the grid's order, read from its BinnedPoints: a target's candidates are the points of the bins i₀ ± w_out of each line of bins within reach, one run per image of the line. Every image of a cell across a periodic direction within the radius is its own entry at its own distance. One pass counts each row and the next fills it, blocks of bins running on backend.
CoarseGrainingEnergyFluxes.Filtering._binned_lines — Method
_binned_lines(h, rin, rout) -> (lines, win, wout)The offsets o across axes 2…D of the lines of bins a ball of radius rout about a point of bin (i₀, J₀) reaches, with win, the largest |i − i₀| of a bin of line J₀ + o wholly inside radius rin from any point of bin (i₀, J₀) (-1 when none is), and wout, the largest of a bin with a point within rout of one. A box offset by k bins of width h along a direction is between max(|k| − 1, 0)·h and (|k| + 1)·h from another.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint! — Method
apply_footprint!(out, field, grid, fp::BinnedTopHatPlan, strategy, driver = _sep_serial) -> out
_driven_batch!(outs, fields, grid, fp::BinnedTopHatPlan, strategy, driver = _sep_serial) -> outsThe top-hat of field at every cell, or of each field of a batch in one sweep that finds every target's lines and partial points once for all of them: the weighted values and their scans, then each target's window sums over the reciprocal mass. driver runs blocks of bins under _sep_serial's contract.
CoarseGrainingEnergyFluxes.Filtering.binned_tophat_plan — Method
binned_tophat_plan(grid, kernel::TopHatKernel, scale; mask_strategy = ZeroFill(), execution = SerialBackend())
-> BinnedTopHatPlanThe binned top-hat over the cells of a Cartesian grid with no lattice of its own, a node set or a curvilinear mesh: the same sum as its neighbour-list engine, over the cells whose centres lie within kernel_radius of the target's, each image of a cell across a periodic direction at its own distance. The window masses are built on execution's threads.
CoarseGrainingEnergyFluxes.Filtering.binned_tophat_plan — Method
binned_tophat_plan(grid::CurvilinearGrid, kernel::TopHatKernel{CellOverlap}, scale; mask_strategy, cache_strategy,
execution)The binned top-hat over a Cartesian curvilinear mesh, each cell weighted by its area inside the disk: bins wholly within R − ρ of every target in a bin add as runs, points within R − ρ count whole, and the cells whose centres lie within ρ of the disk's edge take their polygon's fraction inside (BinnedEdgeCells), held per target where cache_strategy keeps them. ZeroFill divides by the disk's area, the mesh having no lattice past its edge. The window masses and the held fractions are built on execution's threads.
CoarseGrainingEnergyFluxes.Filtering._exterior_lattice — Method
_exterior_lattice(grid, rad; cap = true) -> (ext, lo, extended) or nothinggrid's lattice continued past each bounded edge far enough to hold every exterior cell within rad of a cell of grid, as a grid of the same geometry and closure; lo[d] exterior cells precede the grid's own along direction d, and extended[d] says whether direction d gained any.
cap = false continues each direction by the rows centred on its lattice only, leaving out the cap row between an end face and the pole.
CoarseGrainingEnergyFluxes.Filtering._exterior_mass — Method
_exterior_mass(grid, kernel, scale, execution = SerialBackend()) -> Array or nothingΣ kernel_weight(d) · measure over the exterior cells within the kernel's radius of each cell of grid, or nothing when no cell reaches past a bounded edge; rows are divided among execution's threads where it has them.
CoarseGrainingEnergyFluxes.Filtering._reaches_exterior — Method
_reaches_exterior(grid, kernel, scale) -> BoolWhether the lattice continues past a bounded edge of grid within the kernel's reach, in which case ZeroFill and Deformable divide by different masses even on an unmasked grid. true whenever a window can leave the grid, so a strategy check built on it never accepts a mismatch.
CoarseGrainingEnergyFluxes.Filtering.RadialWeights — Type
RadialWeights{D,K,T}A radial kernel's weight on a cell: kernel_weight(d) in D dimensions times the cell measure.
CoarseGrainingEnergyFluxes.Filtering.ScatteredCache — Type
ScatteredCache{T}The full per-target neighbour list for a ScatteredFilterPlan, built only when the plan's AbstractCacheStrategy calls for it: each neighbour's weight, and its linear cell index ii + (jj − 1)·Nx (the periodic wrap resolved) as runs of consecutive indices. Target t = i + (j−1)·Nx holds runs rptr[t]:rptr[t+1]−1 and weights wptr[t]:wptr[t+1]−1, run r the cells start[r] + (0:len[r]−1) in the order the weights list them. A cell index is an Int32; a grid of more cells raises at build.
CoarseGrainingEnergyFluxes.Filtering.ScatteredFilterPlan — Type
ScatteredFilterPlan{T,K}Cell-by-cell real-space plan for a 2-D StructuredGrid the banded FilterFootprint does not cover, or a CurvilinearGrid. A target's neighbours are the cells within rad that the grid's ball query returns through topology; di_lim/dj_lim bound that query's index window. cache holds them as a ScatteredCache when the plan's AbstractCacheStrategy builds one, and is nothing when the apply recomputes them. weights is the rule a cell's weight comes from, RadialWeights or HighOrderWeights.
CoarseGrainingEnergyFluxes.Filtering._MassOnly — Type
_MassOnly{T}(dims)The field a cell-by-cell engine applies over to write each target's window mass: its loops pass their sums to _emit, which returns the summed weight for it and the weighted mean for any other field. Its values are never read into the output.
CoarseGrainingEnergyFluxes.Filtering._build_footprint_curvilinear — Method
_build_footprint_curvilinear(grid, kernel, scale; cache_strategy = AlwaysCache()) -> ScatteredFilterPlanThe ScatteredFilterPlan of a FlowGeometries.Grids.CurvilinearGrid, with its cache when cache_strategy calls for one. di_lim/dj_lim are the index window the smallest adjacent-node spacing in each direction implies. Other keywords are ignored, as in _build_footprint_scattered.
CoarseGrainingEnergyFluxes.Filtering._build_footprint_scattered — Method
_build_footprint_scattered(grid, kernel, scale; cache_strategy = AlwaysCache()) -> ScatteredFilterPlanThe ScatteredFilterPlan of a 2-D StructuredGrid of any spacing and geometry, with a ScatteredCache when cache_strategy calls for one. Other keywords, mask_strategy among them, are ignored: the plan takes its mask strategy at apply time.
CoarseGrainingEnergyFluxes.Filtering._cache_entries — Method
_cache_entries(count, strategy) -> Union{Int,Nothing}The number of entries a neighbour cache holds, count(), the entries the cache build's ball query yields; or nothing when the plan streams.
CoarseGrainingEnergyFluxes.Filtering._cell_weight — Method
_cell_weight(rule, grid, t, I, J, d) -> (inside::Bool, w)Cell J's weight about target I, whose linear index is t and distance d, under a RadialWeights or HighOrderWeights rule. inside is false, and w zero, for a cell outside a HighOrderKernel's support box.
CoarseGrainingEnergyFluxes.Filtering._query_radius — Method
_query_radius(grid, kernel, scale) -> TThe radius a cell-by-cell engine queries about each target: the kernel's truncation radius, and for a HighOrderKernel the radius of the ball holding every cell that meets its support.
CoarseGrainingEnergyFluxes.Filtering._rule_fold — Method
_rule_fold(f, acc, rule, grid, t, I, rad, mt, sc) -> accFold acc = f(acc, J, w) over the cells the plan's weight rule reaches about target I (linear index t), w cell J's weight: through the grid's ball query of radius rad for a RadialWeights or HighOrderWeights rule, by the support's own walk for an OverlapWeights one.
CoarseGrainingEnergyFluxes.Filtering._scattered_window_bounds — Method
_scattered_window_bounds(grid::StructuredGrid{...,2}, rad) -> (di_lim, dj_lim, periodic_x, periodic_y, x_period, y_period)The widest index window the grid's ball query scans, from Connectivity.metric_window, with the periodic flags and the Cartesian wrap lengths. On a rectilinear grid the window depends on the row alone, so one evaluation per row covers the grid.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint! — Method
apply_footprint!(out, field, grid, fp::ScatteredFilterPlan, strategy, periodic_x, periodic_y)Whole-grid convolve using a ScatteredFilterPlan, the engine for nonuniform-axis and curvilinear grids. Periodicity comes from fp; periodic_x/periodic_y are unused.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint_row! — Method
apply_footprint_row!(out, field, grid, fp::ScatteredFilterPlan, strategy, periodic_x, periodic_y, j, sc = row_scratch(fp))Fill output row j from a ScatteredFilterPlan: if fp.cache !== nothing, read the precomputed per-point neighbour list (linear cell indices, periodic wrap resolved at build time); otherwise recompute each point's neighbours and weights through the grid's ball query, the enumeration the cache was built from, reusing sc. A target the strategy skips is left unwritten.
CoarseGrainingEnergyFluxes.Filtering.build_footprint — Method
build_footprint(grid::CurvilinearGrid, kernel, scale; kwargs...) -> ScatteredFilterPlanReal-space direct-sum footprint for a curvilinear grid (see _build_footprint_curvilinear).
CoarseGrainingEnergyFluxes.Filtering.build_footprint — Method
build_footprint(grid::StructuredGrid, kernel, scale; kwargs...)The real-space footprint of a structured grid, chosen by the spacing of its directions (FlowGeometries.Grids.spacing_trait, a periodic direction's wrap included), its geometry and the kernel: a uniform direction 1 takes the engines shared along it, and the cell-by-cell plan takes what no more specific engine covers.
CoarseGrainingEnergyFluxes.Filtering.row_scratch — Method
row_scratch(fp) -> scratch or nothingThe candidate buffer a row apply's ball queries reuse, the last argument of apply_footprint_row! and apply_footprint_row_batch!: one per concurrent worker. nothing for an engine whose rows query nothing.
CoarseGrainingEnergyFluxes.Filtering.HighOrderBandRows — Type
HighOrderBandRowsA latitude–longitude grid's corrected weights by row over lat, the grid itself or its continued lattice, whose cell I + lo is grid cell I; mt is the topology its folds use, dls and djls each row's index half-widths, and sinλ, havλ the sin Δλ and sin²(Δλ/2) of each longitude offset Δi ≥ 0, at Δi + 1, in the correction's promote_type(T, Float64).
CoarseGrainingEnergyFluxes.Filtering.HighOrderScratch — Type
HighOrderScratchOne target's support cells — index, normal coordinates (in W = promote_type(T, Float64)), measure, weight, whether the cell lies past a bounded edge, and whether it stands for its mirror image too — with the correction's moment matrix G = Σ A φφᵀ, its right-hand side r (then its solution), the solve's work vector y and pivot order piv, and a block of cells' basis values φ, Aφ and weights w̃ the sums run over (_HO_BLOCK rows), all in W.
CoarseGrainingEnergyFluxes.Filtering.HighOrderWeights — Type
HighOrderWeights{P,D,T,K,C,S}A HighOrderKernel{P}'s weight on a cell about target t, in D normal coordinates under the support S: the kernel's mean over the cell plus the target's correction Σᵢ coeffs[i, t] φᵢ(e/half), times the cell measure.
CoarseGrainingEnergyFluxes.Filtering.ProductSupport — Type
ProductSupportThe form of Sadek & Aluie (2018), G(e₁)⋯G(e_D) over the plane's own axes. A cell is taken as a box of its extents; off a rectilinear grid, the cube of its measure.
CoarseGrainingEnergyFluxes.Filtering.RadialSupport — Type
RadialSupport{L,T}The isotropic form, G(|e|) with limb amplitudes amps. A cell is taken as the ball of its measure.
CoarseGrainingEnergyFluxes.Filtering._highorder_band_rows — Method
_highorder_band_rows(grid, kernel, scale) -> HighOrderBandRows or nothing_highorder_rows' corrections one latitude row at a time (_row_taps!); nothing where the targets of a row do not share one.
CoarseGrainingEnergyFluxes.Filtering._highorder_rows — Method
_highorder_rows(grid, kernel, scale) -> (di, dj, w, ptr, mass) or nothingA latitude–longitude grid's weights by row, in the banded layout: row j's entries ptr[j]:ptr[j+1]-1 hold the longitude and latitude offsets and the weights of the in-grid cells, and mass[j] the whole support's, the continued lattice included. nothing where the targets of a row do not share one correction (_highorder_shares_rows).
CoarseGrainingEnergyFluxes.Filtering._highorder_shares_rows — Method
_highorder_shares_rows(grid, kernel, scale) -> BoolWhether every target of a latitude row sees the same cells at the same offsets, so one correction serves the row: on a ring of uniform longitude, and on a regional box of uniform longitude, continued around the ring, while no support reaches the seam where the continuation closes.
CoarseGrainingEnergyFluxes.Filtering._highorder_targets — Method
_highorder_targets(grid, kernel, scale, rad, fold, scratch, lattice, keep, stream, execution) -> (weights, exterior, kept)The correction about every cell of grid. fold(f, acc, I, sc) folds f(acc, J, d) over the grid's cells within rad of cell I with the query buffer sc, one per task from scratch(); lattice is _ho_lattice's. Returns the HighOrderWeights, holding each cell's coefficients where stream (a plan that forms its weights at every apply) and none otherwise, the mass past a bounded edge per cell (or nothing), and where keep every cell's in-grid neighbours and weights as (ids, w, ptr) in fold order, ids the neighbours' Int32 linear indices among the grid's cells, else nothing. The targets are divided among execution's threads: a first pass counts each target's in-grid cells, the second corrects each target and writes its entries from its offset.
CoarseGrainingEnergyFluxes.Filtering._ho_correct! — Method
_ho_correct!(s, kernel, ℓ, h) -> cCorrect the recorded cells' weights w̃ in place to wₖ = w̃ₖ + Aₖ p(eₖ/h), with p = Σ cᵢ φᵢ the polynomial that keeps the total and zeroes every moment of order 1…P, and return c: one pass sums the moment matrix and right-hand side block by block, a second adds the correction.
CoarseGrainingEnergyFluxes.Filtering._ho_correct! — Method
_ho_correct!(s, kernel, ℓ, h, ix) -> cThe correction over the polynomials ix (indices into _ho_exponents), each recorded cell counted _ho_multiplicity times; c[i] is polynomial ix[i]'s coefficient.
CoarseGrainingEnergyFluxes.Filtering._ho_exponents — Method
_ho_exponents(Val(D), Val(P)) -> NTupleThe exponents (a₁, …, a_D) with Σ aᵢ ≤ P, the constant first: one per tensor Legendre polynomial of total degree at most P.
CoarseGrainingEnergyFluxes.Filtering._ho_lattice — Method
_ho_lattice(grid, rad) -> (ext, lo, extended, topology) or nothinggrid's lattice continued past each bounded edge (_exterior_lattice), with the ball-query topology its folds use.
CoarseGrainingEnergyFluxes.Filtering._ho_multiplicity — Method
_ho_multiplicity(s, c, W) -> WHow many cells recorded cell c stands for: 2 where it is marked as standing for its mirror image too, else 1.
CoarseGrainingEnergyFluxes.Filtering.FilterFootprintND — Type
FilterFootprintND{N,T}Translation-invariant footprint of a 1-D or 3-D Cartesian grid with uniform axes: the in-support neighbour offsets (NTuple{N,Int}) and their weights w = kernel_weight(distance) · cell_measure, which a device applies point by point, and the same taps as LineRuns, which the host applies as one contiguous axpy per tap along axis 1; both sum a point's taps in the order offsets lists them. invden is the reciprocal window mass under strategy, ZeroFill's including the mass past a bounded edge (_exterior_mass); it is zero where the window is empty or, under Deformable, the target inactive.
CoarseGrainingEnergyFluxes.Filtering.LineRuns — Type
LineRuns{M,VO,VI,VT}The taps of a translation-invariant footprint in M + 1 dimensions by line: run s covers the consecutive axis-1 offsets di0[s] + t − 1 at offsets tail[s] along axes 2…M+1, with weights w[start[s] + t − 1] for t = 1:(start[s+1] − start[s]).
CoarseGrainingEnergyFluxes.Filtering.SeparableFootprintND — Type
SeparableFootprintND{N,T}A separable kernel in N dimensions: one weight table per axis, applied as N successive 1-D passes, ∑(2wᵈ+1) multiply-adds per point.
Weight tables follow _sepw: a vector where the axis is uniform, an Nᵈ × (2wᵈ+1) matrix where it is stretched.
CoarseGrainingEnergyFluxes.Filtering._drive_pass! — Method
_drive_pass!(f, driver, indices, dst)
_drive_pointwise!(f, driver, indices)A separable pass's sweep under driver, f(I) writing line I of dst, and the normalization's pointwise sweep, which reads and writes its output in place. Both call driver(f, indices); a driver that divides a pass among processes defines its own methods, assembling dst on each.
CoarseGrainingEnergyFluxes.Filtering._nd_out_line! — Method
_nd_out_line!(out, src, fp::FilterFootprintND, J) -> nothingOutput line J (out[:, J...]) from the source _nd_source! returned, scaled by the reciprocal window mass. Writes that line alone, so lines may run concurrently.
CoarseGrainingEnergyFluxes.Filtering._nd_source! — Method
_nd_source!(fp::FilterFootprintND, field, grid) -> srcThe array the line sweep reads: on a masked grid the plan's buffer, filled with mask · field; otherwise field itself. Call it before the lines run.
CoarseGrainingEnergyFluxes.Filtering._sep_serial — Method
_sep_serial(f, indices)The default pass driver: apply f to every index in order. A substitute driver may call f on the indices in any order or concurrently, and must return once every call has completed; each call writes its own outputs, so the result is bit-identical.
CoarseGrainingEnergyFluxes.Filtering.apply_separable_nd! — Method
apply_separable_nd!(out, field, grid, fp, strategy, driver = _sep_serial, buffers = _sep_nd_buffers(fp, out, Val(R)), lines = nothing)Filter field into out: the R separable passes, then the pointwise normalization. driver runs each pass's index sweep under _sep_serial's contract. strategy must match the footprint's wherever the two strategies' denominators differ (fp.bound). With lines, a block of the lines along axis 1 in their linear order, every pass but the last covers the whole grid and the last pass and the normalization write those lines alone.
out and field may carry trailing batch axes beyond the grid's rank R; each pass covers the whole batch, through buffers, two arrays of out's shape. The profiles, the renormalization array and the mask are indexed by the leading R components of the driven index.
CoarseGrainingEnergyFluxes.Filtering.NodeFilterPlan — Type
NodeFilterPlan{T}Real-space filter footprint for a node set: per-node CSR neighbour blocks (nbrs, w, offsets ptr) with their geometric weights w = kernel_weight(d) · control volume, found once at plan time, in the plan's node order: a point cloud's space-filling order, its node s the grid's node perm[s], so a row's neighbours lie near it in memory; the grid's own (perm nothing) where its ids follow space, as a pixelization's do. A host apply reads the field and the mask into that order once (vals, act) and writes each node's result to its own id.
Each node's block includes the node itself, which Connectivity.neighbors_within leaves out. A neighbour is an Int32 node index; a node set of more nodes raises at build.
CoarseGrainingEnergyFluxes.Filtering._sphere_csr — Method
_sphere_csr(grid, kernel, scale, backend) -> (nbrs, w, ptr)A spherical flat-cell grid's list, read from bins of its points embedded in three dimensions (_binned_csr): the ball of great-circle radius r on the sphere of radius R is the chord ball of radius 2R sin(r/2R), and a neighbour a chord c away lies 2R asin(c/2R) along the sphere. A bin's side is the largest of the mean spacing, half the chord radius and 2R/128, so the lattice over the sphere's bounding cube holds at most 128³ bins.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint! — Method
apply_footprint!(out, field, grid, fp::NodeFilterPlan, strategy) -> outWeighted mean over each node's stored neighbourhood, with the same two mask conventions the structured engines use: ZeroFill keeps a masked neighbour in the denominator, contributes nothing for it and filters a masked node too; Deformable drops it from both sums and leaves a masked node at zero.
CoarseGrainingEnergyFluxes.Filtering.build_footprint — Method
build_footprint(grid, kernel, scale; kwargs...) -> NodeFilterPlanReal-space footprint for a flat-cell grid (see _is_flat_cell): every cell's neighbours within kernel_radius and their weights. A Cartesian node set's are read from its bins (_binned_csr), each image of a cell across a periodic direction at its own distance; any other grid's come from Connectivity.fold_within, the grid's own metric ball query on the cell list Connectivity.default_sweep_topology returns, so the neighbourhood follows the geometry's distance and periodic wrap. Raises for a grid whose cells are an index tuple and that no rectilinear or curvilinear engine matches.
CoarseGrainingEnergyFluxes.Filtering.CapOverlap — Type
CapOverlap{F,N}The support of a top-hat on a sphere: the cap of angular radius θ, with the Gauss–Legendre nodes its cell fractions integrate by (Geometry.cap_cell_fraction).
CoarseGrainingEnergyFluxes.Filtering.GeodesicBand — Type
GeodesicBand{F,D}A source row seen from a target row on a spheroid: its latitude faces lo < hi and the target's geodesic disk. line marks a grid of one row.
CoarseGrainingEnergyFluxes.Filtering.GeodesicOverlap — Type
GeodesicOverlap{F,N}The support of a top-hat on a spheroid of equatorial radius a and flattening f: the geodesic disk of radius R (the whole surface where whole), with the Gauss–Legendre nodes its cell fractions integrate by (Geometry.geodesic_cell_fraction).
CoarseGrainingEnergyFluxes.Filtering.OverlapBand — Type
OverlapBand{F}A source row seen from a target row: its faces lo < hi along axis 2 (relative to the target on a plane, latitudes on a sphere) and the target's axis-2 coordinate t (zero on a plane, its latitude on a sphere). line marks a grid of one row, whose cells are segments of it.
CoarseGrainingEnergyFluxes.Filtering.OverlapPolygons — Type
OverlapPolygons{O,F,M}A Kernels.CellOverlap top-hat's weights on a 2-D CurvilinearGrid, cell by cell: the support ov, the cell-vertex coordinates xc, yc (one larger than the grid in each direction; the grid's own, or FlowGeometries' reconstruction from the centres), the ball radius reach a query needs to find every cell the support touches (R plus the farthest any cell's vertex lies from its centre), and each coordinate's period (zero where it does not wrap), by which a cell is taken at its image nearest the target.
CoarseGrainingEnergyFluxes.Filtering.OverlapShells — Type
OverlapShells{F,VF,N,B}A Kernels.CellOverlap top-hat's weights on a 3-D spherical or spheroidal StructuredGrid, whose distance is the chord: the ball of radius R about the target, and each cell the region between its longitude, latitude and third-direction faces (latitude faces clamped at the poles), inside it with the Gauss–Legendre nodes: a sphere's radius sector by Geometry.shell_cell_fraction (body nothing, radius faces clamped at the origin), a spheroid's geodetic cell of heights by Geometry.geodetic_cell_fraction (body its equatorial radius and squared eccentricity). reach, R plus the farthest any cell's corner lies from its centre, is the ball a query needs to find every cell the support touches.
CoarseGrainingEnergyFluxes.Filtering.OverlapWeights — Type
OverlapWeights{O,F,VF}A Kernels.CellOverlap top-hat's weights on a 2-D StructuredGrid, cell by cell: the support ov, each row's target (_overlap_target), each direction's cell faces and centres, and its closure. A periodic Cartesian direction tiles (tiles_x, tiles_y, its images each counted, shifted by s·m·p, s the coordinate's sign along the index); a periodic longitude is a ring (ring_x), each cell once; a regional longitude box (box_x) reaches the cells across its seam the short way round.
CoarseGrainingEnergyFluxes.Filtering.OverlapWeightsND — Type
OverlapWeightsND{N,O,F,VF}A Kernels.CellOverlap top-hat's weights on a 1-D or 3-D Cartesian StructuredGrid, or a sphere's single ring of longitude, cell by cell: the support ov, each direction's cell faces and centres, and its closure. A periodic Cartesian direction tiles (tiles, its images each counted, shifted by sgn·m·period); a periodic longitude is a ring (ring), each cell once; a regional longitude (box) reaches the cells across its seam the short way round.
CoarseGrainingEnergyFluxes.Filtering.PlanarOverlap — Type
PlanarOverlap{F,N}The support of a top-hat on a Cartesian grid: the segment, disk or ball of radius R, with the Gauss–Legendre nodes a ball's cell fractions integrate by (Geometry.ball_box_fraction).
CoarseGrainingEnergyFluxes.Filtering._cell_faces — Method
_cell_faces(grid, d, F) -> Vector{F}The N + 1 faces of direction d's cells, as FlowGeometries places them; a sphere's latitude faces clamped at the poles.
CoarseGrainingEnergyFluxes.Filtering._cell_fraction — Method
_cell_fraction(ov, band, xa, xb, line_x) -> FThe fraction inside the support of the cell spanning [xa, xb] along axis 1 (relative to the target) within band. line_x marks a grid of one column, whose cells are segments along axis 2 at the target's own axis-1 position.
CoarseGrainingEnergyFluxes.Filtering._full_support — Method
_full_support(grid, kernel, scale) -> BoolWhether ZeroFill divides by the support's measure: a Kernels.CellOverlap top-hat on a grid where a window leaves it, whose cells past the edge, weighted by their overlap, complete the support exactly.
CoarseGrainingEnergyFluxes.Filtering._lattice_fraction — Method
_lattice_fraction(ov::PlanarOverlap, o, Δ) -> FThe fraction inside the support of the cell at lattice offset o of a uniform Cartesian grid of steps Δ.
CoarseGrainingEnergyFluxes.Filtering._overlap_exterior — Method
_overlap_exterior(grid, r::OverlapWeights, kernel, scale) -> Matrix or nothingThe mass past the grid's edges under ZeroFill: the support's measure less the weights a target's window sums over the grid's own cells, where a window leaves the grid; nothing where none does.
CoarseGrainingEnergyFluxes.Filtering._overlap_fold — Method
_overlap_fold(f, acc, r::OverlapWeights, grid, i, j) -> accFold acc = f(acc, J, w) over every cell J the support about target (i, j) reaches, w its measure times its fraction inside. Rows are taken outward from the target's until one lies wholly outside, and within each the cells outward from the target's column until one does: on a convex support symmetric about the target, a cell's fraction falls as it moves away.
CoarseGrainingEnergyFluxes.Filtering._overlap_fold_nd — Method
_overlap_fold_nd(f, acc, r::OverlapWeightsND, grid, I) -> accFold acc = f(acc, J, w) over every cell J the support about target I reaches, w its measure times its fraction inside. Each direction, from the last, is taken outward from the target until a slab's nearest point lies at the support's radius, counting the directions already fixed; on a ball symmetric about the target the slabs only grow farther.
CoarseGrainingEnergyFluxes.Filtering._overlap_target — Method
_overlap_target(ov, t)What the support's fractions about a target at axis-2 coordinate t read: t itself, or on a spheroid the geodesic disk about latitude t (Geometry.geodesic_disk), built once per target row from the edge points of FlowGeometries' direct geodesic problem.
CoarseGrainingEnergyFluxes.Filtering._overlap_walk — Method
_overlap_walk(g, acc, r::OverlapWeightsND, I, Val(d), r2) -> accDirection d's slabs about target I, outward from the target's own, acc = g(acc, ii, (a, b), r2′) for each whose nearest point lies within the support given the squared distance r2 the directions already fixed contribute: cell ii, its faces a < b relative to the target, and r2′ that distance with this slab's added.
CoarseGrainingEnergyFluxes.Filtering._support_mass — Method
_support_mass(ov, line_x, line_y, target) -> FThe support's measure in the grid's units, the mass ZeroFill divides by where a window leaves the grid: the disk πR², or 2R along a single resolved direction (a missing direction's cells have unit width); the cap 4πa² sin²(θ/2), the arc 2w·a cos t of a circle of latitude t, or the meridian's span within the cap; a spheroid's geodesic disk, its arc along the target's parallel, or its meridian's span within it.
CoarseGrainingEnergyFluxes.Filtering.CompensatedScan — Type
CompensatedScan{T,A}A prefix scan held as two tables: hi, the floating-point running sum, and lo, the running sum of the exact rounding error of each addition, so entry k is hi[k] + lo[k] to about twice T's precision (Ogita, Rump & Oishi, SIAM J. Sci. Comput. 26 (2005), Algorithm 4.4, Sum2). A difference of two entries, _scan_diff, is then as accurate as summing the interval directly, whatever the row length or the mean of the data.
CoarseGrainingEnergyFluxes.Filtering.PrefixEdgeCells — Type
PrefixEdgeCells{VI,VT,MI}The cells the support of a Kernels.CellOverlap top-hat cuts, for a plan whose axis 1 is uniform. Row j's taps ptr[j]:ptr[j+1]-1 hold an axis-1 offset di, a raw axis-2 offset dj and w = f·wy, f the cell's fraction inside the support, which multiplies the cell's scanned value mask·field·wx. far[b, j] is the least axis-1 offset from which every cell across a regional longitude box's seam lies wholly inside, 0 where none does. Axis-1 offsets count along the scan's ascending order (rev: the coordinates descend), and modulo the axis's length where it closes on itself (wrap).
CoarseGrainingEnergyFluxes.Filtering.PrefixSumGridPlan — Type
PrefixSumGridPlan{T,VT,PW,DT,BT,WX,WY,MS} <: AbstractGridPlanThe scale-independent part of the prefix-sum top-hat engine: everything fixed by the grid, its mask and the mask strategy. One instance serves every scale of a sweep.
Holds the separable measure factors (wx,wy), the axis-1 coordinates in ascending order, and the two measure scans the window mass is formed from: prefix_wx of wx along axis 1 (ZeroFill), and prefix_den of mask·wx per row (Deformable on a masked grid, nothing otherwise). Every scan holds one copy of the axis. Where axis 1 wraps (tiles_x || rings_x), the two-pointer sweep walks an extended axis of three copies shifted by −P, 0, +P, so a wrapped support interval is one contiguous run: entry c·Nx + t is xe[t] + (c − 1)·P, and its scan entry c row totals plus the scan's entry t (_walk_band).
CoarseGrainingEnergyFluxes.Filtering.PrefixSumScratch — Type
PrefixSumScratch{T,S,VS,VV} <: AbstractFilterScratchThe prefix-sum engine's per-apply buffers: one CompensatedScan of mask·field·wx per field in flight, and under Kernels.CellOverlap the cells' values mask·field·wx themselves in the scan's order (cell_values, nothing under CellCentre), which the cells the disk's edge cuts read. Every apply refills them, so one set serves every scale of a sweep, one apply at a time. Each row is written independently, so the numerator fill may run concurrently by row.
A single-field apply uses slot 1, a batched apply of K fields slots 1:K; _prefixsum_numerators! adds missing slots.
CoarseGrainingEnergyFluxes.Filtering.PrefixSumTopHatPlan — Type
PrefixSumTopHatPlan{T,GP,SC,MT,WT,RM}Exact O(N·dj_lim) top-hat footprint for a rectilinear 2D StructuredGrid, holding the state that depends on the filter scale ℓ. grid_plan and scratch may be shared with the other scales of a sweep.
invden: the reciprocal window mass per point, a function of the grid, the mask, the strategy and ℓ.hw/wcell: underKernels.CellCentre, the support half-width per(band, row)and, on a uniform ascending axis, the constant cell half-width it implies; underKernels.CellOverlap,hw ≥ 0marks a band holding cells wholly inside the support andwcellthe half-width, in cells, of those about the target.edge:nothingunderCellCentre, thePrefixEdgeCellsunderCellOverlap.
invden is built for one mask strategy: where the two strategies normalize differently (bound), the apply throws unless its strategy has the type of grid_plan.strategy.
CoarseGrainingEnergyFluxes.Filtering._build_prefixsum_grid_plan — Method
_build_prefixsum_grid_plan(grid; mask_strategy = ZeroFill()) -> PrefixSumGridPlanBuild the scale-independent half of the prefix-sum top-hat engine. Nothing here reads the filter scale, so one call serves an entire sweep — see plan_filter_sweep.
CoarseGrainingEnergyFluxes.Filtering._build_prefixsum_tophat — Method
_build_prefixsum_tophat(grid, kernel::TopHatKernel, scale; mask_strategy=ZeroFill(), grid_plan=nothing, scratch=nothing,
execution=SerialBackend(), kwargs...) -> PrefixSumTopHatPlanBuild the exact O(N·dj_lim) prefix-sum top-hat plan for one scale, its window masses on execution's threads. grid_plan/scratch let a sweep hand in the shared pieces; omitted, they are built here. A given grid_plan fixes the mask strategy, and mask_strategy is then unused. kwargs... absorbs and ignores cache_strategy.
CoarseGrainingEnergyFluxes.Filtering._build_prefixsum_tophat — Method
_build_prefixsum_tophat(grid, kernel::TopHatKernel{CellOverlap}, scale; ...) -> PrefixSumTopHatPlanThe prefix-sum top-hat with each cell weighted by its fraction inside the support, on a grid whose axis 1 is uniform: per (band, row) the integer half-width of the cells wholly inside about the target (by its scan interval) and, across a regional longitude box's seam, the offset from which they are; per target row, the cells the support's boundary cuts as PrefixEdgeCells taps. A band's fractions are symmetric in the axis-1 offset, and fall from one to zero as it grows. ZeroFill divides by the support's measure (_support_mass) where a window leaves the grid, and by the summed weights elsewhere. The rows' cut cells and window masses are built on execution's threads.
CoarseGrainingEnergyFluxes.Filtering._overlap_band_rows — Method
_overlap_band_rows(grid, kernel::TopHatKernel{CellOverlap}, scale) -> (di, dj, w, ptr)Every tap of a CellOverlap top-hat on a 2-D grid of uniform axis 1, by target row: row j's entries ptr[j]:ptr[j+1]-1 hold the axis-1 and axis-2 offsets of each cell the support about a target in row j reaches and its weight measure · f. The same for every target of a row, as _sphere_band_rows's.
CoarseGrainingEnergyFluxes.Filtering._overlap_row_sum! — Method
_overlap_row_sum!(oc, Pn, V, fp, edge, j, Nx, Ny) -> ocAdd target row j's weighted sums under a PrefixEdgeCells plan into oc, the row in the scan's ascending order: per band, the cells wholly inside about the target and across a regional seam from the scan Pn, then the cells the disk's edge cuts from their values V. The device sweep adds in this order.
CoarseGrainingEnergyFluxes.Filtering._prefixsum_batch_fuses — Method
_prefixsum_batch_fuses(fp) -> BoolWhether a batched apply shares one support walk across its fields: true unless every band is constant-width (fp.uniform_axis), where no band has a walk to share.
CoarseGrainingEnergyFluxes.Filtering._prefixsum_build_invden — Method
_prefixsum_build_invden(grid, gp, dj_lim, hw, wcell, exterior, execution) -> invdenThe reciprocal window mass per point, zero where the mass is zero, its rows split among the build's threads (_build_share). ZeroFill adds exterior, the mass past a bounded edge, and keeps every target; Deformable counts active cells only and gives an inactive target zero, so the apply's epilogue is one multiply.
CoarseGrainingEnergyFluxes.Filtering._prefixsum_numerators! — Method
_prefixsum_numerators!(sc, K) -> sc.prefix_numsGrow sc to at least K numerator slots (and cell-value slots, where held) and return them. A new slot is a zeroed similar of slot 1, since the fill never writes row 1, the empty prefix. Call it before any parallel region that uses the slots: growing push!es.
CoarseGrainingEnergyFluxes.Filtering._prefixsum_scratch — Method
_prefixsum_scratch(gp::PrefixSumGridPlan, grid, kernel) -> PrefixSumScratchAllocate the engine's per-apply numerator scan, and under Kernels.CellOverlap the cell values. Sized by the grid alone, so one scratch serves every scale — but only one apply at a time; see AbstractFilterScratch.
CoarseGrainingEnergyFluxes.Filtering._rectilinear_measure_factors — Method
_rectilinear_measure_factors(grid) -> (wx, wy)The grid's stored per-axis measure factors, with measure[i, j] == wx[i] * wy[j] exactly, including on a degenerate direction: a single-latitude grid measures arc length R·Δλ and a single-longitude one R·Δφ. Throws an ArgumentError on a dense measure.
CoarseGrainingEnergyFluxes.Filtering._structured_footprint — Method
_structured_footprint(::Tuple, grid::StructuredGrid{T,<:AbstractGeometry,2}, kernel::TopHatKernel, scale; kwargs...)The top-hat on a rectilinear 2D StructuredGrid; keywords as for _build_prefixsum_tophat. Under Kernels.CellCentre, the prefix-sum engine at any spacing. Under Kernels.CellOverlap, the prefix-sum engine with its edge where axis 1 is uniform, so a row's cut cells are the same about every target, and the cell-by-cell plan with the overlap rule otherwise.
CoarseGrainingEnergyFluxes.Filtering._walk_band — Method
_walk_band(f, xe, src, x, wraps, P, a, c, Nx)The two-pointer sweep of one band: for each target i = src[t] in ascending coordinate order whose interval [x[i] − a, x[i] + c] holds an entry of the extended axis, f(i, n, hi, lo) with the run's sum _wrap_sum(Ph, Pl, n, hi, lo, Nx, …). Each pointer holds its copy and entry, so the extended axis is never stored; entry t of copy k lies at xe[t] + _copy_shift(wraps, k, P).
CoarseGrainingEnergyFluxes.Filtering.apply_footprint! — Method
apply_footprint!(out, field, grid, fp::PrefixSumTopHatPlan, strategy, periodic_x, periodic_y) -> outWhole-grid convolve with a prefix-sum plan, as apply_prefixsum_tophat!. periodic_x/periodic_y are unused: the plan fixes periodicity, and the matching extended coordinates, from the grid at build time.
CoarseGrainingEnergyFluxes.Filtering.apply_prefixsum_tophat! — Method
apply_prefixsum_tophat!(out, field, grid, fp, strategy) -> outWhole-grid exact top-hat convolve: one O(N) prefix-sum pass over the field, then one O(N·dj_lim) two-pointer sweep.
CoarseGrainingEnergyFluxes.Filtering.apply_prefixsum_tophat_batch! — Method
apply_prefixsum_tophat_batch!(outs, fields, grid, fp, strategy) -> outsWhole-grid batched top-hat convolve: one prefix scan per field, then a single sweep that walks each support interval once and feeds every field from it. Where _prefixsum_batch_fuses is false, each field is applied on its own.
CoarseGrainingEnergyFluxes.Filtering.apply_prefixsum_tophat_batch_row! — Method
apply_prefixsum_tophat_batch_row!(outs, grid, fp, strategy, j) -> outsFill row j of every output in a batch from the per-field prefix scans, which prefixsum_fill_numerator_batch! must have filled. Where fp.uniform_axis, each field runs the single-field row body; otherwise each band's two-pointer walk runs once and feeds every field. Writes only row j of each output.
CoarseGrainingEnergyFluxes.Filtering.apply_prefixsum_tophat_row! — Method
apply_prefixsum_tophat_row!(out, grid, fp, strategy, j) -> outFill output row j from the prefix scans, which prefixsum_fill_numerator! must have filled for the current field. For each band, two monotone pointers sweep axis 1 in O(1) amortized per point, so the row costs O(Nx·dj_lim). Writes only row j of out, so rows may run concurrently.
This sums the numerator only and scales it by the per-scale reciprocal window mass fp.invden.
CoarseGrainingEnergyFluxes.Filtering.prefixsum_fill_numerator! — Method
prefixsum_fill_numerator!(fp, field, grid)Refill the scratch numerator scan (cumulative mask·field·wx along each row) from field, in O(N). Must run before any apply_prefixsum_tophat_row! call for that field.
CoarseGrainingEnergyFluxes.Filtering.prefixsum_fill_numerator_batch_row! — Method
prefixsum_fill_numerator_batch_row!(fp, fields, grid, j)Fill row j's numerator scan for every field of a batch, one slot each. Writes only column j of each slot, so it may run concurrently across j once _prefixsum_numerators! has grown the slots.
CoarseGrainingEnergyFluxes.Filtering.prefixsum_fill_numerator_row! — Method
prefixsum_fill_numerator_row!(fp, field, grid, j)Fill row j's numerator prefix scan. Writes only column j of the scratch, so it may run concurrently across j.
CoarseGrainingEnergyFluxes.Filtering.PrefixEdgeCells3D — Type
PrefixEdgeCells3D{VO,VT}The cells the support of a Kernels.CellOverlap top-hat cuts on a uniform 3-D grid: tap s at offset offsets[s] with weight w[s], the cell's fraction inside the support, applied to the cell's scanned value.
CoarseGrainingEnergyFluxes.Filtering.PrefixSum3DScratch — Type
PrefixSum3DScratch{T,A,VV} <: AbstractFilterScratchThe 3-D top-hat engine's per-apply buffers: the axis-1 CompensatedScan of mask · field, sized (Nx+1, Ny, Nz), and the cells' values mask · field (cell_values, Nx × Ny × Nz), which the cells the ball's boundary cuts read; nothing under Kernels.CellCentre. Refilled at the start of every apply.
CoarseGrainingEnergyFluxes.Filtering.PrefixSumTopHat3DPlan — Type
PrefixSumTopHat3DPlan{T,SC,A,WT,MS,RM}Exact O(N·w_y·w_z) top-hat footprint for a uniform 3-D Cartesian StructuredGrid.
wcell is the (2·dj_lim+1) × (2·dk_lim+1) table of the ball's axis-1 half-width at each offset (dj, dk), -1 where that slice is empty; on a uniform grid it is the same at every point. Under Kernels.CellOverlap it is the half-width of the cells wholly inside, and edge the PrefixEdgeCells3D of those the boundary cuts; nothing under Kernels.CellCentre.
invden is the reciprocal window mass, built once per scale under strategy.
CoarseGrainingEnergyFluxes.Filtering._build_prefixsum_tophat_3d — Method
_build_prefixsum_tophat_3d(grid, kernel::TopHatKernel{CellOverlap}, scale; ...) -> PrefixSumTopHat3DPlanThe 3-D prefix-sum top-hat with each cell weighted by its fraction inside the ball: per (dj, dk) the half-width of the cells wholly inside about the target, and a tap for every cell the ball's boundary cuts. ZeroFill divides by the ball's measure where a window leaves the grid, and by the summed weights elsewhere. The window masses are built on execution's threads.
CoarseGrainingEnergyFluxes.Filtering._prefixsum3d_fill_plane! — Method
_prefixsum3d_fill_plane!(sc, src, grid, masked, j, k) -> nothingCompensated scan along axis 1 of src for one (j, k) plane into sc.prefix, with entry 1 the empty prefix, and the plane's values into sc.cell_values where it holds them. Writes only that plane, so planes may be filled concurrently.
CoarseGrainingEnergyFluxes.Filtering._prefixsum3d_out_plane! — Method
_prefixsum3d_out_plane!(out, fp, j, k) -> nothingOutput plane (j, k) from the scan fp.scratch.prefix already holds, scaled by the reciprocal window mass. Writes only that plane, so planes may run concurrently.
CoarseGrainingEnergyFluxes.Filtering.NDRingCache — Type
NDRingCache{N, T}The neighbour lists of an NDScatteredFilterPlan whose targets along a uniform periodic direction 1 share their cells and weights: one list per index of the other directions, about the target in column 1. Target (i, J...) reads cell (mod1(i + c₁ − 1, dims[1]), c₂, …) for each stored cell c, c₁ ∈ 1:dims[1].
CoarseGrainingEnergyFluxes.Filtering.NDScatteredCache — Type
NDScatteredCache{N, T}The full per-target-point neighbour list for an NDScatteredFilterPlan, built only when the plan's AbstractCacheStrategy calls for it: each neighbour's weight, and its linear cell index in the grid of size dims as runs of consecutive indices, as ScatteredCache holds them. Target t = LinearIndices(dims)[I] holds runs rptr[t]:rptr[t+1]−1 and weights wptr[t]:wptr[t+1]−1. A cell index is an Int32; a grid of more cells raises at build.
CoarseGrainingEnergyFluxes.Filtering.NDScatteredFilterPlan — Type
NDScatteredFilterPlan{N, T, K, C, MT}N-D (1D or 3D) analog of ScatteredFilterPlan, for a grid with no translation-invariant footprint, such as one with a plain AbstractVector axis: the kernel, the support radius, the per-axis index window lim at the worst cell, and the grid's ball-query topology. cache holds the NDScatteredCache, or the NDRingCache of a shell on a uniform ring, when the plan's cache strategy builds one, nothing otherwise (apply-time recomputation). exterior is the mass past a bounded edge that ZeroFill adds to each point's denominator, or nothing. weights is the rule a cell's weight comes from, RadialWeights or HighOrderWeights.
CoarseGrainingEnergyFluxes.Filtering._nd_rule_fold — Method
_nd_rule_fold(f, acc, rule, grid, t, Ti, rad, mt) -> accThe N-D _rule_fold: acc = f(acc, J, w) over the cells rule reaches about target Ti (linear index t), through the grid's ball query or, for an OverlapWeightsND rule, the support's own walk.
CoarseGrainingEnergyFluxes.Filtering._shell_parts — Method
_shell_parts(grid, rule::OverlapShells, rad, mt, strategy, exterior::Bool) -> (cache, exterior)A shell's neighbour cache (nothing where the plan streams) and, where exterior, the ball's volume less each target's summed weights, every cell's fraction computed once. Along a uniform direction 1 a target's cells and weights are its row and level's shifted along it: a periodic ring keeps one list per (row, level) about column 1, an NDRingCache; a bounded axis one table of offsets per (row, level), from the folds about its two end columns, each target reading the offsets that stay on the grid. Any other shell folds each target once.
CoarseGrainingEnergyFluxes.Filtering.SeparableFootprint — Type
SeparableFootprint{T}Per-axis kernel weight tables (gx, gy, read through _sepw), the denominator, and the scratch buffers of the two-pass separable convolution.
The denominator is invrenorm for Deformable on a masked grid: the reciprocal kernel mass over active cells, the same two-pass convolution applied to the mask. Otherwise it is the outer product of Nx_profile and Ny_profile: ZeroFill counts the offsets in the domain and past a bounded edge, Deformable on a fully active grid only those in the domain. Whether an offset lies in the domain depends on i and j separately, so the profiles are rank-1.
Each axis is truncated at rad on its own, so the window is a square. For the Gaussian it differs from the disk-truncated engines by weights below the truncation tolerance of kernel_radius.
CoarseGrainingEnergyFluxes.Filtering.SeparableScratch — Type
SeparableScratch{T,MT} <: AbstractFilterScratchThe separable engine's two pass buffers: the masked input, and the intermediate the row pass writes and the column pass reads.
Sized by the grid alone, so one set serves every scale of a sweep. One set serves one apply at a time, so a driver running applies concurrently needs one per worker.
CoarseGrainingEnergyFluxes.Filtering._build_separable_footprint — Method
_build_separable_footprint(sp, grid, kernel::SeparableKernel, scale; mask_strategy=ZeroFill(), scratch=nothing, kwargs...) -> SeparableFootprintBuild the per-axis weight tables for the spacing tuple sp, the denominator for mask_strategy, and the pass buffers of the separable engine. A given scratch, a SeparableScratch, supplies the buffers. kwargs... absorbs and ignores cache_strategy.
CoarseGrainingEnergyFluxes.Filtering._separable_axis_weights — Method
_separable_axis_weights(spacing, x, lim, periodic, period, kernel, scale, wfac) -> AbstractVecOrMatA separable kernel's per-axis weight table, Kernels.profile_cell_average over the stencil, in the layout _sepw reads, for a direction of spacing trait spacing (Grids.spacing_trait, a periodic direction's wrap included). Serves the Gaussian and Kernels.HighOrderKernel.
Uniform direction: the displacement is ddi·Δ at every position, so one vector serves them all. Otherwise an n × (2·lim+1) table, one stencil per position, each weight times the neighbour's width.
lim comes from the smallest gap on the axis, so on a stretched axis a coarse region's stencil has slots past rad, holding the kernel's negligible or zero tail. A periodic displacement includes the image shift, so each image of a cell counts at its own distance.
CoarseGrainingEnergyFluxes.Filtering._separable_profile — Method
_separable_profile(x, lim, g, periodic, kernel, scale, wfac, exterior) -> profileThe denominator profile along one axis: Σ w over the stencil's in-domain offsets at each index and, with exterior, over the offsets past a bounded edge too, on the lattice continued at its edge gap. wfac is the axis's cell widths, the measure factor _separable_axis_weights was given.
CoarseGrainingEnergyFluxes.Filtering._separable_tables — Method
_separable_tables(sp, grid, kernel::SeparableKernel, scale) -> (; g, lim, periodic, mf)The separable engines' per-axis weight tables g (_separable_axis_weights) by the spacing tuple sp (_with_spacings) and stencil half-widths lim, from the smallest gap on each axis so the stencil covers the kernel's radius everywhere, with each axis's periodicity and the grid's measure factors mf. Axis d takes the profile of Kernels._axis_kernel(kernel, Val(d)).
CoarseGrainingEnergyFluxes.Filtering._sepw — Method
_sepw(g, i, k) -> TWeight of stencil slot k at axis position i: g[k] for a uniform axis, whose weight depends on the offset alone, and g[i, k] for a stretched axis's n × (2·lim+1) table.
CoarseGrainingEnergyFluxes.Filtering._structured_footprint — Method
_structured_footprint(::Tuple, grid::StructuredGrid{T,<:CartesianGeometry,2}, kernel::SeparableKernel, scale; kwargs...) -> SeparableFootprintThe separable two-pass engine, O(N·(wx+wy)), on any rectilinear Cartesian grid: a stretched axis gets a per-position weight table (see _separable_axis_weights). Keywords as for _build_separable_footprint.
CoarseGrainingEnergyFluxes.Filtering.apply_separable! — Method
apply_separable!(out, field, grid, fp::SeparableFootprint, strategy) -> outFilter field into out: the two-pass convolution of mask .* field, normalized by the denominator fp holds. Where the strategies normalize differently (fp.bound), strategy must be the one fp was built for, or this throws an ArgumentError.