GlobalMasterServer Class Reference

#include <GlobalMasterServer.h>

List of all members.

Public Member Functions

 GlobalMasterServer (ComputeMgr *m, int theNumDataSenders)
virtual ~GlobalMasterServer ()
void recvData (ComputeGlobalDataMsg *)
void addClient (GlobalMaster *newClient)


Detailed Description

Definition at line 22 of file GlobalMasterServer.h.


Constructor & Destructor Documentation

GlobalMasterServer::GlobalMasterServer ( ComputeMgr m,
int  theNumDataSenders 
)

Definition at line 449 of file GlobalMasterServer.C.

References DebugM, SimParameters::lattice, Node::Object(), and Node::simParameters.

00450                                                               {
00451   DebugM(3,"Constructing GlobalMasterServer\n");
00452   myComputeManager = m;
00453   numDataSenders = 0; // theNumDataSenders;
00454   numForceSenders = 0;
00455   latticeCount = 0;
00456   lattice = Node::Object()->simParameters->lattice;
00457   recvCount = 0; /* we haven't gotten any messages yet */
00458   firstTime = 1; /* XXX temporary */
00459   step = -1;
00460   totalAtomsRequested = 0;
00461   totalGroupsRequested = 0;
00462   forceSendEnabled = 0;
00463   if ( Node::Object()->simParameters->tclForcesOn ) forceSendEnabled = 1;
00464   if ( Node::Object()->simParameters->colvarsOn ) forceSendEnabled = 1;
00465   DebugM(3,"done constructing\n");
00466 }

GlobalMasterServer::~GlobalMasterServer (  )  [virtual]

Definition at line 468 of file GlobalMasterServer.C.

References ResizeArray< Elem >::begin(), and ResizeArray< Elem >::end().

00468                                         {
00469   GlobalMaster *m_i = *clientList.begin();
00470   GlobalMaster *m_e = *clientList.end();
00471   
00472   /* delete each of the masters */
00473   while(m_i != m_e) {
00474     delete m_i;
00475     m_i++;
00476   }
00477 }


Member Function Documentation

void GlobalMasterServer::addClient ( GlobalMaster newClient  ) 

Definition at line 29 of file GlobalMasterServer.C.

References ResizeArray< Elem >::add(), DebugM, and GlobalMaster::setLattice().

Referenced by ComputeMgr::createComputes().

00029                                                           {
00030   DebugM(3,"Adding client\n");
00031   clientList.add(newClient);
00032   newClient->setLattice(&lattice);
00033   DebugM(2,"Added.\n");
00034 }

void GlobalMasterServer::recvData ( ComputeGlobalDataMsg  ) 

Definition at line 36 of file GlobalMasterServer.C.

References ResizeArray< Elem >::add(), ComputeGlobalDataMsg::aid, ResizeArray< Elem >::begin(), ComputeGlobalDataMsg::count, DebugM, ResizeArray< Elem >::end(), ComputeGlobalDataMsg::fid, ComputeGlobalDataMsg::gcom, ComputeGlobalDataMsg::gmass, ComputeGlobalDataMsg::gtf, ComputeGlobalDataMsg::lat, NAMD_bug(), ComputeGlobalDataMsg::p, ResizeArray< Elem >::resize(), ResizeArray< Elem >::setall(), ResizeArray< Elem >::size(), ComputeGlobalDataMsg::step, and ComputeGlobalDataMsg::tf.

Referenced by ComputeMgr::recvComputeGlobalData().

00036                                                            {
00037   DebugM(3,"Storing data (" << msg->aid.size() << " positions) on master\n");
00038 
00039   if ( msg->step != -1 ) step = msg->step;
00040 
00041   /* get the beginning and end of the lists */
00042   AtomIDList::iterator a_i = msg->aid.begin();
00043   AtomIDList::iterator a_e = msg->aid.end();
00044   PositionList::iterator p_i = msg->p.begin();
00045   PositionList::iterator g_i = msg->gcom.begin();
00046   PositionList::iterator g_e = msg->gcom.end();
00047   BigRealList::iterator gm_i = msg->gmass.begin();
00048 
00049   /* iterate over each member of the atom lists */
00050   for ( ; a_i != a_e; ++a_i, ++p_i ) {
00051     receivedAtomIDs.add(*a_i);
00052     receivedAtomPositions.add(*p_i);
00053   }
00054   
00055   /* iterate over each member of "total force" lists */
00056   a_e = msg->fid.end();
00057   ForceList::iterator f_i=msg->tf.begin();
00058   for (a_i=msg->fid.begin() ; a_i!=a_e; ++a_i,++f_i) {
00059     receivedForceIDs.add(*a_i);
00060     receivedTotalForces.add(*f_i);
00061   }
00062 
00063   /* iterate over each member of the group position list */
00064   int i=0;
00065   for ( ; g_i != g_e; ++g_i, ++gm_i ) {
00066     DebugM(1,"Received center of mass "<<*g_i<<"\n");
00067     if(i >= totalGroupsRequested) NAMD_bug("Received too many groups.");
00068     receivedGroupPositions[i] += (*g_i);
00069     receivedGroupMasses[i] += (*gm_i);
00070     i++;
00071   }
00072   if(i!=totalGroupsRequested) NAMD_bug("Received too few groups.");
00073 
00074   /* iterate over each member of group total force lists */
00075   int ntf = msg->gtf.size();
00076   if ( ntf && ntf != receivedGroupTotalForces.size() ) NAMD_bug("Received wrong number of group forces.");
00077   ForceList::iterator gf_i=msg->gtf.begin();
00078   ForceList::iterator gf_e=msg->gtf.end();
00079   for ( i=0 ; gf_i != gf_e; ++gf_i, ++i ) {
00080     receivedGroupTotalForces[i] += (*gf_i);
00081   }
00082 
00083   if ( msg->lat.size() ) {
00084     if ( latticeCount ) {
00085       NAMD_bug("GlobalMasterServer::recvData received lattice twice.");
00086     }
00087     lattice = msg->lat[0];
00088     latticeCount = 1;
00089   }
00090 
00091   recvCount += msg->count;
00092 
00093   /* done with the message, delete it */
00094   delete msg;
00095 
00096   /* check whether we've gotten all the expected messages */
00097   if(recvCount > numDataSenders + numForceSenders + 1) {
00098     NAMD_bug("GlobalMasterServer::recvData recvCount too high.");
00099   }
00100   if(recvCount == numDataSenders + numForceSenders + 1) {
00101     if ( ! latticeCount ) {
00102       NAMD_bug("GlobalMasterServer::recvData did not receive lattice.");
00103     }
00104 
00105     int oldTotalGroupsRequested = totalGroupsRequested;
00106 
00107     DebugM(3,"received messages from each of the ComputeGlobals\n");
00108     int resendCoordinates = callClients();
00109 
00110     /* now restart */
00111     step = -1;
00112     receivedAtomIDs.resize(0);
00113     receivedAtomPositions.resize(0);
00114     receivedGroupPositions.resize(totalGroupsRequested);
00115     receivedGroupPositions.setall(Vector(0,0,0));
00116     receivedGroupMasses.resize(totalGroupsRequested);
00117     receivedGroupMasses.setall(0);
00118     latticeCount = 0;
00119     recvCount = 0;
00120     if ( resendCoordinates ) {
00121       recvCount += numForceSenders;
00122     } else {
00123       receivedGroupTotalForces.resize(totalGroupsRequested);
00124       receivedGroupTotalForces.setall(0);
00125       receivedForceIDs.resize(0);
00126       receivedTotalForces.resize(0);
00127     }
00128   }
00129 }


The documentation for this class was generated from the following files:
Generated on Sun Sep 24 01:17:18 2017 for NAMD by  doxygen 1.4.7