pub struct AmrGrid {
pub root: AmrCell,
pub domain: Domain,
pub refinement_threshold: f64,
pub gradient_threshold: f64,
pub max_level: 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.
Fields§
§root: AmrCellRoot cell of the tree, spanning the entire 6D domain.
domain: DomainThe simulation domain (spatial/velocity extents, resolutions, BCs).
refinement_threshold: f64Cells with |f| > refinement_threshold are subdivided.
gradient_threshold: f64Gradient-based refinement threshold (reserved for future use).
max_level: usizeMaximum refinement level (0 = root only).
Implementations§
Source§impl AmrGrid
impl AmrGrid
Sourcepub fn new(domain: Domain, refinement_threshold: f64, max_levels: usize) -> Self
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.
Sourcepub fn refine(&mut self)
pub fn refine(&mut self)
Refine cells where |f| exceeds the refinement threshold, up to max_level.
Sourcepub fn coarsen(&mut self)
pub fn coarsen(&mut self)
Merge children back into parent when their values are nearly uniform (spread < threshold / 10).
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Number of leaf cells currently in the tree.
Trait Implementations§
Source§impl PhaseSpaceRepr for AmrGrid
impl PhaseSpaceRepr for AmrGrid
Source§fn compute_density(&self) -> DensityField
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)
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)
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
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
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
fn casimir_c2(&self) -> f64
Casimir invariant C2 = integral of f^2 dx^3 dv^3.
Source§fn stream_count(&self) -> StreamCountField
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>
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) -> f64
fn total_kinetic_energy(&self) -> f64
Total kinetic energy T = (1/2) integral of f * v^2 dx^3 dv^3.
Source§fn to_snapshot(&self, time: f64) -> PhaseSpaceSnapshot
fn to_snapshot(&self, time: f64) -> PhaseSpaceSnapshot
Extract a full 6D snapshot by depositing leaf values onto a uniform grid.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Source§fn load_snapshot(&mut self, snap: PhaseSpaceSnapshot)
fn load_snapshot(&mut self, snap: PhaseSpaceSnapshot)
Auto Trait Implementations§
impl Freeze for AmrGrid
impl RefUnwindSafe for AmrGrid
impl Send for AmrGrid
impl Sync for AmrGrid
impl Unpin for AmrGrid
impl UnsafeUnpin for AmrGrid
impl UnwindSafe for AmrGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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