Advection Operators
🌀 Analytic Warp
Section titled “🌀 Analytic Warp”sim_add_analytic_warp_operator(ctx, field, opts)
Nonlinear analytic deformation (digamma/trigamma/power/tanh/hyperexp/qhyperexp).
profile(enum):digamma,trigamma,power,tanh,hyperexp,qhyperexp.delta(>0, default 1e-3): symmetric offset for gradient estimates.lambda(default 1.0): response gain.bias(default 0): pre-profile offset.exponent(power profile).hyperexp_epsilon,hyperexp_depth,hyperexp_q(hyperexp/qhyperexp profiles).complex_mode(enum):componentorpolar.continuity_mode(enum):none|strict|clamped|limited.continuity_clamp_min/continuity_clamp_max: bounds for clamped/limited.continuity_tolerance: blend radius for limited mode.
Examples:
sim.sim_add_analytic_warp_operator(ctx, field, { profile = "power", exponent = 1.5, lambda = 0.4})
sim.sim_add_analytic_warp_operator(ctx, field, { profile = "hyperexp", hyperexp_depth = 16, hyperexp_epsilon = 0.25, complex_mode = "polar"})∇ Spatial Derivative
Section titled “∇ Spatial Derivative”sim_add_spatial_derivative_operator(ctx, src, dst, opts)
Finite difference derivative df/dx (or df/dy).
method(enum):central(default),forward,backward.axis(int, default 0): 0=x, 1=y.skew_forward(bool): bias central toward upwind.spacing(>0): dx scale.boundary(enum):periodic|neumann|dirichlet|reflective.accumulate(bool): add instead of overwrite.
Examples:
sim.sim_add_spatial_derivative_operator(ctx, u, ux, { method = "forward", spacing = 0.25})
sim.sim_add_spatial_derivative_operator(ctx, u, uy, { method = "central", axis = 1, boundary = "dirichlet", accumulate = true})Read/modify an existing spatial-derivative operator
Section titled “Read/modify an existing spatial-derivative operator”sim_spatial_derivative_config(ctx, op_index) -> table|nilreturns{ input_field, output_field, spacing/dx, method, method_index, axis, skew_forward, boundary, accumulate }.sim_spatial_derivative_update(ctx, op_index, opts) -> trueupdates any subset of those fields.input_field/output_fieldaccept a field handle or index;methodaccepts enum/string;boundaryacceptsperiodic|neumann|dirichlet|reflective.
local cfg = sim.sim_spatial_derivative_config(ctx, op_index)if cfg then sim.log("∂ axis=%d method=%s dx=%.3g", cfg.axis, cfg.method, cfg.dx)end
-- Switch to backward upwind on y with tighter spacingsim.sim_spatial_derivative_update(ctx, op_index, { axis = 1, method = "backward", spacing = 0.05, skew_forward = false, boundary = "neumann",})