pub struct Multigrid {
pub levels: usize,
pub shape: [usize; 3],
pub dx: [f64; 3],
pub bc: SpatialBoundType,
pub n_smooth: usize,
pub tolerance: f64,
/* private fields */
}Expand description
Geometric multigrid Poisson solver.
Uses V-cycles with red-black Gauss-Seidel smoothing, full-weighting restriction, and trilinear prolongation. Supports periodic and Dirichlet zero boundary conditions.
Fields§
§levels: usizeNumber of multigrid levels (1 = single-grid, higher = deeper V-cycle).
shape: [usize; 3]Grid dimensions [nx, ny, nz].
dx: [f64; 3]Cell spacings [dx, dy, dz].
bc: SpatialBoundTypeSpatial boundary condition (Periodic or Dirichlet zero).
n_smooth: usizeNumber of red-black Gauss-Seidel sweeps per pre/post-smoothing phase.
tolerance: f64Relative residual convergence tolerance for the iterative V-cycle loop.
Implementations§
Source§impl Multigrid
impl Multigrid
Sourcepub fn new(domain: &Domain, levels: usize, smoothing_steps: usize) -> Self
pub fn new(domain: &Domain, levels: usize, smoothing_steps: usize) -> Self
Create a new multigrid solver.
domain: the computational domain (provides shape, dx, boundary type)levels: requested number of multigrid levels (will be capped so the coarsest grid has at least 2 cells per dimension)smoothing_steps: number of Gauss-Seidel sweeps per pre/post-smoothing phase
Trait Implementations§
Source§impl PoissonSolver for Multigrid
impl PoissonSolver for Multigrid
Source§fn set_progress(&mut self, p: Arc<StepProgress>)
fn set_progress(&mut self, p: Arc<StepProgress>)
Register a shared progress handle for intra-step reporting to the TUI.
Source§fn solve(&self, density: &DensityField, g: f64) -> PotentialField
fn solve(&self, density: &DensityField, g: f64) -> PotentialField
Solve ∇²Φ = 4πGρ using multigrid V-cycles.
Iterates V-cycles until the relative residual drops below tolerance
or the maximum iteration count (100) is reached. For periodic BC, the
mean of phi is subtracted after solving (since the solution is only
determined up to a constant).
Source§fn compute_acceleration(&self, potential: &PotentialField) -> AccelerationField
fn compute_acceleration(&self, potential: &PotentialField) -> AccelerationField
Compute gravitational acceleration g = -∇Φ via second-order centered finite differences.
Auto Trait Implementations§
impl Freeze for Multigrid
impl RefUnwindSafe for Multigrid
impl Send for Multigrid
impl Sync for Multigrid
impl Unpin for Multigrid
impl UnsafeUnpin for Multigrid
impl UnwindSafe for Multigrid
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