Skip to main content

MacroMicroRepr

Struct MacroMicroRepr 

Source
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: Domain

Domain specification.

Implementations§

Source§

impl MacroMicroRepr

Source

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.

Source

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

Source§

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)

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)

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

Computes velocity moments by delegating to the inner kinetic representation.

Source§

fn total_mass(&self) -> f64

Returns the cached total mass from macro density integration.

Source§

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

Fluid-level entropy: configurational (-integral rho ln rho) plus thermal (3/2 rho ln(2 pi e T)).

Source§

fn stream_count(&self) -> StreamCountField

Delegates stream counting to the inner kinetic representation.

Source§

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>

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>

Produces a full 6D snapshot by delegating to the inner representation.

Source§

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

Reports whether the inner representation supports dense materialization.

Source§

fn memory_bytes(&self) -> usize

Total memory: macro fields (density + velocity + temperature) plus inner representation.

Source§

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

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.

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,