Reference

Contents

Index

UniformStreamlines.ArrowDataType
ArrowData{D}

Holds arrow glyphs computed by streamarrows.

Fields

  • points :: Matrix{Float64}D × N matrix of arrow base positions.
  • vectors :: Matrix{Float64}D × N matrix of arrow direction vectors (unit tangent scaled by scale).
  • speeds :: Vector{Float64} — speed ‖field(p)‖ at each arrow, suitable for color-mapping.
  • indices :: Vector{Int} — column indices into the original StreamlineData.paths matrix, so per-vertex color arrays can be subsampled.
source
UniformStreamlines.StreamlineDataType
StreamlineData{D}

Holds the output of evenstream. D is the spatial dimension.

Fields

  • paths :: Matrix{Float64}D × N matrix. Streamlines are stored column-by-column and separated by columns of NaN. Pass paths[1,:] and paths[2,:] (and paths[3,:] in 3-D) directly to a plotting library.
  • lower :: Vector{Float64} — lower corner of the domain box.
  • upper :: Vector{Float64} — upper corner of the domain box.
  • field :: Function — the interpolated velocity function field(p::AbstractVector) -> Vector{Float64}. Useful for querying velocities at arbitrary points, and required internally by colorize and streamarrows.
source
UniformStreamlines.box_intersection!Method
box_intersection!(out, pin, pout, lower, upper)

Compute the point where the segment pin → pout crosses the axis-aligned box [lower, upper] and write the result into out. Assumes pin is inside the box and pout is outside.

source
UniformStreamlines.colorizeMethod
colorize(data::StreamlineData, f) -> Vector

Compute a per-point value along the streamlines for use as a color argument to streamlines / streamlines!.

The return type matches the return type of f:

  • f returns a RealVector{Float64} (use with colormap)
  • f returns a ColorantVector{<:Colorant} (used directly as color, no colormap needed)

The color function f

f has the signature

f(pos::AbstractVector, vel::AbstractVector) -> Union{Real, Colorant}

where pos is the point position and vel = field(pos) is the velocity vector, both of length D.

Built-in symbols (shortcuts for scalar coloring):

SymbolEquivalent function
:norm/:speed(p, v) -> norm(v)
:vx / :u(p, v) -> v[1]
:vy / :v(p, v) -> v[2]
:vz / :w(p, v) -> v[3] (3-D only)
:x(p, v) -> p[1]
:y(p, v) -> p[2]
:z(p, v) -> p[3] (3-D only)

Examples

# Scalar coloring — pair with colormap
c = colorize(str, :norm)
c = colorize(str, (p, v) -> p[1]^2 + p[2]^2)   # distance² from origin
c = colorize(str, (p, v) -> v[1] / norm(v))     # cos(angle) with x-axis
streamlines!(ax, str; color=c, colormap=:viridis)

# Direct color — no colormap needed
c = colorize(str, (p, v) -> RGBAf(v[1], v[2], 0, 1))   # color by velocity direction
streamlines!(ax, str; color=c)
source
UniformStreamlines.streamMethod
stream(Val(D), lower, upper, u; kwargs...) -> Matrix{Float64}

Low-level core: compute evenly-spaced streamlines of the vector field u over the axis-aligned box [lower, upper]. Works in any dimension D (D=2 or D=3 are typical).

u must be a function u(p::AbstractVector) -> AbstractVector returning the velocity at position p.

Returns

A D × N matrix. Individual streamlines are concatenated column-by-column, separated by columns of NaN.

Keyword arguments

KeywordDefaultDescription
min_density4Seeding grid density (domain divided into 10 × min_density cells/axis). Higher → more seed candidates → denser coverage.
max_density10Collision grid density (domain divided into 10 × max_density cells/axis). Higher → streamlines may pass closer together.
allow_collisionsfalseIf true, streamlines pass through each other instead of being truncated.
seedsnothingExplicit seed points; overrides density grids. Two formats: ([x1,y1], [x2,y2], ...) (tuple of D-vectors, one per point) or (xs, ys) (pair of N-vectors, one per axis).
min_length2Discard streamlines with fewer than this many vertices.
stepsizeadaptiveArc-length step size (physical distance per integration step). Velocity is normalized internally, so this controls spatial resolution independent of field magnitude. Default: min(norm(domain) / (10 × max_density × 10), 0.05).
source
UniformStreamlines.streamarrowsMethod
streamarrows(data::StreamlineData{D}; every=10, spacing=nothing, scale=1.0) -> ArrowData{D}

Extract arrow glyphs from a StreamlineData result.

Arrows can be placed in two modes:

  1. Vertex mode (default) — an arrow every every path vertices. Fast, but non-uniform when vertex spacing varies.
  2. Arc-length mode — an arrow every spacing units of arc length. Set spacing to a positive number to enable uniform placement. When spacing is given, every is ignored.

Keyword arguments

  • every :: Int = 10 — (vertex mode) place an arrow every this many path vertices.
  • spacing :: Real = nothing — (arc-length mode) place an arrow every this many units of arc length along each streamline. Overrides every when set.
  • scale :: Real = 1.0 — length factor applied to each unit-tangent arrow vector; pass this directly to your quiver/arrow plotting call.

Returns

An ArrowData{D} with fields:

  • pointsD × N base positions.
  • vectorsD × N arrow vectors (unit tangent × scale).
  • speedsN-vector of ‖velocity‖ at each arrow, for color-mapping.
  • indices — column indices into the original StreamlineData.paths matrix (nearest vertex to each arrow position).

Examples

# Vertex-based (legacy)
arrows = streamarrows(result; every=15, scale=0.05)

# Uniform arc-length spacing
arrows = streamarrows(result; spacing=0.3, scale=0.05)
source
UniformStreamlines.streamlinesFunction
streamlines(str::StreamlineData; kwargs...)
streamlines!(ax, str::StreamlineData; kwargs...)

Plot evenly-spaced streamlines from precomputed StreamlineData.

streamlines creates a new figure; streamlines! adds to an existing axis or plot. Both work with Makie (via MakieExt) and Plots.jl (via PlotsExt).

Common keyword arguments

KeywordDefaultDescription
with_arrowsfalseDraw directional arrowheads along streamlines
arrows_spacingautomaticArc-length spacing between arrows (uniform placement)
arrows_everynothingLegacy: place an arrow every N vertices; overrides arrows_spacing

Makie-specific keyword arguments

KeywordDefaultDescription
color:blueA color, or a per-point Vector from colorize
colormapColormap when color is numeric (e.g. :viridis, :plasma)
colorrangeautomatic(min, max) for the color mapping
linewidthinheritedStreamline width
markersizeinherited (2-D)Arrowhead size. In 2-D this is in pixels; in 3-D it is in data units (default auto-scaled to ~2 % of domain diagonal)

Plots.jl-specific keyword arguments

KeywordDefaultDescription
line_zPer-point color values from colorize
markersize1.0Scale factor for arrowhead size
color:blueSeries color / colormap when using line_z

Examples

using UniformStreamlines

xs = LinRange(-2, 2, 200)
ys = LinRange(-2, 2, 200)
str = evenstream(xs, ys, (x, y) -> -y, (x, y) -> x)

# Makie
using CairoMakie
streamlines(str; color=colorize(str, :norm), colormap=:viridis,
            with_arrows=true)

# Plots.jl
using Plots
c = colorize(str, :norm)
streamlines(str; line_z=c, color=:viridis,
            with_arrows=true)
source
UniformStreamlines.trace!Method
trace!(verts, pos, x, x0, u, stepsize, maxvert, lower, upper, sgn) -> Int

Integrate a single streamline from x0 into the pre-allocated buffer verts (D × maxvert) using midpoint (RK2) steps with unit-velocity normalization (each step advances exactly stepsize in arc-length, regardless of field magnitude). pos and x are D-length working vectors. Returns the number of columns written.

source