--- branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp 2004/12/03 21:30:30 1843 +++ branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp 2004/12/16 19:20:49 1895 @@ -32,13 +32,20 @@ #include #include + #include "brains/SimInfo.hpp" +#include "math/Vector3.hpp" #include "primitives/Molecule.hpp" #include "UseTheForce/doForces_interface.h" #include "UseTheForce/notifyCutoffs_interface.h" #include "utils/MemoryUtils.hpp" #include "utils/simError.h" +#ifdef IS_MPI +#include "UseTheForce/mpiComponentPlan.h" +#include "UseTheForce/DarkSide/simParallel_interface.h" +#endif + namespace oopse { SimInfo::SimInfo(std::vector >& molStampPairs, @@ -146,6 +153,8 @@ bool SimInfo::addMolecule(Molecule* mol) { nCutoffGroups_ += mol->getNCutoffGroups(); nConstraints_ += mol->getNConstraints(); + addExcludePairs(mol); + return true; } else { return false; @@ -169,6 +178,7 @@ bool SimInfo::removeMolecule(Molecule* mol) { nCutoffGroups_ -= mol->getNCutoffGroups(); nConstraints_ -= mol->getNConstraints(); + removeExcludePairs(mol); molecules_.erase(mol->getGlobalIndex()); delete mol; @@ -379,7 +389,7 @@ void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp int curStampId; //index from 0 - curStampId = molStampIds_.size(); + curStampId = moleculeStamps_.size(); moleculeStamps_.push_back(molStamp); molStampIds_.insert(molStampIds_.end(), nmol, curStampId); @@ -452,8 +462,8 @@ void SimInfo::setupSimType() { int useDirectionalAtom = 0; int useElectrostatics = 0; //usePBC and useRF are from simParams - bool usePBC = simParams_->getPBC(); - bool useRF = simParams_->getUseRF(); + int usePBC = simParams_->getPBC(); + int useRF = simParams_->getUseRF(); //loop over all of the atom types for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { @@ -602,7 +612,7 @@ void SimInfo::setupFortranSim() { //molMembershipArray is filled by SimCreator std::vector molMembershipArray(nGlobalAtoms_); for (int i = 0; i < nGlobalAtoms_; i++) { - molMembershipArray.push_back(globalMolMembership_[i] + 1); + molMembershipArray[i] = globalMolMembership_[i] + 1; } //setup fortran simulation @@ -670,11 +680,11 @@ void SimInfo::setupFortranParallel() { parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); parallelData.nGroupsLocal = getNCutoffGroups(); parallelData.myNode = worldRank; - MPI_Comm_size(MPI_COMM_WORLD, &(parallelData->nProcessors)); + MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); //pass mpiSimData struct and index arrays to fortran - setFsimParallel(parallelData, &(parallelData->nAtomsLocal), - &localToGlobalAtomIndex[0], &(parallelData->nGroupsLocal), + setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), + &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), &localToGlobalCutoffGroupIndex[0], &isError); if (isError) { @@ -831,6 +841,13 @@ Vector3d SimInfo::getComVel(){ comVel += mass * mol->getComVel(); } +#ifdef IS_MPI + double tmpMass = totalMass; + Vector3d tmpComVel(comVel); + MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); +#endif + comVel /= totalMass; return comVel; @@ -849,6 +866,13 @@ Vector3d SimInfo::getCom(){ com += mass * mol->getCom(); } +#ifdef IS_MPI + double tmpMass = totalMass; + Vector3d tmpCom(com); + MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); +#endif + com /= totalMass; return com;