ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp (file contents):
Revision 1843 by tim, Fri Dec 3 21:30:30 2004 UTC vs.
Revision 1895 by tim, Thu Dec 16 19:20:49 2004 UTC

# Line 32 | Line 32
32  
33   #include <algorithm>
34   #include <set>
35 +
36   #include "brains/SimInfo.hpp"
37 + #include "math/Vector3.hpp"
38   #include "primitives/Molecule.hpp"
39   #include "UseTheForce/doForces_interface.h"
40   #include "UseTheForce/notifyCutoffs_interface.h"
41   #include "utils/MemoryUtils.hpp"
42   #include "utils/simError.h"
43  
44 + #ifdef IS_MPI
45 + #include "UseTheForce/mpiComponentPlan.h"
46 + #include "UseTheForce/DarkSide/simParallel_interface.h"
47 + #endif
48 +
49   namespace oopse {
50  
51   SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs,
# Line 146 | Line 153 | bool SimInfo::addMolecule(Molecule* mol) {
153          nCutoffGroups_ += mol->getNCutoffGroups();
154          nConstraints_ += mol->getNConstraints();
155  
156 +        addExcludePairs(mol);
157 +        
158          return true;
159      } else {
160          return false;
# Line 169 | Line 178 | bool SimInfo::removeMolecule(Molecule* mol) {
178          nCutoffGroups_ -= mol->getNCutoffGroups();
179          nConstraints_ -= mol->getNConstraints();
180  
181 +        removeExcludePairs(mol);
182          molecules_.erase(mol->getGlobalIndex());
183  
184          delete mol;
# Line 379 | Line 389 | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp
389      int curStampId;
390  
391      //index from 0
392 <    curStampId = molStampIds_.size();
392 >    curStampId = moleculeStamps_.size();
393  
394      moleculeStamps_.push_back(molStamp);
395      molStampIds_.insert(molStampIds_.end(), nmol, curStampId);
# Line 452 | Line 462 | void SimInfo::setupSimType() {
462      int useDirectionalAtom = 0;    
463      int useElectrostatics = 0;
464      //usePBC and useRF are from simParams
465 <    bool usePBC = simParams_->getPBC();
466 <    bool useRF = simParams_->getUseRF();
465 >    int usePBC = simParams_->getPBC();
466 >    int useRF = simParams_->getUseRF();
467  
468      //loop over all of the atom types
469      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
# Line 602 | Line 612 | void SimInfo::setupFortranSim() {
612      //molMembershipArray is filled by SimCreator    
613      std::vector<int> molMembershipArray(nGlobalAtoms_);
614      for (int i = 0; i < nGlobalAtoms_; i++) {
615 <        molMembershipArray.push_back(globalMolMembership_[i] + 1);
615 >        molMembershipArray[i] = globalMolMembership_[i] + 1;
616      }
617      
618      //setup fortran simulation
# Line 670 | Line 680 | void SimInfo::setupFortranParallel() {
680      parallelData.nGroupsGlobal = getNGlobalCutoffGroups();
681      parallelData.nGroupsLocal = getNCutoffGroups();
682      parallelData.myNode = worldRank;
683 <    MPI_Comm_size(MPI_COMM_WORLD, &(parallelData->nProcessors));
683 >    MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors));
684  
685      //pass mpiSimData struct and index arrays to fortran
686 <    setFsimParallel(parallelData, &(parallelData->nAtomsLocal),
687 <                    &localToGlobalAtomIndex[0],  &(parallelData->nGroupsLocal),
686 >    setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
687 >                    &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
688                      &localToGlobalCutoffGroupIndex[0], &isError);
689  
690      if (isError) {
# Line 831 | Line 841 | Vector3d SimInfo::getComVel(){
841          comVel += mass * mol->getComVel();
842      }  
843  
844 + #ifdef IS_MPI
845 +    double tmpMass = totalMass;
846 +    Vector3d tmpComVel(comVel);    
847 +    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
848 +    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
849 + #endif
850 +
851      comVel /= totalMass;
852  
853      return comVel;
# Line 849 | Line 866 | Vector3d SimInfo::getCom(){
866          com += mass * mol->getCom();
867      }  
868  
869 + #ifdef IS_MPI
870 +    double tmpMass = totalMass;
871 +    Vector3d tmpCom(com);    
872 +    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
873 +    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
874 + #endif
875 +
876      com /= totalMass;
877  
878      return com;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines