Advection
apply_scalar_advection and apply_vector_advection implement first-order
upwind advection for scalar and vector (1-form) fields on a discrete mesh.
Summary
| Function | Input | Output | Scheme |
|---|---|---|---|
apply_scalar_advection | vertex field , velocity 1-form | vertex field | Upwind finite difference |
apply_vector_advection | edge 1-form , velocity | edge 1-form | Upwind Lie derivative |
Upwind Scheme
The upwind direction for edge is determined by the sign of the velocity projection onto the edge orientation:
This is the discrete analogue of : the directional derivative of along the velocity field .
Code Examples
Scalar advection
use cartan_dec::{Mesh, apply_scalar_advection};
use nalgebra::DVector;
let mesh = Mesh::unit_square_grid(4);
// Scalar field on vertices
let f = DVector::from_fn(mesh.n_vertices(), |i, _| {
let [x, _y] = mesh.vertices[i];
x // linear field f = x
});
// Velocity field on edges (1-form)
let u = DVector::from_element(mesh.n_edges(), 0.5_f64); // uniform flow
let df_dt = apply_scalar_advection(&mesh, &f, &u);
assert_eq!(df_dt.len(), mesh.n_vertices());Time stepping
let dt = 0.01_f64;
let f_next = &f + dt * apply_scalar_advection(&mesh, &f, &u);Vector advection
use cartan_dec::apply_vector_advection;
// 1-form alpha on edges
let alpha = DVector::from_element(mesh.n_edges(), 1.0_f64);
let dalpha_dt = apply_vector_advection(&mesh, &alpha, &u);
assert_eq!(dalpha_dt.len(), mesh.n_edges());Numerical Notes
CFL condition: the upwind scheme is stable when . For a uniform grid with edge length and maximum velocity , use .
Upwind direction: determined by the sign of the velocity projection on each edge. Zero velocity on an edge contributes no advective flux at that edge.
Applications
- Active nematics: advection of Q-tensor field by active flow in volterra
- Scalar transport: tracer advection in fluid simulations
- Material lines: passive scalar advection for flow visualization