pub struct HybridMultigridSolver { /* private fields */ }Expand description
Hybrid 2-level multigrid solver with a learned smoother at the fine level.
The solver performs V-cycles:
- Pre-smooth (learned smoother)
- Restrict residual to coarse grid
- Solve coarse system (direct solve)
- Prolongate correction to fine grid
- Post-smooth (learned smoother)
If the learned smoother increases the residual, the solver falls back to classical weighted Jacobi.
Implementations§
Source§impl HybridMultigridSolver
impl HybridMultigridSolver
Sourcepub fn new(
a_values: Vec<f64>,
a_row_ptr: Vec<usize>,
a_col_idx: Vec<usize>,
smoother: Box<dyn Smoother>,
config: LearnedSmootherConfig,
) -> SparseResult<Self>
pub fn new( a_values: Vec<f64>, a_row_ptr: Vec<usize>, a_col_idx: Vec<usize>, smoother: Box<dyn Smoother>, config: LearnedSmootherConfig, ) -> SparseResult<Self>
Create a new hybrid multigrid solver.
§Arguments
a_values,a_row_ptr,a_col_idx: fine-grid operator in CSRsmoother: a trained (or untrained) learned smootherconfig: solver configuration
Sourcepub fn solve(&self, b: &[f64]) -> SparseResult<Vec<f64>>
pub fn solve(&self, b: &[f64]) -> SparseResult<Vec<f64>>
Solve A x = b using iterative V-cycles.
Returns the solution vector. Falls back to Jacobi smoothing if the learned smoother causes divergence.
Sourcepub fn compare_with_jacobi(
&self,
b: &[f64],
n_iterations: usize,
) -> SparseResult<SmootherMetrics>
pub fn compare_with_jacobi( &self, b: &[f64], n_iterations: usize, ) -> SparseResult<SmootherMetrics>
Compare learned smoother convergence with classical Jacobi.
Runs both for n_iterations V-cycles and returns metrics.
Sourcepub fn coarse_dim(&self) -> usize
pub fn coarse_dim(&self) -> usize
Coarse grid dimension.
Auto Trait Implementations§
impl Freeze for HybridMultigridSolver
impl !RefUnwindSafe for HybridMultigridSolver
impl !Send for HybridMultigridSolver
impl !Sync for HybridMultigridSolver
impl Unpin for HybridMultigridSolver
impl UnsafeUnpin for HybridMultigridSolver
impl !UnwindSafe for HybridMultigridSolver
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> 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