pub struct KfvsSolver {
pub shape: [usize; 3],
pub dx: [f64; 3],
pub state: Vec<MacroState>,
}Expand description
KFVS macroscopic solver on a 3D spatial grid.
Evolves (ρ, ρu, e) using kinetic flux vector splitting. The KFVS flux at cell interface i+½ in direction d is:
F⁺ = ∫{v_d > 0} v_d * [1, v, ½|v|²]ᵀ * f⁺ dv F⁻ = ∫{v_d < 0} v_d * [1, v, ½|v|²]ᵀ * f⁻ dv
where f⁺/f⁻ are Maxwellians reconstructed from left/right cell states.
Fields§
§shape: [usize; 3]Spatial grid shape [nx, ny, nz].
dx: [f64; 3]Cell spacings [dx, dy, dz].
state: Vec<MacroState>Macroscopic state: one MacroState per spatial cell (row-major).
Implementations§
Source§impl KfvsSolver
impl KfvsSolver
Sourcepub fn new(shape: [usize; 3], dx: [f64; 3]) -> Self
pub fn new(shape: [usize; 3], dx: [f64; 3]) -> Self
Create a KFVS solver for the given spatial grid, initialized to zero state.
Sourcepub fn initialize_from_moments(
&mut self,
density: &[f64],
momentum_x: &[f64],
momentum_y: &[f64],
momentum_z: &[f64],
energy: &[f64],
)
pub fn initialize_from_moments( &mut self, density: &[f64], momentum_x: &[f64], momentum_y: &[f64], momentum_z: &[f64], energy: &[f64], )
Populate the macroscopic state from per-cell kinetic moments (flat arrays of length N).
Sourcepub fn step(&mut self, dt: f64, gx: &[f64], gy: &[f64], gz: &[f64])
pub fn step(&mut self, dt: f64, gx: &[f64], gy: &[f64], gz: &[f64])
Advance the macroscopic state by one time step Δt using KFVS.
gx, gy, gz provide the gravitational acceleration components
at each cell as separate flat arrays of length nxnynz.
Sourcepub fn density_field(&self) -> Vec<f64>
pub fn density_field(&self) -> Vec<f64>
Extract the density field as a flat array from the macroscopic state.
Sourcepub fn momentum_field(&self) -> [Vec<f64>; 3]
pub fn momentum_field(&self) -> [Vec<f64>; 3]
Extract the three momentum-density components [Jx, Jy, Jz] as flat arrays.
Sourcepub fn energy_field(&self) -> Vec<f64>
pub fn energy_field(&self) -> Vec<f64>
Extract the energy-density field as a flat array from the macroscopic state.
Sourcepub fn total_mass(&self) -> f64
pub fn total_mass(&self) -> f64
Total mass (sum of ρ * dx³).
Sourcepub fn total_momentum(&self) -> [f64; 3]
pub fn total_momentum(&self) -> [f64; 3]
Total momentum (sum of J * dx³).
Sourcepub fn total_energy(&self) -> f64
pub fn total_energy(&self) -> f64
Total energy (sum of e * dx³).
Auto Trait Implementations§
impl Freeze for KfvsSolver
impl RefUnwindSafe for KfvsSolver
impl Send for KfvsSolver
impl Sync for KfvsSolver
impl Unpin for KfvsSolver
impl UnsafeUnpin for KfvsSolver
impl UnwindSafe for KfvsSolver
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