--- branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp 2004/12/03 20:30:07 1842 +++ branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp 2004/12/15 16:44:14 1887 @@ -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; @@ -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) { @@ -815,8 +825,60 @@ void SimInfo::setSnapshotManager(SnapshotManager* sman } } +} + +Vector3d SimInfo::getComVel(){ + SimInfo::MoleculeIterator i; + Molecule* mol; + + Vector3d comVel(0.0); + double totalMass = 0.0; + + + for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { + double mass = mol->getMass(); + totalMass += mass; + 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; } +Vector3d SimInfo::getCom(){ + SimInfo::MoleculeIterator i; + Molecule* mol; + + Vector3d com(0.0); + double totalMass = 0.0; + + for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { + double mass = mol->getMass(); + totalMass += mass; + 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; + +} + std::ostream& operator <<(std::ostream& o, SimInfo& info) { return o;