Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | List of all members
cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format > Class Template Reference

Detailed description

template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
class cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >

Algebraic multigrid preconditoner based on smoothed aggregation.

Template Parameters
IndexTypeType used for matrix values (e.g. int or size_t).
ValueTypeType used for matrix values (e.g. float or double).
MemorySpaceA memory space (e.g. cusp::host_memory or cusp::device_memory)
Overview
Given a matrix A to precondition, the smoothed aggregation preconditioner constructs a algebraic multigrid (AMG) operator.

Smoothed aggregation is expensive to use but is a very effective preconditioning technique to solve challenging linear systems. The default configuration uses a symmetric strength measure, MIS-based aggregation in device memory, sequential aggregation in host_memory, Jacobi smoothing is applied to the tentative prolongator, Jacobi relaxation on each level of hierarchy and LU to solve the coarse matrix in host memory.

Example
The following code snippet demonstrates how to use a smoothed_aggregation preconditioner to solve a linear system.
#include <cusp/krylov/cg.h>
#include <iostream>
int main(int argc, char *argv[])
{
typedef int IndexType;
typedef double ValueType;
typedef cusp::device_memory MemorySpace;
// create an empty sparse matrix structure
// construct 2d poisson matrix
IndexType N = 256;
std::cout << "Generated matrix (poisson5pt) "
<< "with shape (" << A.num_rows << "," << A.num_cols << ") and "
<< A.num_entries << " entries" << "\n";
std::cout << "\nSolving with smoothed aggregation preconditioner and jacobi smoother" << std::endl;
// print AMG statistics
M.print();
// allocate storage for solution (x) and right hand side (b)
// set stopping criteria (iteration_limit = 1000, relative_tolerance = 1e-10)
cusp::monitor<ValueType> monitor(b, 1000, 1e-10);
// solve
cusp::krylov::cg(A, x, b, monitor, M);
// report status
monitor.print();
return 0;
}
Examples:
custom_amg.cu, and smoothed_aggregation.cu.

Definition at line 160 of file smoothed_aggregation.h.

#include <smoothed_aggregation.h>

Inheritance diagram for cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >:

Public Methods

 smoothed_aggregation (void)
 
template<typename MatrixType >
 smoothed_aggregation (const MatrixType &A)
 
template<typename MatrixType , typename ArrayType >
 smoothed_aggregation (const MatrixType &A, const ArrayType &B, typename thrust::detail::enable_if_convertible< typename ArrayType::format, cusp::array1d_format >::type *=0)
 
template<typename MemorySpace2 , typename SmootherType2 , typename SolverType2 , typename Format2 >
 smoothed_aggregation (const smoothed_aggregation< IndexType, ValueType, MemorySpace2, SmootherType2, SolverType2, Format2 > &M)
 
template<typename MatrixType >
void initialize (const MatrixType &A)
 
template<typename MatrixType , typename ArrayType >
void initialize (const MatrixType &A, const ArrayType &B, typename thrust::detail::enable_if_convertible< typename MatrixType::format, cusp::known_format >::type *=0)
 

Constructor & Destructor Documentation

template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::smoothed_aggregation ( void  )
inline

Construct an empty smoothed_aggregation preconditioner.

Definition at line 177 of file smoothed_aggregation.h.

template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
template<typename MatrixType >
cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::smoothed_aggregation ( const MatrixType &  A)

Construct a smoothed_aggregation preconditioner from a matrix.

Parameters
Amatrix used to create the AMG hierarchy.
template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
template<typename MatrixType , typename ArrayType >
cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::smoothed_aggregation ( const MatrixType &  A,
const ArrayType &  B,
typename thrust::detail::enable_if_convertible< typename ArrayType::format, cusp::array1d_format >::type *  = 0 
)

Construct a smoothed_aggregation preconditioner from a matrix and specified near nullspace vector.

Parameters
Amatrix used to create the AMG hierarchy.
Bcandidate near nullspace vector.
template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
template<typename MemorySpace2 , typename SmootherType2 , typename SolverType2 , typename Format2 >
cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::smoothed_aggregation ( const smoothed_aggregation< IndexType, ValueType, MemorySpace2, SmootherType2, SolverType2, Format2 > &  M)

Construct a smoothed_aggregation preconditioner from a existing SA smoothed_aggregation preconditioner.

Parameters
Mother smoothed_aggregation preconditioner.

Member Function Documentation

template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
template<typename MatrixType >
void cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::initialize ( const MatrixType &  A)

Initialize a smoothed_aggregation preconditioner from a matrix. Used to initialize a smoothed_aggregation preconditioner constructed with no input matrix specified.

Parameters
Amatrix used to create the AMG hierarchy.
template<typename IndexType, typename ValueType, typename MemorySpace, typename SmootherType = thrust::use_default, typename SolverType = thrust::use_default, typename Format = thrust::use_default>
template<typename MatrixType , typename ArrayType >
void cusp::precond::aggregation::smoothed_aggregation< IndexType, ValueType, MemorySpace, SmootherType, SolverType, Format >::initialize ( const MatrixType &  A,
const ArrayType &  B,
typename thrust::detail::enable_if_convertible< typename MatrixType::format, cusp::known_format >::type *  = 0 
)

Initialize a smoothed_aggregation preconditioner from a matrix and initial near nullspace vector. Used to initialize a smoothed_aggregation preconditioner constructed with no input matrix specified.

Parameters
Amatrix used to create the AMG hierarchy.
Bcandidate near nullspace vector.