Skip to content

Scalar Support #34

Closed
Closed

Description

@jbphyswx

Everything we have right now is velocity structure fucntions. would be great to add support for scalar structure fucntions

Activity

  1. jbphyswx commented on Sep 6, 2026

    @jbphyswx
    OwnerAuthor

    Implemented.

    Scalars arrive by dispatch on a field-bundle type, not a keyword reinterpreting u's rows — a keyword would make (3,N) mean either a 3-component velocity or 2 components plus a tracer depending on a flag, which is two ways to say one thing.

    Fields(vectors = (u,),   scalars = (θ,))    # velocity + tracer
    Fields(vectors = (u, 𝓐u))                   # advective (see #36)
    Fields(scalars = (ω, 𝓐ω))

    Vector channels are parallel-transported by the geometry; scalar channels are differenced where they stand, because a scalar has nothing to transport. Internally one packed (V·D + K, N) array, so the kernels keep exactly the existing load path.

    Operators added: ScalarSFType{P} (⟨(δθ)^P⟩), MixedSFType{NL,NT,P} (⟨δu_L^NL ‖δu_T‖^NT (δθ)^P⟩, with {1,0,2} being Yaglom), and the cross-channel ScalarDotSFType(a,b) / VectorDotSFType(a,b). Note VectorDotSFType(1,1) is S2SF — the existing second-order operator is this one's diagonal, not a separate thing.

    Fields(vectors = (u,)) is the array path, not a copy of it — it forwards to the existing entry, so a bare u and a one-vector bundle give bit-identical sums.

    Performance. The first cut was up to 6.1× slower than the array path; that was two separate losses — missing culling (the gap grew with N) and a missing SIMD compute/scatter split (a flat 1.6× everywhere). Both reused existing machinery. A multi-channel field now costs 1.1× a single-channel one for the same pairs.

    Threaded backend supported. KHM gained epsilon_theta_from_yaglom / yaglom_residual for the mixed moment.

    A live defect this surfaced and fixed: epsilon_from_four_fifths(r, S3) named its argument S3, but the four-fifths law is for ⟨δu_L³⟩ — the package's L3SF — while the package's S3SF is ⟨δu_L‖δu‖²⟩, which obeys the four-thirds law. Passing results.S3, the obvious reading, returned ε too small by exactly 5/3 with nothing complaining. Argument renamed, and epsilon_from_four_thirds added alongside; a test now asserts the two are not interchangeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions