Skip to main content

FlowMapRepr

Struct FlowMapRepr 

Source
pub struct FlowMapRepr {
    pub positions: Vec<f64>,
    pub velocities: Vec<f64>,
    pub f0_values: Vec<f64>,
    pub masses: Vec<f64>,
    pub n_lag: usize,
    pub nv_lag: usize,
    pub spatial_shape: [usize; 3],
    pub domain: Domain,
    /* private fields */
}
Expand description

Flow-map Lagrangian representation of the 6D distribution function.

Stores n_lag³ * nv_lag³ Lagrangian tracer points, each carrying:

  • Initial position q and velocity p (from IC)
  • Current position X(t;q,p) and velocity V(t;q,p)
  • Initial distribution value f₀(q,p) and particle mass

Density is recovered via CIC deposition, following the same pattern as SheetTracker.

Fields§

§positions: Vec<f64>

Lagrangian grid positions X(t;q) — flat [x0,y0,z0, x1,y1,z1, …]

§velocities: Vec<f64>

Lagrangian grid velocities V(t;q) — flat [vx0,vy0,vz0, …]

§f0_values: Vec<f64>

Initial distribution function value f₀(q,p) at each Lagrangian point

§masses: Vec<f64>

Mass of each Lagrangian tracer (= f₀ * dq³ * dp³)

§n_lag: usize

Number of Lagrangian points per spatial dimension

§nv_lag: usize

Number of Lagrangian points per velocity dimension

§spatial_shape: [usize; 3]

Spatial grid dimensions for density deposition [nx, ny, nz]

§domain: Domain

Domain specification

Implementations§

Source§

impl FlowMapRepr

Source

pub fn new(domain: &Domain, n_lag: usize, nv_lag: usize) -> Self

Create a new FlowMapRepr with all tracers at their initial positions and zero f₀.

The Lagrangian grid spans the full domain: n_lag³ points in spatial dimensions, nv_lag³ points in velocity dimensions. Each dimension is uniformly spaced.

Source

pub fn from_snapshot( snap: &PhaseSpaceSnapshot, domain: &Domain, n_lag: usize, nv_lag: usize, ) -> Self

Initialize from a PhaseSpaceSnapshot by sampling f₀ at Lagrangian grid points.

Places n_lag³ * nv_lag³ tracers on a regular grid in (x,v) space. Records f₀ at each point via trilinear interpolation of the snapshot data, and computes particle masses as m_i = f₀(q_i, p_i) * dq³ * dp³.

Source

pub fn num_tracers(&self) -> usize

Total number of Lagrangian tracer points.

Trait Implementations§

Source§

impl PhaseSpaceRepr for FlowMapRepr

Source§

fn set_progress(&mut self, p: Arc<StepProgress>)

Register a progress reporter for intra-step progress updates.

Source§

fn compute_density(&self) -> DensityField

CIC deposition of tracer masses onto the spatial grid.

For each Lagrangian tracer, finds the 8 nearest spatial cells and distributes its mass using trilinear weights, then divides by cell volume to get density. Uses rayon parallelism with fold/reduce (same pattern as SheetTracker).

Source§

fn advect_x(&mut self, _displacement: &DisplacementField, dt: f64)

Drift sub-step: X[i] += V[i] * dt for each tracer. Exact – no interpolation.

For periodic domains, positions are wrapped into [-L, L].

Source§

fn advect_v(&mut self, acceleration: &AccelerationField, dt: f64)

Kick sub-step: V[i] += g(X[i]) * dt for each tracer.

The acceleration at each tracer’s current position is obtained by trilinear interpolation of the acceleration field.

Source§

fn moment(&self, position: &[f64; 3], order: usize) -> Tensor

Velocity moment at a given spatial position.

Finds all tracers in the same spatial cell and computes the requested moment from their velocities and masses.

Source§

fn total_mass(&self) -> f64

Total mass. Constant by Liouville’s theorem — returns the cached value.

Source§

fn casimir_c2(&self) -> f64

Casimir invariant C₂ = integral of f² over phase space.

Approximated by depositing onto the spatial grid and computing integral of rho^2. This is a spatial-only approximation; the true C₂ involves the 6D distribution.

Source§

fn entropy(&self) -> f64

Entropy S = -integral of f ln f over phase space. Constant by Liouville’s theorem — returns the cached value.

Source§

fn stream_count(&self) -> StreamCountField

Number of distinct velocity streams at each spatial point.

Counts the number of distinct Lagrangian tracers per spatial cell.

Source§

fn velocity_distribution(&self, position: &[f64; 3]) -> Vec<f64>

Local velocity distribution at a given spatial position.

Collects the speed |v| of all tracers in the same cell as the given position.

Source§

fn total_kinetic_energy(&self) -> Option<f64>

Total kinetic energy T = sum of 0.5 * mass[i] * |V[i]|^2.

Source§

fn to_snapshot(&self, time: f64) -> Option<PhaseSpaceSnapshot>

Extract a full 6D snapshot by CIC deposition of all tracers.

Each tracer is deposited onto 2^3 x 2^3 = 64 surrounding cells in the 6D grid. This is expensive for large grids and should only be used for checkpoints.

Source§

fn as_any(&self) -> &dyn Any

Downcast to &dyn Any for runtime type queries.

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast to &mut dyn Any for runtime type queries.

Source§

fn memory_bytes(&self) -> usize

Heap memory used by position, velocity, f0, and mass arrays.

Source§

fn load_snapshot( &mut self, snap: PhaseSpaceSnapshot, ) -> Result<(), CausticError>

Replace the current state with data from a dense 6D snapshot. Read more
Source§

fn can_materialize(&self) -> bool

Whether full 6D materialization fits in available memory. Default: true. Compressed representations (HT, TT) should override to check shape vs a memory threshold.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,