--- trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/28 22:34:02 1140 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2004/05/11 21:14:26 1158 @@ -12,7 +12,6 @@ Molecule::Molecule( void ){ myBonds = NULL; myBends = NULL; myTorsions = NULL; - hasMassRatio = false; } Molecule::~Molecule( void ){ @@ -43,6 +42,12 @@ void Molecule::initialize( molInit &theInit ){ void Molecule::initialize( molInit &theInit ){ + CutoffGroup* curCutoffGroup; + vector::iterator iterCutoff; + Atom* cutoffAtom; + vector::iterator iterAtom; + int atomIndex; + nAtoms = theInit.nAtoms; nMembers = nAtoms; nBonds = theInit.nBonds; @@ -50,6 +55,7 @@ void Molecule::initialize( molInit &theInit ){ nTorsions = theInit.nTorsions; nRigidBodies = theInit.nRigidBodies; nOriented = theInit.nOriented; + nCutoffGroups = theInit.nCutoffGroups; myAtoms = theInit.myAtoms; myBonds = theInit.myBonds; @@ -62,6 +68,26 @@ void Molecule::initialize( molInit &theInit ){ for (int i = 0; i < myRigidBodies.size(); i++) myRigidBodies[i]->calcRefCoords(); + myCutoffGroups = theInit.myCutoffGroups; + + //creat a global index set of atoms which belong to cutoff group. + //it will be use to speed up the query whether an atom belongs to cutoff group or not + cutoffAtomSet.clear(); + + for(curCutoffGroup = beginCutoffGroup(iterCutoff); curCutoffGroup != NULL; + curCutoffGroup = nextCutoffGroup(iterCutoff)){ + + for(cutoffAtom = curCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL; + cutoffAtom = curCutoffGroup->nextAtom(iterAtom)){ +#ifdef IS_MPI + atomIndex = cutoffAtom->getGlobalIndex(); +#else + atomIndex = cutoffAtom->getIndex(); +#endif + cutoffAtomSet.insert(atomIndex); + }// end for(cutoffAtom) + }//end for(curCutoffGroup) + } void Molecule::calcForces( void ){ @@ -73,19 +99,10 @@ void Molecule::calcForces( void ){ myRigidBodies[i]->updateAtoms(); } - //the mass ratio will never change during the simulation. Thus, we could - //just calculate it at the begining of the simulation - if (!hasMassRatio){ - double totMass = getTotalMass(); - for(int i = 0; i < nAtoms; i ++) - myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); - hasMassRatio = true; - } - //calculate the center of mass of the molecule - getCOM(com); - for(int i = 0; i < nAtoms; i ++) - myAtoms[i]->setRc(com); + //getCOM(com); + //for(int i = 0; i < nAtoms; i ++) + // myAtoms[i]->setRc(com); for(i=0; i