MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::itl::mg::multigrid< Value, Accumulator > Class Template Reference

Multigrid solver/preconditioner. More...

#include <multigrid.hpp>

Public Member Functions

template<typename SmootherFactory, typename CoarseSolver>
 multigrid (const std::vector< matrix_type > &levels, const std::vector< matrix_type > &restrictors, const std::vector< matrix_type > &prolongators, SmootherFactory smoother_factory, CoarseSolver coarse_solver, int nu_pre=2, int nu_post=2)
 Construct multigrid hierarchy.
 multigrid (const multigrid &)=delete
 V-cycle starting from the given level.
multigrid & operator= (const multigrid &)=delete
 multigrid (multigrid &&)=default
multigrid & operator= (multigrid &&)=default
void vcycle (vector_type &x, const vector_type &b, int level=0) const
void wcycle (vector_type &x, const vector_type &b, int level=0) const
 W-cycle: like V-cycle but recurses twice at each level.
void operator() (vector_type &x, const vector_type &b) const
 Apply V-cycle as operator() for use as a stand-alone solver iteration.
template<typename VecX, typename VecB>
void solve (VecX &x, const VecB &b) const
 Preconditioner interface: solve() applies one V-cycle to M*x = b.
template<typename VecX, typename VecB>
void adjoint_solve (VecX &x, const VecB &b) const
 adjoint_solve: same as solve (symmetric for symmetric smoothers)

Detailed Description

template<typename Value = double, typename Accumulator = void>
class mtl::itl::mg::multigrid< Value, Accumulator >

Multigrid solver/preconditioner.

Smoother must have operator()(VecX&, const VecB&) -> VecX& interface. CoarseSolver must have operator()(VecX&, const VecB&) interface.

Not thread-safe, although vcycle, wcycle, solve and operator() are const: the smoothers and the coarse solver keep scratch (Jacobi's x_new, say) that every cycle writes through std::function. Two threads must not cycle one multigrid object at the same time; give each thread its own (issue 888).

Constructor & Destructor Documentation

◆ multigrid() [1/3]

template<typename Value = double, typename Accumulator = void>
template<typename SmootherFactory, typename CoarseSolver>
mtl::itl::mg::multigrid< Value, Accumulator >::multigrid ( const std::vector< matrix_type > & levels,
const std::vector< matrix_type > & restrictors,
const std::vector< matrix_type > & prolongators,
SmootherFactory smoother_factory,
CoarseSolver coarse_solver,
int nu_pre = 2,
int nu_post = 2 )
inline

Construct multigrid hierarchy.

Parameters
levelsVector of system matrices A[0] (finest) ... A[L-1] (coarsest)
restrictorsRestriction matrices R[0] ... R[L-2]
prolongatorsProlongation matrices P[0] ... P[L-2]
smoother_factoryCreates a smoother for a given level matrix
coarse_solverSolves the coarsest level exactly
nu_preNumber of pre-smoothing steps
nu_postNumber of post-smoothing steps

◆ multigrid() [2/3]

template<typename Value = double, typename Accumulator = void>
mtl::itl::mg::multigrid< Value, Accumulator >::multigrid ( const multigrid< Value, Accumulator > & )
delete

V-cycle starting from the given level.

◆ multigrid() [3/3]

template<typename Value = double, typename Accumulator = void>
mtl::itl::mg::multigrid< Value, Accumulator >::multigrid ( multigrid< Value, Accumulator > && )
default

Member Function Documentation

◆ adjoint_solve()

template<typename Value = double, typename Accumulator = void>
template<typename VecX, typename VecB>
void mtl::itl::mg::multigrid< Value, Accumulator >::adjoint_solve ( VecX & x,
const VecB & b ) const
inline

adjoint_solve: same as solve (symmetric for symmetric smoothers)

◆ operator()()

template<typename Value = double, typename Accumulator = void>
void mtl::itl::mg::multigrid< Value, Accumulator >::operator() ( vector_type & x,
const vector_type & b ) const
inline

Apply V-cycle as operator() for use as a stand-alone solver iteration.

◆ operator=() [1/2]

template<typename Value = double, typename Accumulator = void>
multigrid & mtl::itl::mg::multigrid< Value, Accumulator >::operator= ( const multigrid< Value, Accumulator > & )
delete

◆ operator=() [2/2]

template<typename Value = double, typename Accumulator = void>
multigrid & mtl::itl::mg::multigrid< Value, Accumulator >::operator= ( multigrid< Value, Accumulator > && )
default

◆ solve()

template<typename Value = double, typename Accumulator = void>
template<typename VecX, typename VecB>
void mtl::itl::mg::multigrid< Value, Accumulator >::solve ( VecX & x,
const VecB & b ) const
inline

Preconditioner interface: solve() applies one V-cycle to M*x = b.

◆ vcycle()

template<typename Value = double, typename Accumulator = void>
void mtl::itl::mg::multigrid< Value, Accumulator >::vcycle ( vector_type & x,
const vector_type & b,
int level = 0 ) const
inline

◆ wcycle()

template<typename Value = double, typename Accumulator = void>
void mtl::itl::mg::multigrid< Value, Accumulator >::wcycle ( vector_type & x,
const vector_type & b,
int level = 0 ) const
inline

W-cycle: like V-cycle but recurses twice at each level.


The documentation for this class was generated from the following file: