1 #ifndef DDMD_GROUP_COLLECTOR_TPP 2 #define DDMD_GROUP_COLLECTOR_TPP 11 #include "GroupCollector.h" 14 #include <ddMd/storage/GroupStorage.tpp> 30 recvArrayCapacity_(256),
52 storagePtr_ = &storage;
62 if (recvArrayCapacity <= 0) {
63 UTIL_THROW(
"Attempt to set nonpositive recvArrayCapacity");
65 if (recvArray_.capacity() > 0) {
66 UTIL_THROW(
"Attempt to set recvArrayCapacity after allocation");
68 recvArrayCapacity_ = recvArrayCapacity;
79 UTIL_THROW(
"Collector not initialized: No associated domain");
92 if (recvArray_.capacity() == 0) {
93 if (recvArrayCapacity_ == 0) {
96 recvArray_.allocate(recvArrayCapacity_);
106 storagePtr_->begin(iterator_);
117 if (domainPtr_ == 0) {
118 UTIL_THROW(
"GroupCollector has not been initialized");
126 if (recvArray_.capacity() <= 0) {
134 while (!isComplete_) {
135 if (iterator_.notEnd()) {
136 groupPtr = iterator_.get();
138 atomPtr = groupPtr->
atomPtr(0);
154 while (recvArrayId_ == recvArraySize_) {
157 if (recvBufferSize_ == 0) {
166 if (source_ == domainPtr_->
grid().
size()) {
173 int message = source_;
180 recvBufferSize_ = bufferPtr_->
recvSize();
184 if (recvBufferSize_ > 0) {
188 && recvArraySize_ < recvArray_.capacity())
190 recvArray_[recvArraySize_].unpack(*bufferPtr_);
193 if (recvBufferSize_ != bufferPtr_->
recvSize()) {
194 UTIL_THROW(
"Inconsistent buffer receive counters");
203 return &recvArray_[recvArrayId_ - 1];
218 UTIL_THROW(
"Collector not initialized: null domainPtr_");
224 UTIL_THROW(
"GroupCollector<N>::send() called from master node.");
227 UTIL_THROW(
"Collector not initialized: Null storagePtr_");
229 if (storagePtr_->capacity() <= 0) {
233 UTIL_THROW(
"Collector not initialized: Null bufferPtr_");
245 storagePtr_->begin(iterator_);
248 while (!isComplete_) {
252 domainPtr_->
communicator().Recv(&message, 1, MPI::INT, 0, tag);
255 int recvArraySize_ = 0;
256 isComplete_ = iterator_.isEnd();
259 while (recvArraySize_ < bufferCapacity && !isComplete_) {
262 atomPtr = iterator_->atomPtr(0);
265 iterator_->pack(*bufferPtr_);
270 isComplete_ = iterator_.isEnd();
283 #endif // ifndef DDMD_GROUP_COLLECTOR_TPP void setup()
Setup master processor for receiving.
bool beginRecvBlock()
Begin to receive a block from the recv buffer.
int groupCapacity() const
Maximum number of group<N> objects for which space is available.
Group< N > * nextPtr()
Return a pointer to the next available atom, or null.
bool isInitialized() const
Has this Domain been initialized by calling readParam?
void beginSendBlock(int sendType)
Initialize a data block.
Atom * atomPtr(int i) const
Get a pointer to a specific Atom.
A point particle in an MD simulation.
Parallel domain decomposition (DD) MD simulation.
MPI::Intracomm & communicator() const
Return Cartesian communicator by reference.
GroupCollector()
Constructor.
int size() const
Get total number of grid points.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool isGhost() const
Is this atom a ghost?
Utility classes for scientific computation.
void setCapacity(int recvArrayCapacity)
Set size of cache for receiving groups on the master.
A container for all the Group<N> objects on this processor.
int recvSize() const
Number of unread items left in current recv block.
void send(MPI::Intracomm &comm, int dest)
Send a complete buffer.
const Grid & grid() const
Return processor Grid by const reference.
bool isMaster() const
Is this the master processor (gridRank == 0) ?
Buffer for interprocessor communication.
Decomposition of the system into domains associated with processors.
void recv(MPI::Intracomm &comm, int source)
Receive a buffer.
void send()
Send all groups on this processor to the master processor.
~GroupCollector()
Destructor.
void associate(Domain &domain, GroupStorage< N > &storage, Buffer &buffer)
Initialize pointers to associated objects.
void endSendBlock(bool isComplete=true)
Finalize a block in the send buffer.
void setClassName(const char *className)
Set class name string.
bool isInitialized() const
Has this Buffer been initialized?
A group of covalently interacting atoms.
void clearSendBuffer()
Clear the send buffer.