Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::KrylovMV< S, T > Class Template Reference

Binds a Krylov solver to an SpMatrix. More...

#include <AMReX_KrylovMV.H>

Public Types

using RT = T
 
using VEC = AlgVector< T >
 
using MAT = SpMatrix< T >
 
using Solver = S< VEC, KrylovMV< S, T > >
 
using GM = Solver
 
using PC = std::function< void(VEC &, VEC const &)>
 

Public Member Functions

 KrylovMV (MAT const *a_mat)
 Bind the solver to a sparse matrix described by a_mat.
 
 ~KrylovMV ()=default
 
 KrylovMV (const KrylovMV &)=delete
 
 KrylovMV (KrylovMV &&)=delete
 
KrylovMV & operator= (const KrylovMV &)=delete
 
KrylovMV & operator= (KrylovMV &&)=delete
 
void setPrecond (PC a_pc)
 Supply an optional right-preconditioner functor.
 
void solve (VEC &a_sol, VEC const &a_rhs, T a_tol_rel, T a_tol_abs)
 Solve the linear system.
 
void setVerbose (int v)
 Set verbosity level v for the underlying solver.
 
Solver & getSolver ()
 Access the underlying solver for additional settings and results.
 
Solver & getGMRES ()
 Same as getSolver(), for GMRES_MV only.
 
VEC makeVecRHS () const
 Return an AlgVector that mirrors the matrix partition for RHS storage.
 
VEC makeVecLHS () const
 Return another AlgVector with the same partition for LHS storage.
 
void apply (VEC &lhs, VEC &rhs) const
 Apply the sparse operator: lhs = A rhs.
 
void precond (VEC &lhs, VEC const &rhs) const
 Apply the optional preconditioner (or copy if none is provided).
 

Static Public Member Functions

static T norm2 (VEC const &vec)
 Euclidean norm of vec.
 
static void scale (VEC &vec, T scale_factor)
 Scale vec in place by scale_factor.
 
static T dotProduct (VEC const &vec1, VEC const &vec2)
 Dot product between vec1 and vec2.
 
static void setToZero (VEC &lhs)
 Reset lhs to zero.
 
static void assign (VEC &lhs, VEC const &rhs)
 Copy rhs into lhs.
 
static void increment (VEC &lhs, VEC const &rhs, T a)
 Accumulate lhs += a * rhs.
 
static void linComb (VEC &lhs, T a, VEC const &rhs_a, T b, VEC const &rhs_b)
 Form the linear combination lhs = a * rhs_a + b * rhs_b.
 

Detailed Description

template<template< typename, typename > class S, typename T>
class amrex::KrylovMV< S, T >

Binds a Krylov solver to an SpMatrix.

Template Parameters
SKrylov solver class template with the GMRES operator interface, e.g., GMRES, BiCGStab or PCG.
TValue type of the matrix and vectors (double or float).

Use the aliases GMRES_MV, BiCGStab_MV and PCG_MV.

Member Typedef Documentation

◆ GM

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::GM = Solver

◆ MAT

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::MAT = SpMatrix<T>

◆ PC

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::PC = std::function<void(VEC&,VEC const&)>

◆ RT

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::RT = T

◆ Solver

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::Solver = S<VEC,KrylovMV<S,T> >

◆ VEC

template<template< typename, typename > class S, typename T >
using amrex::KrylovMV< S, T >::VEC = AlgVector<T>

Constructor & Destructor Documentation

◆ KrylovMV() [1/3]

template<template< typename, typename > class S, typename T >
amrex::KrylovMV< S, T >::KrylovMV ( MAT const *  a_mat)

Bind the solver to a sparse matrix described by a_mat.

Parameters
a_matMatrix supplying the SpMV operation and partition.

◆ ~KrylovMV()

template<template< typename, typename > class S, typename T >
amrex::KrylovMV< S, T >::~KrylovMV ( )
default

◆ KrylovMV() [2/3]

template<template< typename, typename > class S, typename T >
amrex::KrylovMV< S, T >::KrylovMV ( const KrylovMV< S, T > &  )
delete

◆ KrylovMV() [3/3]

template<template< typename, typename > class S, typename T >
amrex::KrylovMV< S, T >::KrylovMV ( KrylovMV< S, T > &&  )
delete

Member Function Documentation

◆ apply()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::apply ( VEC &  lhs,
VEC &  rhs 
) const

Apply the sparse operator: lhs = A rhs.

rhs is non-const to satisfy the solver interface.

◆ assign()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::assign ( VEC &  lhs,
VEC const &  rhs 
)
static

Copy rhs into lhs.

◆ dotProduct()

template<template< typename, typename > class S, typename T >
T amrex::KrylovMV< S, T >::dotProduct ( VEC const &  vec1,
VEC const &  vec2 
)
static

Dot product between vec1 and vec2.

◆ getGMRES()

template<template< typename, typename > class S, typename T >
Solver & amrex::KrylovMV< S, T >::getGMRES ( )
inline

Same as getSolver(), for GMRES_MV only.

◆ getSolver()

template<template< typename, typename > class S, typename T >
Solver & amrex::KrylovMV< S, T >::getSolver ( )
inline

Access the underlying solver for additional settings and results.

◆ increment()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::increment ( VEC &  lhs,
VEC const &  rhs,
T  a 
)
static

Accumulate lhs += a * rhs.

◆ linComb()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::linComb ( VEC &  lhs,
T  a,
VEC const &  rhs_a,
T  b,
VEC const &  rhs_b 
)
static

Form the linear combination lhs = a * rhs_a + b * rhs_b.

◆ makeVecLHS()

template<template< typename, typename > class S, typename T >
auto amrex::KrylovMV< S, T >::makeVecLHS ( ) const

Return another AlgVector with the same partition for LHS storage.

◆ makeVecRHS()

template<template< typename, typename > class S, typename T >
auto amrex::KrylovMV< S, T >::makeVecRHS ( ) const

Return an AlgVector that mirrors the matrix partition for RHS storage.

◆ norm2()

template<template< typename, typename > class S, typename T >
T amrex::KrylovMV< S, T >::norm2 ( VEC const &  vec)
static

Euclidean norm of vec.

◆ operator=() [1/2]

template<template< typename, typename > class S, typename T >
KrylovMV & amrex::KrylovMV< S, T >::operator= ( const KrylovMV< S, T > &  )
delete

◆ operator=() [2/2]

template<template< typename, typename > class S, typename T >
KrylovMV & amrex::KrylovMV< S, T >::operator= ( KrylovMV< S, T > &&  )
delete

◆ precond()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::precond ( VEC &  lhs,
VEC const &  rhs 
) const

Apply the optional preconditioner (or copy if none is provided).

◆ scale()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::scale ( VEC &  vec,
T  scale_factor 
)
static

Scale vec in place by scale_factor.

◆ setPrecond()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::setPrecond ( PC  a_pc)
inline

Supply an optional right-preconditioner functor.

The functor must follow the signature void(VEC& lhs, VEC const& rhs).

Parameters
a_pcCallable that computes lhs = P^{-1}(rhs).

◆ setToZero()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::setToZero ( VEC &  lhs)
static

Reset lhs to zero.

◆ setVerbose()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::setVerbose ( int  v)
inline

Set verbosity level v for the underlying solver.

◆ solve()

template<template< typename, typename > class S, typename T >
void amrex::KrylovMV< S, T >::solve ( VEC &  a_sol,
VEC const &  a_rhs,
T  a_tol_rel,
T  a_tol_abs 
)

Solve the linear system.

Parameters
a_solunknowns, i.e., x in A x = b.
a_rhsRHS, i.e., b in A x = b.
a_tol_relrelative tolerance.
a_tol_absabsolute tolerance.

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