pub struct MacroMicroRepr {
pub density: Vec<f64>,
pub mean_velocity: Vec<f64>,
pub temperature: Vec<f64>,
pub inner: Box<dyn PhaseSpaceRepr>,
pub spatial_shape: [usize; 3],
pub velocity_shape: [usize; 3],
pub domain: Domain,
/* private fields */
}Expand description
Macro-micro representation: f = f_M + g.
f_M is a local Maxwellian parameterized by (rho, u, T).
g is the kinetic deviation, stored by an inner PhaseSpaceRepr.
Density is O(N^3) from the macro fields – no velocity integration needed. Conservation of mass, momentum, and energy is exact by construction.
Fields§
§density: Vec<f64>Macro density rho(x) – flat row-major [nx*ny*nz].
mean_velocity: Vec<f64>Macro mean velocity u(x) – flat [nxnynz * 3] (ux, uy, uz interleaved).
temperature: Vec<f64>Macro temperature T(x) – flat [nx*ny*nz] (scalar temperature).
inner: Box<dyn PhaseSpaceRepr>Micro deviation g = f - f_M, stored by inner representation.
spatial_shape: [usize; 3]Spatial grid shape [nx, ny, nz].
velocity_shape: [usize; 3]Velocity grid shape [nv1, nv2, nv3].
domain: DomainDomain specification.
Implementations§
Source§impl MacroMicroRepr
impl MacroMicroRepr
Sourcepub fn from_repr(inner: Box<dyn PhaseSpaceRepr>, domain: &Domain) -> Self
pub fn from_repr(inner: Box<dyn PhaseSpaceRepr>, domain: &Domain) -> Self
Create from an existing PhaseSpaceRepr by extracting macro moments
and computing g = f - f_M.
Sourcepub fn reproject_moments(&mut self)
pub fn reproject_moments(&mut self)
Re-project: recompute macro fields (rho, u, T) from the current inner representation state, ensuring exact conservation of macroscopic moments.
Trait Implementations§
Source§impl PhaseSpaceRepr for MacroMicroRepr
impl PhaseSpaceRepr for MacroMicroRepr
Source§fn compute_density(&self) -> DensityField
fn compute_density(&self) -> DensityField
Returns density directly from the cached macro field (O(N^3), no velocity integration).
Source§fn advect_x(&mut self, displacement: &DisplacementField, dt: f64)
fn advect_x(&mut self, displacement: &DisplacementField, dt: f64)
Delegates spatial advection to the inner representation.
Macro fields are re-synced via reproject_moments() after a full step.
Source§fn advect_v(&mut self, acceleration: &AccelerationField, dt: f64)
fn advect_v(&mut self, acceleration: &AccelerationField, dt: f64)
Delegates velocity advection to the inner representation.
Macro momentum update is applied via reproject_moments() after a full step.
Source§fn moment(&self, position: &[f64; 3], order: usize) -> Tensor
fn moment(&self, position: &[f64; 3], order: usize) -> Tensor
Computes velocity moments by delegating to the inner kinetic representation.
Source§fn total_mass(&self) -> f64
fn total_mass(&self) -> f64
Returns the cached total mass from macro density integration.
Source§fn casimir_c2(&self) -> f64
fn casimir_c2(&self) -> f64
Approximates C2 = integral(f^2) using the fluid-level density: sum(rho^2 * dx^3).
Source§fn entropy(&self) -> f64
fn entropy(&self) -> f64
Fluid-level entropy: configurational (-integral rho ln rho) plus thermal (3/2 rho ln(2 pi e T)).
Source§fn stream_count(&self) -> StreamCountField
fn stream_count(&self) -> StreamCountField
Delegates stream counting to the inner kinetic representation.
Source§fn velocity_distribution(&self, position: &[f64; 3]) -> Vec<f64>
fn velocity_distribution(&self, position: &[f64; 3]) -> Vec<f64>
Delegates local velocity distribution extraction to the inner representation.
Source§fn total_kinetic_energy(&self) -> Option<f64>
fn total_kinetic_energy(&self) -> Option<f64>
Kinetic energy from macro fields: bulk (1/2 rho |u|^2) plus thermal (3/2 rho T).
Source§fn to_snapshot(&self, time: f64) -> Option<PhaseSpaceSnapshot>
fn to_snapshot(&self, time: f64) -> Option<PhaseSpaceSnapshot>
Produces a full 6D snapshot by delegating to the inner representation.
Source§fn load_snapshot(
&mut self,
snap: PhaseSpaceSnapshot,
) -> Result<(), CausticError>
fn load_snapshot( &mut self, snap: PhaseSpaceSnapshot, ) -> Result<(), CausticError>
Loads a snapshot into the inner representation and re-syncs macro fields.
Source§fn can_materialize(&self) -> bool
fn can_materialize(&self) -> bool
Reports whether the inner representation supports dense materialization.
Source§fn memory_bytes(&self) -> usize
fn memory_bytes(&self) -> usize
Total memory: macro fields (density + velocity + temperature) plus inner representation.
Source§fn set_progress(&mut self, progress: Arc<StepProgress>)
fn set_progress(&mut self, progress: Arc<StepProgress>)
Attaches a shared progress reporter to both this wrapper and the inner representation.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any. Only HtTensor overrides this; the default
returns self but concrete downcasts will yield None.Auto Trait Implementations§
impl Freeze for MacroMicroRepr
impl !RefUnwindSafe for MacroMicroRepr
impl Send for MacroMicroRepr
impl Sync for MacroMicroRepr
impl Unpin for MacroMicroRepr
impl UnsafeUnpin for MacroMicroRepr
impl !UnwindSafe for MacroMicroRepr
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