tk::ConjugateGradients class

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

Constructors, destructors, conversion operators

ConjugateGradients(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 std::unordered_map<int, std::unordered_set<std::size_t>>& nodecommmap) explicit
Constructor taking a tuple of {A,x,b} by rvalue reference.
ConjugateGradients(CkMigrateMessage* m) 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 std::unordered_map<int, std::unordered_set<std::size_t>>& nodecommmap = {}) -> ConjugateGradients_SDAG_CODE explicit
Constructor.
void solve(std::size_t maxit, tk::real tol, int pe, uint64_t verbose, CkCallback c)
Solve linear system.
void init(const std::vector<tk::real>& x, const std::vector<tk::real>& b, const std::vector<tk::real>& neubc, const std::unordered_map<std::size_t, std::vector<std::pair<int, tk::real>>>& dirbc, const std::string& pc, 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,z)
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::map<std::size_t, std::vector<std::pair<int, tk::real>>>& dbc, const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)
Receive contributions to boundary conditions and rhs on chare-boundaries.
void comr(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& rc)
Receive contributions to rhs with Dirichlet BCs applied on chare-boundaries.
void comd(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)
Receive contributions to preconditioner 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)
Receive contributions to final solution on chare-boundaries.
void pq(tk::real d)
Compute the dot product (p,q)
void normres(tk::real r)
Compute the norm of the residual (r,r)
void rz(tk::real rz)
Compute the dot product (r,z)
auto solution() const -> const std::vector<tk::real>&
Access solution.
auto converged() const -> bool
Return convergence flag.
auto it() const -> std::size_t
Return number of iterations taken.

Pack/unpack (Charm++ serialization) routines

void pup(PUP::er& p) override
Pack/Unpack serialize member function.
void operator|(PUP::er& p, ConjugateGradients& c)
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 std::unordered_map<int, std::unordered_set<std::size_t>>& 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, int pe, uint64_t verbose, CkCallback c)

Solve linear system.

Parameters
maxit in Max iteration count
tol in Stop tolerance
pe in Processing element
verbose in Verbose output
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::vector<tk::real>& neubc, const std::unordered_map<std::size_t, std::vector<std::pair<int, tk::real>>>& dirbc, const std::string& pc, CkCallback cb)

Initialize linear solve: set initial guess and boundary conditions.

Parameters
in Initial guess
in Right hand side vector
neubc in Right hand side vector with Neumann BCs partially applied
dirbc in Local node ids and associated Dirichlet BCs
pc in Preconditioner to use
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. It also performs communication of BC data.

void tk::ConjugateGradients::setup(CkCallback c)

Setup solver.

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

void tk::ConjugateGradients::normb(tk::real n)

Compute the norm of the right hand side.

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

void tk::ConjugateGradients::rho(tk::real r)

Compute rho = (r,z)

Parameters
in Dot product, rho = (r,z) (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::map<std::size_t, std::vector<std::pair<int, tk::real>>>& dbc, const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)

Receive contributions to boundary conditions and rhs on chare-boundaries.

Parameters
dbc in Contributions to Dirichlet boundary conditions
gid in Global mesh node IDs at which we receive contributions
qc in Contributions to Neumann boundary conditions

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

Receive contributions to rhs with Dirichlet BCs applied 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::comd(const std::vector<std::size_t>& gid, const std::vector<std::vector<tk::real>>& qc)

Receive contributions to preconditioner 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::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)

Receive contributions to final solution on chare-boundaries.

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

void tk::ConjugateGradients::pq(tk::real d)

Compute the dot product (p,q)

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

void tk::ConjugateGradients::normres(tk::real r)

Compute the norm of the residual (r,r)

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

void tk::ConjugateGradients::rz(tk::real rz)

Compute the dot product (r,z)

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

void tk::ConjugateGradients::pup(PUP::er& p) override

Pack/Unpack serialize member function.

Parameters
in/out Charm++'s PUP::er serializer object reference

void tk::ConjugateGradients::operator|(PUP::er& p, ConjugateGradients& c)

Pack/Unpack serialize operator|.

Parameters
in/out Charm++'s PUP::er serializer object reference
in/out ConjugateGradients object reference