class
ConjugateGradientsConjugateGradients Charm++ chare array used to perform a distributed linear solve with the conjugate gradients algorithm.
Contents
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 NodeCommMap& nodecommmap) explicit - Constructor taking a tuple of {A,x,b} by rvalue reference.
- ConjugateGradients(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.
- 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 NodeCommMap& nodecommmap) explicit
Constructor.
Parameters | |
---|---|
A in | Left hand side matrix of the linear system to solve in Ax=b |
x in | Solution (initial guess) of the linear system to solve in Ax=b |
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:: 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 | |
---|---|
x in | Initial guess |
b 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.
void tk:: ConjugateGradients:: setup(CkCallback c)
Setup solver.
Parameters | |
---|---|
c 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.
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:: pup(PUP::er& p) override
Pack/Unpack serialize member function.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |
void tk:: ConjugateGradients:: operator|(PUP::er& p,
ConjugateGradients& c)
Pack/Unpack serialize operator|.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |
c in/out | ConjugateGradients object reference |