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

Comparing branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp (file contents):
Revision 1842 by tim, Fri Dec 3 20:30:07 2004 UTC vs.
Revision 1887 by tim, Wed Dec 15 16:44:14 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 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 815 | Line 825 | void SimInfo::setSnapshotManager(SnapshotManager* sman
825          }
826      }    
827      
828 + }
829 +
830 + Vector3d SimInfo::getComVel(){
831 +    SimInfo::MoleculeIterator i;
832 +    Molecule* mol;
833 +
834 +    Vector3d comVel(0.0);
835 +    double totalMass = 0.0;
836 +    
837 +
838 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
839 +        double mass = mol->getMass();
840 +        totalMass += mass;
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;
854   }
855  
856 + Vector3d SimInfo::getCom(){
857 +    SimInfo::MoleculeIterator i;
858 +    Molecule* mol;
859 +
860 +    Vector3d com(0.0);
861 +    double totalMass = 0.0;
862 +    
863 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
864 +        double mass = mol->getMass();
865 +        totalMass += mass;
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;
879 +
880 + }        
881 +
882   std::ostream& operator <<(std::ostream& o, SimInfo& info) {
883  
884      return o;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines