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

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

00581                                                               {
00582   DebugM(3,"Constructing GlobalMasterServer\n");
00583   myComputeManager = m;
00584   numDataSenders = 0; // theNumDataSenders;
00585   numForceSenders = 0;
00586   latticeCount = 0;
00587   lattice = Node::Object()->simParameters->lattice;
00588   recvCount = 0; /* we haven't gotten any messages yet */
00589   recvPatchesCount = 0;
00590   firstTime = 1; /* XXX temporary */
00591   step = -1;
00592   totalAtomsRequested = 0;
00593   totalGroupsRequested = 0;
00594   forceSendEnabled = 0;
00595   if ( Node::Object()->simParameters->tclForcesOn ) forceSendEnabled = 1;
00596   if ( Node::Object()->simParameters->colvarsOn ) forceSendEnabled = 1;
00597   DebugM(3,"done constructing\n");
00598 }

GlobalMasterServer::~GlobalMasterServer (  )  [virtual]

Definition at line 600 of file GlobalMasterServer.C.

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

00600                                         {
00601   GlobalMaster *m_i = *clientList.begin();
00602   GlobalMaster *m_e = *clientList.end();
00603   
00604   /* delete each of the masters */
00605   while(m_i != m_e) {
00606     delete m_i;
00607     m_i++;
00608   }
00609 }


Member Function Documentation

void GlobalMasterServer::addClient ( GlobalMaster newClient  ) 

Definition at line 31 of file GlobalMasterServer.C.

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

Referenced by ComputeMgr::createComputes().

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

void GlobalMasterServer::recvData ( ComputeGlobalDataMsg msg  ) 

Definition at line 38 of file GlobalMasterServer.C.

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

Referenced by ComputeMgr::recvComputeGlobalData().

00038                                                            {
00039   DebugM(3,"Storing data (" << msg->aid.size() << " positions) on master\n");
00040 
00041   if ( msg->step != -1 ) step = msg->step;
00042 
00043   /* get the beginning and end of the lists */
00044   AtomIDList::iterator a_i = msg->aid.begin();
00045   AtomIDList::iterator a_e = msg->aid.end();
00046   PositionList::iterator p_i = msg->p.begin();
00047   PositionList::iterator g_i = msg->gcom.begin();
00048   PositionList::iterator g_e = msg->gcom.end();
00049   BigRealList::iterator gm_i = msg->gmass.begin();
00050 
00051   /* iterate over each member of the atom lists */
00052   for ( ; a_i != a_e; ++a_i, ++p_i ) {
00053     receivedAtomIDs.add(*a_i);
00054     receivedAtomPositions.add(*p_i);
00055   }
00056   
00057   /* iterate over each member of "total force" lists */
00058   a_e = msg->fid.end();
00059   ForceList::iterator f_i=msg->tf.begin();
00060   for (a_i=msg->fid.begin() ; a_i!=a_e; ++a_i,++f_i) {
00061     receivedForceIDs.add(*a_i);
00062     receivedTotalForces.add(*f_i);
00063   }
00064 
00065   /* iterate over each member of the group position list */
00066   int i=0;
00067   for ( ; g_i != g_e; ++g_i, ++gm_i ) {
00068     DebugM(1,"Received center of mass "<<*g_i<<"\n");
00069     if(i >= totalGroupsRequested) NAMD_bug("Received too many groups.");
00070     receivedGroupPositions[i] += (*g_i);
00071     receivedGroupMasses[i] += (*gm_i);
00072     i++;
00073   }
00074   if(i!=totalGroupsRequested) NAMD_bug("Received too few groups.");
00075 
00076   /* iterate over each member of group total force lists */
00077   int ntf = msg->gtf.size();
00078   if ( ntf && ntf != receivedGroupTotalForces.size() ) NAMD_bug("Received wrong number of group forces.");
00079   ForceList::iterator gf_i=msg->gtf.begin();
00080   ForceList::iterator gf_e=msg->gtf.end();
00081   for ( i=0 ; gf_i != gf_e; ++gf_i, ++i ) {
00082     receivedGroupTotalForces[i] += (*gf_i);
00083   }
00084 
00085   // Get values of the GridForce objects
00086   int ngov = msg->gridobjvalue.size();
00087   IntList::iterator goi_i = msg->gridobjindex.begin();
00088   BigRealList::iterator gov_i = msg->gridobjvalue.begin();
00089   BigRealList::iterator gov_e = msg->gridobjvalue.end();
00090   for ( i=0 ; gov_i != gov_e; gov_i++, goi_i++, i++ ) {
00091     receivedGridObjIndices[i] = (*goi_i);
00092     receivedGridObjValues[i] += (*gov_i);
00093   }
00094   if (ngov && ngov != receivedGridObjValues.size()) {
00095     NAMD_bug("Received wrong number of grid objects.");
00096   }
00097 
00098   if ( msg->lat.size() ) {
00099     if ( latticeCount ) {
00100       NAMD_bug("GlobalMasterServer::recvData received lattice twice.");
00101     }
00102     lattice = msg->lat[0];
00103     latticeCount = 1;
00104   }
00105 
00106   recvCount += msg->count;
00107   recvPatchesCount += msg->patchcount;
00108   int numPatches = PatchMap::Object()->numPatches();
00109 
00110   /* done with the message, delete it */
00111   delete msg;
00112 
00113   /* check whether we've gotten all the expected messages */
00114 
00115   DebugM(3, "received " << recvCount << " atom messages and "
00116          << recvPatchesCount << " patch messages (out of " << numPatches
00117          << " patches) from the ComputeGlobals\n" << endi);
00118 
00119   int numNeededPatches = totalGridObjsRequested ? numPatches : 0;
00120   if (firstTime) numNeededPatches = 0;
00121 
00122   if (recvCount > numDataSenders + numForceSenders + 1) {
00123     NAMD_bug("GlobalMasterServer::recvData recvCount too high.");
00124   }
00125 
00126   if (recvPatchesCount > numPatches) {
00127     NAMD_bug("GlobalMasterServer::recvData too many patches received.");
00128   }
00129 
00130   if ((recvCount == numDataSenders + numForceSenders + 1) &&
00131       (recvPatchesCount == numNeededPatches)) {
00132 
00133     if ( ! latticeCount ) {
00134       NAMD_bug("GlobalMasterServer::recvData did not receive lattice.");
00135     }
00136 
00137     DebugM(3, "Received all needed data\n" << endi);
00138 
00139 #ifdef DEBUGM
00140     for (size_t ig = 0; ig < receivedGroupMasses.size(); ig++) {
00141       // The groups' positions will be normalized later, in callClients()
00142       DebugM(3, "Group mass " << ig << " = "
00143              << receivedGroupMasses[ig] << "\n" << endi);
00144     }
00145     for (size_t ig = 0; ig < receivedGridObjValues.size(); ig++) {
00146       DebugM(3, "Grid object " << receivedGridObjIndices[ig] << " = "
00147              << receivedGridObjValues[ig] << "\n" << endi);
00148     }
00149 #endif
00150 
00151     int oldTotalGroupsRequested = totalGroupsRequested;
00152 
00153     int resendCoordinates = callClients();
00154 
00155     if (resendCoordinates) {
00156       DebugM(3, "resendCoordinates\n" << endi);
00157     }
00158 
00159     /* now restart */
00160     step = -1;
00161     receivedAtomIDs.resize(0);
00162     receivedAtomPositions.resize(0);
00163     receivedGroupPositions.resize(totalGroupsRequested);
00164     receivedGroupPositions.setall(Vector(0,0,0));
00165     receivedGroupMasses.resize(totalGroupsRequested);
00166     receivedGroupMasses.setall(0);
00167     receivedGridObjIndices.resize(totalGridObjsRequested);
00168     receivedGridObjIndices.setall(-1);
00169     receivedGridObjValues.resize(totalGridObjsRequested);
00170     receivedGridObjValues.setall(0);
00171     latticeCount = 0;
00172     recvCount = 0;
00173     recvPatchesCount = 0;
00174     if ( resendCoordinates ) {
00175       recvCount += numForceSenders;
00176     } else {
00177       receivedGroupTotalForces.resize(totalGroupsRequested);
00178       receivedGroupTotalForces.setall(0);
00179       receivedForceIDs.resize(0);
00180       receivedTotalForces.resize(0);
00181     }
00182   }
00183 }


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

Generated on 29 May 2020 for NAMD by  doxygen 1.6.1