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 466 of file GlobalMasterServer.C.

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

00467                                                               {
00468   DebugM(3,"Constructing GlobalMasterServer\n");
00469   myComputeManager = m;
00470   numDataSenders = 0; // theNumDataSenders;
00471   numForceSenders = 0;
00472   latticeCount = 0;
00473   lattice = Node::Object()->simParameters->lattice;
00474   recvCount = 0; /* we haven't gotten any messages yet */
00475   firstTime = 1; /* XXX temporary */
00476   step = -1;
00477   totalAtomsRequested = 0;
00478   totalGroupsRequested = 0;
00479   forceSendEnabled = 0;
00480   if ( Node::Object()->simParameters->tclForcesOn ) forceSendEnabled = 1;
00481   if ( Node::Object()->simParameters->colvarsOn ) forceSendEnabled = 1;
00482   DebugM(3,"done constructing\n");
00483 }

GlobalMasterServer::~GlobalMasterServer (  )  [virtual]

Definition at line 485 of file GlobalMasterServer.C.

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

00485                                         {
00486   GlobalMaster *m_i = *clientList.begin();
00487   GlobalMaster *m_e = *clientList.end();
00488   
00489   /* delete each of the masters */
00490   while(m_i != m_e) {
00491     delete m_i;
00492     m_i++;
00493   }
00494 }


Member Function Documentation

void GlobalMasterServer::addClient ( GlobalMaster newClient  ) 

Definition at line 30 of file GlobalMasterServer.C.

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

Referenced by ComputeMgr::createComputes().

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

void GlobalMasterServer::recvData ( ComputeGlobalDataMsg msg  ) 

Definition at line 37 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().

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


The documentation for this class was generated from the following files:

Generated on 8 Dec 2019 for NAMD by  doxygen 1.6.1