ConjugateGradients Charm++ chare array used to perform a distributed linear solve with the conjugate gradients algorithm.

• Reference

## Constructors, destructors, conversion operators

std::tuple<tk::CSR, std::vector<tk::real>, std::vector<tk::real>>&& system, const std::vector<std::size_t>& gid, const std::unordered_map<std::size_t, std::size_t>& lid, const NodeCommMap& nodecommmap) explicit
Constructor taking a tuple of {A,x,b} by rvalue reference.
CkMigrateMessage*) explicit
Migrate constructor.

## Public functions

auto ConjugateGradients(const CSR& A, const std::vector<tk::real>& x, const std::vector<tk::real>& b, const std::vector<std::size_t>& gid, const std::unordered_map<std::size_t, std::size_t>& lid, const NodeCommMap& nodecommmap) -> ConjugateGradients_SDAG_CODE explicit
Constructor.
void solve(std::size_t maxit, tk::real tol, CkCallback c)
Solve linear system.
void init(const std::vector<tk::real>& x, const std::vector<tk::real>& b, const std::unordered_map<std::size_t, std::vector<std::pair<bool, tk::real>>>& bc, std::size_t ignorebc, CkCallback cb)
Initialize linear solve: set initial guess and boundary conditions.
void setup(CkCallback c)
Setup solver.
void normb(tk::real n)
Compute the norm of the right hand side.
void rho(tk::real r)
Compute rho = (r,r)
void comres(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& rc)
Receive contributions to r = b - A * x on chare-boundaries.
void combc(const std::unordered_map<std::size_t, std::vector<std::pair<bool, tk::real>>>& bc)
Receive contributions to boundary conditions on chare-boundaries.
void comq(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)
Receive contributions to q = A * p on chare-boundaries.
void comx(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& xc)
void pq(tk::real d)
Compute the dot product (p,q)
void normres(tk::real r)
Compute the norm of the residual: (r,r)
auto solution() const -> std::vector<tk::real>
Access solution.
auto converged() const -> bool
Return convergence flag.

## Pack/unpack (Charm++ serialization) routines

void pup(PUP::er& p) override
Pack/Unpack serialize member function.
Pack/Unpack serialize operator|.

## Function documentation

### ConjugateGradients_SDAG_CODE tk::ConjugateGradients::ConjugateGradients(const CSR& A, const std::vector<tk::real>& x, const std::vector<tk::real>& b, const std::vector<std::size_t>& gid, const std::unordered_map<std::size_t, std::size_t>& lid, const NodeCommMap& nodecommmap) explicit

Constructor.

Parameters
in Left hand side matrix of the linear system to solve in Ax=b
in Solution (initial guess) of the linear system to solve in Ax=b
in Right hand side of the linear system to solve in Ax=b
gid in Global node ids
lid in Local node ids associated to global ones
nodecommmap in Global mesh node IDs shared with other chares associated to their chare IDs

### void tk::ConjugateGradients::solve(std::size_t maxit, tk::real tol, CkCallback c)

Solve linear system.

Parameters
maxit in Max iteration count
tol in Stop tolerance
in Call to continue with after solve is complete

### void tk::ConjugateGradients::init(const std::vector<tk::real>& x, const std::vector<tk::real>& b, const std::unordered_map<std::size_t, std::vector<std::pair<bool, tk::real>>>& bc, std::size_t ignorebc, CkCallback cb)

Initialize linear solve: set initial guess and boundary conditions.

Parameters
in Initial guess
in Right hand side vector
bc in Local node ids and associated Dirichlet BCs
ignorebc in True if applyin BCs should be skipped
cb in Call to continue with when initialized and ready for a solve

This function allows setting the initial guess and boundary conditions, followed by computing the initial residual and the rhs norm.

Setup solver.

Parameters
in Call to continue with after initialization is complete

This function initiates computing the residual (r=b-A*x), its dot product, and the rhs norm.

Compute the norm of the right hand side.

Parameters
in Norm of right hand side (aggregated across all chares)

Compute rho = (r,r)

Parameters
in Dot product, rho = (r,r) (aggregated across all chares)

### void tk::ConjugateGradients::comres(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& rc)

Receive contributions to r = b - A * x on chare-boundaries.

Parameters
gid in Global mesh node IDs at which we receive contributions
rc in Partial contributions at chare-boundary nodes

### void tk::ConjugateGradients::combc(const std::unordered_map<std::size_t, std::vector<std::pair<bool, tk::real>>>& bc)

Receive contributions to boundary conditions on chare-boundaries.

Parameters
bc in Contributions to boundary conditions

### void tk::ConjugateGradients::comq(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)

Receive contributions to q = A * p on chare-boundaries.

Parameters
gid in Global mesh node IDs at which we receive contributions
qc in Partial contributions at chare-boundary nodes

### void tk::ConjugateGradients::comx(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& xc)

Parameters
gid in Global mesh node IDs at which we receive contributions
xc in Partial contributions at chare-boundary nodes

Compute the dot product (p,q)

Parameters
in Dot product of (p,q) (aggregated across all chares)

Compute the norm of the residual: (r,r)

Parameters
in Dot product, (r,r) (aggregated across all chares)