pub struct Multigrid {
pub levels: usize,
pub shape: [usize; 3],
pub dx: [f64; 3],
pub bc: SpatialBoundType,
pub n_smooth: usize,
pub tolerance: f64,
}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: usize§shape: [usize; 3]§dx: [f64; 3]§bc: SpatialBoundType§n_smooth: usize§tolerance: f64Implementations§
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 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 = -nabla Phi via 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
Mutably borrows from an owned value. Read more
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>
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 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>
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