class
ConjugateGradientsConjugateGradients 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 | |
---|---|
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::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 | |
---|---|
x in | Initial guess |
b 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:: 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:: 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:: 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 |