1#ifndef AMREX_KRYLOV_MV_H_
2#define AMREX_KRYLOV_MV_H_
17template <
typename V,
typename M>
class GMRES;
28template <
template <
typename,
typename>
class S,
typename T>
37 using PC = std::function<void(
VEC&,
VEC const&)>;
71 void solve (
VEC& a_sol,
VEC const& a_rhs, T a_tol_rel, T a_tol_abs);
122 MAT const* m_mat =
nullptr;
126template <
template <
typename,
typename>
class S,
typename T>
130 m_solver.define(*
this);
133template <
template <
typename,
typename>
class S,
typename T>
136 m_solver.solve(a_sol, a_rhs, a_tol_rel, a_tol_abs);
139template <
template <
typename,
typename>
class S,
typename T>
142 return VEC(m_mat->partition());
145template <
template <
typename,
typename>
class S,
typename T>
148 return VEC(m_mat->partition());
151template <
template <
typename,
typename>
class S,
typename T>
157template <
template <
typename,
typename>
class S,
typename T>
163template <
template <
typename,
typename>
class S,
typename T>
169template <
template <
typename,
typename>
class S,
typename T>
175template <
template <
typename,
typename>
class S,
typename T>
181template <
template <
typename,
typename>
class S,
typename T>
187template <
template <
typename,
typename>
class S,
typename T>
193template <
template <
typename,
typename>
class S,
typename T>
199template <
template <
typename,
typename>
class S,
typename T>
Distributed dense vector that mirrors the layout of an AlgPartition.
Definition AMReX_AlgVector.H:29
void setValAsync(T val)
Definition AMReX_AlgVector.H:280
T norm2(bool local=false) const
Return the 2-norm.
Definition AMReX_AlgVector.H:383
void copyAsync(AlgVector< T, Allocator > const &rhs)
Definition AMReX_AlgVector.H:295
void scaleAsync(T scale_factor)
Definition AMReX_AlgVector.H:329
GMRES.
Definition AMReX_GMRES.H:87
Binds a Krylov solver to an SpMatrix.
Definition AMReX_KrylovMV.H:30
VEC makeVecRHS() const
Return an AlgVector that mirrors the matrix partition for RHS storage.
Definition AMReX_KrylovMV.H:140
static void assign(VEC &lhs, VEC const &rhs)
Copy rhs into lhs.
Definition AMReX_KrylovMV.H:176
static void increment(VEC &lhs, VEC const &rhs, T a)
Accumulate lhs += a * rhs.
Definition AMReX_KrylovMV.H:182
void setPrecond(PC a_pc)
Supply an optional right-preconditioner functor.
Definition AMReX_KrylovMV.H:61
void solve(VEC &a_sol, VEC const &a_rhs, T a_tol_rel, T a_tol_abs)
Solve the linear system.
Definition AMReX_KrylovMV.H:134
static T dotProduct(VEC const &vec1, VEC const &vec2)
Dot product between vec1 and vec2.
Definition AMReX_KrylovMV.H:164
static void setToZero(VEC &lhs)
Reset lhs to zero.
Definition AMReX_KrylovMV.H:170
T RT
Definition AMReX_KrylovMV.H:32
void precond(VEC &lhs, VEC const &rhs) const
Apply the optional preconditioner (or copy if none is provided).
Definition AMReX_KrylovMV.H:200
std::function< void(VEC &, VEC const &)> PC
Definition AMReX_KrylovMV.H:37
KrylovMV(const KrylovMV &)=delete
S< VEC, KrylovMV< S, T > > Solver
Definition AMReX_KrylovMV.H:35
static T norm2(VEC const &vec)
Euclidean norm of vec.
Definition AMReX_KrylovMV.H:152
void apply(VEC &lhs, VEC &rhs) const
Apply the sparse operator: lhs = A rhs.
Definition AMReX_KrylovMV.H:194
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.
Definition AMReX_KrylovMV.H:188
KrylovMV(KrylovMV &&)=delete
Solver & getGMRES()
Same as getSolver(), for GMRES_MV only.
Definition AMReX_KrylovMV.H:80
Solver & getSolver()
Access the underlying solver for additional settings and results.
Definition AMReX_KrylovMV.H:77
Solver GM
Definition AMReX_KrylovMV.H:36
void setVerbose(int v)
Set verbosity level v for the underlying solver.
Definition AMReX_KrylovMV.H:74
static void scale(VEC &vec, T scale_factor)
Scale vec in place by scale_factor.
Definition AMReX_KrylovMV.H:158
KrylovMV(MAT const *a_mat)
Bind the solver to a sparse matrix described by a_mat.
Definition AMReX_KrylovMV.H:127
VEC makeVecLHS() const
Return another AlgVector with the same partition for LHS storage.
Definition AMReX_KrylovMV.H:146
KrylovMV & operator=(const KrylovMV &)=delete
Distributed CSR matrix that manages storage and GPU-friendly partitions.
Definition AMReX_SpMatrix.H:65
Definition AMReX_Amr.cpp:50
FAB::value_type Dot(FabArray< FAB > const &x, int xcomp, FabArray< FAB > const &y, int ycomp, int ncomp, IntVect const &nghost, bool local=false)
Compute dot products of two FabArrays.
Definition AMReX_FabArrayUtility.H:1898
void LinComb(MF &dst, typename MF::value_type a, MF const &src_a, int acomp, typename MF::value_type b, MF const &src_b, int bcomp, int dcomp, int ncomp, IntVect const &nghost)
dst = a*src_a + b*src_b
Definition AMReX_FabArrayUtility.H:2241
void Axpy(AlgVector< T, Allocator > &y, T a, AlgVector< T, Allocator > const &x)
y = ax + y. For GPU builds this is asynchronous with respect to the host.
Definition AMReX_AlgVecUtil.H:188
void SpMV(Long nrows, Long ncols, T *__restrict__ py, CsrView< T const, I > const &A, T const *__restrict__ px)
Perform y = A * x using CSR data (GPU/CPU aware).
Definition AMReX_SpMV.H:30