Skip to main content

AmrGrid

Struct AmrGrid 

Source
pub struct AmrGrid {
    pub root: AmrCell,
    pub domain: Domain,
    pub refinement_threshold: f64,
    pub gradient_threshold: f64,
    pub max_level: usize,
    pub velocity_removal_threshold: f64,
    pub active_block_count: usize,
}
Expand description

Adaptive mesh refinement grid in 6D phase space.

The root cell spans the full domain. Cells are refined where the distribution function is significant and coarsened when values become uniform. Implements PhaseSpaceRepr by depositing leaf values onto a uniform spatial grid.

Fields§

§root: AmrCell

Root cell of the tree, spanning the entire 6D domain.

§domain: Domain

The simulation domain (spatial/velocity extents, resolutions, BCs).

§refinement_threshold: f64

Cells with |f| > refinement_threshold are subdivided.

§gradient_threshold: f64

Gradient-based refinement threshold (reserved for future use).

§max_level: usize

Maximum refinement level (0 = root only).

§velocity_removal_threshold: f64

Velocity block removal threshold: blocks with max(|f|) < this are deallocated. Set to 0 to disable sparse velocity cleanup. Default: 1e-14.

§active_block_count: usize

Current active block count (leaves with non-negligible f).

Implementations§

Source§

impl AmrGrid

Source

pub fn new(domain: Domain, refinement_threshold: f64, max_levels: usize) -> Self

Create a new AmrGrid with a single root cell spanning the full 6D domain.

  • refinement_threshold: cells with |f| above this are subdivided.
  • max_levels: maximum tree depth (0 = root only, no refinement).
Source

pub fn refine(&mut self)

Refine cells where |f| exceeds the refinement threshold, up to max_level.

Source

pub fn coarsen(&mut self)

Merge children back into parent when their values are nearly uniform (spread < threshold / 10).

Source

pub fn cleanup_sparse_velocity(&mut self)

Remove velocity-space blocks where max(|f|) < velocity_removal_threshold.

Walks the tree and coarsens leaf cells in velocity dimensions whose values are below the threshold. This reduces memory for cold/warm distributions where most of velocity space is empty.

Source

pub fn leaf_count(&self) -> usize

Number of leaf cells currently in the tree.

Trait Implementations§

Source§

impl PhaseSpaceRepr for AmrGrid

Source§

fn compute_density(&self) -> DensityField

Compute density rho(x) = integral of f dv^3 by accumulating leaf cell contributions onto the spatial grid.

Source§

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

Drift sub-step: shift leaf cell centers in spatial coordinates by v * dt. The velocity coordinates (center[3..6]) of each leaf encode its velocity, so the spatial drift is center[0..3] += center[3..6] * dt.

Source§

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

Kick sub-step: shift leaf cell centers in velocity coordinates by a(x) * dt. The acceleration is interpolated from the AccelerationField at the leaf’s spatial position.

Source§

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

Compute velocity moment of order n at the given spatial position. Sums over leaf cells whose spatial center is in the same grid cell.

Source§

fn total_mass(&self) -> f64

Total mass M = integral of f dx^3 dv^3 = sum over leaves of f * cell_volume_6D.

Source§

fn casimir_c2(&self) -> f64

Casimir invariant C2 = integral of f^2 dx^3 dv^3.

Source§

fn entropy(&self) -> f64

Boltzmann entropy S = -integral of f ln(f) dx^3 dv^3.

Source§

fn stream_count(&self) -> StreamCountField

Count distinct velocity streams at each spatial position. For each spatial grid cell, count the number of leaf cells that overlap it with significant value (indicating separate velocity-space populations).

Source§

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

Extract the velocity distribution f(v | x) at a given spatial position. Returns the values of f from all leaf cells whose spatial center maps to the same grid cell as the query position.

Source§

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

Total kinetic energy T = (1/2) integral of f * v^2 dx^3 dv^3.

Source§

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

Extract a full 6D snapshot by depositing leaf values onto a uniform grid.

Source§

fn as_any(&self) -> &dyn Any

Downcast to concrete type for implementation-specific queries (e.g. HT rank data).
Source§

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

Mutable downcast for in-place modification (e.g. BUG integrator leaf updates). Returns self as &mut dyn Any. Only HtTensor overrides this; the default returns self but concrete downcasts will yield None.
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.
Source§

fn memory_bytes(&self) -> usize

Approximate memory usage of this representation in bytes. Default returns 0; implementations should override for accurate tracking.
Source§

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

Attach shared progress state for intra-phase cell-level reporting. Implementations can use this to report progress via StepProgress::set_intra_progress.

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,