pub struct LbmSimulation {
pub config: LbmConfig,
pub f: Vec<Vec<f64>>,
pub solid: Vec<bool>,
pub lid_vel_x: f64,
pub lid_vel_y: f64,
pub lid_vel_z: f64,
pub step_count: u64,
/* private fields */
}Expand description
D3Q19 BGK LBM simulation.
Population arrays are indexed f[dir][cell_index] where
cell_index = x + nx * (y + ny * z).
Fields§
§config: LbmConfigConfiguration.
f: Vec<Vec<f64>>Distribution functions f_i (19 × N_cells).
solid: Vec<bool>Solid (no-slip) mask: true = bounce-back wall.
lid_vel_x: f64Lid velocity (X component).
lid_vel_y: f64Lid velocity (Y component).
lid_vel_z: f64Lid velocity (Z component).
step_count: u64Total steps executed.
Implementations§
Source§impl LbmSimulation
impl LbmSimulation
Sourcepub fn new(config: LbmConfig) -> Self
pub fn new(config: LbmConfig) -> Self
Create a new LBM simulation, initialised at rest with density ρ₀.
Sourcepub fn set_lid_velocity(&mut self, ux: f64, uy: f64, uz: f64)
pub fn set_lid_velocity(&mut self, ux: f64, uy: f64, uz: f64)
Set the lid (top-face, y = ny-1) moving at (ux, uy, uz).
Sourcepub fn has_gpu(&self) -> bool
pub fn has_gpu(&self) -> bool
True if a real GPU adapter was successfully initialised.
Returns false before the first call to step() (GPU state is lazy).
Sourcepub fn step(&mut self)
pub fn step(&mut self)
Advance one LBM step: BGK collision + streaming + boundary.
When the wgpu-backend feature is enabled the GPU path is tried first;
it falls back to CPU if no adapter is available.
Sourcepub fn cell_macro(&mut self, x: usize, y: usize, z: usize) -> (f64, [f64; 3])
pub fn cell_macro(&mut self, x: usize, y: usize, z: usize) -> (f64, [f64; 3])
Density and velocity at cell (x, y, z).
Sourcepub fn mean_velocity(&mut self) -> (f64, f64, f64)
pub fn mean_velocity(&mut self) -> (f64, f64, f64)
Mean velocity (ux, uy, uz) averaged over all fluid cells.
When body forces are active the physical (observable) velocity in the Guo
forcing scheme is u_phys = (Σ f_i e_i + F/2) / ρ, so config.force_*
contributes a half-force correction here.
If GPU steps have been taken, the CPU-side populations are synchronised from the GPU before computing the mean.
Sourcepub fn mean_density(&mut self) -> f64
pub fn mean_density(&mut self) -> f64
Mean density over all fluid cells.
If GPU steps have been taken, the CPU-side populations are synchronised from the GPU before computing the mean.
Sourcepub fn max_velocity_magnitude(&mut self) -> f64
pub fn max_velocity_magnitude(&mut self) -> f64
Maximum velocity magnitude across all fluid cells.
If GPU steps have been taken, the CPU-side populations are synchronised from the GPU before computing the maximum.
Auto Trait Implementations§
impl !Freeze for LbmSimulation
impl !RefUnwindSafe for LbmSimulation
impl Send for LbmSimulation
impl Sync for LbmSimulation
impl Unpin for LbmSimulation
impl UnsafeUnpin for LbmSimulation
impl !UnwindSafe for LbmSimulation
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> 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