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

Comparing trunk/OOPSE-3.0/src/brains/SimInfo.cpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 2116 by tim, Fri Mar 11 15:00:20 2005 UTC

# Line 56 | Line 56
56   #include "UseTheForce/notifyCutoffs_interface.h"
57   #include "utils/MemoryUtils.hpp"
58   #include "utils/simError.h"
59 + #include "selection/SelectionManager.hpp"
60  
61   #ifdef IS_MPI
62   #include "UseTheForce/mpiComponentPlan.h"
# Line 108 | Line 109 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
109  
110          //calculate atoms in rigid bodies
111          int nAtomsInRigidBodies = 0;
112 <        int nRigidBodiesInStamp = molStamp->getNCutoffGroups();
112 >        int nRigidBodiesInStamp = molStamp->getNRigidBodies();
113          
114          for (int j=0; j < nRigidBodiesInStamp; j++) {
115              rbStamp = molStamp->getRigidBody(j);
# Line 137 | Line 138 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
138   #ifdef IS_MPI    
139      molToProcMap_.resize(nGlobalMols_);
140   #endif
141 <    
141 >
142   }
143  
144   SimInfo::~SimInfo() {
145 <    //MemoryUtils::deleteVectorOfPointer(molecules_);
146 <
147 <    MemoryUtils::deleteVectorOfPointer(moleculeStamps_);
145 >    std::map<int, Molecule*>::iterator i;
146 >    for (i = molecules_.begin(); i != molecules_.end(); ++i) {
147 >        delete i->second;
148 >    }
149 >    molecules_.clear();
150 >    
151 >    MemoryUtils::deletePointers(moleculeStamps_);
152      
153      delete sman_;
154      delete simParams_;
155      delete forceField_;
151
156   }
157  
158   int SimInfo::getNGlobalConstraints() {
# Line 363 | Line 367 | void SimInfo::addExcludePairs(Molecule* mol) {
367          exclude_.addPair(c, d);        
368      }
369  
370 <    
370 >    Molecule::RigidBodyIterator rbIter;
371 >    RigidBody* rb;
372 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
373 >        std::vector<Atom*> atoms = rb->getAtoms();
374 >        for (int i = 0; i < atoms.size() -1 ; ++i) {
375 >            for (int j = i + 1; j < atoms.size(); ++j) {
376 >                a = atoms[i]->getGlobalIndex();
377 >                b = atoms[j]->getGlobalIndex();
378 >                exclude_.addPair(a, b);
379 >            }
380 >        }
381 >    }        
382 >
383 >    Molecule::CutoffGroupIterator cgIter;
384 >    CutoffGroup* cg;
385 >    for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) {
386 >        std::vector<Atom*> atoms = cg->getAtoms();
387 >        for (int i = 0; i < atoms.size() -1 ; ++i) {
388 >            for (int j = i + 1; j < atoms.size(); ++j) {
389 >                a = atoms[i]->getGlobalIndex();
390 >                b = atoms[j]->getGlobalIndex();
391 >                exclude_.addPair(a, b);
392 >            }
393 >        }
394 >    }  
395 >
396   }
397  
398   void SimInfo::removeExcludePairs(Molecule* mol) {
# Line 408 | Line 437 | void SimInfo::removeExcludePairs(Molecule* mol) {
437          exclude_.removePair(c, d);        
438      }
439  
440 +    Molecule::RigidBodyIterator rbIter;
441 +    RigidBody* rb;
442 +    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
443 +        std::vector<Atom*> atoms = rb->getAtoms();
444 +        for (int i = 0; i < atoms.size() -1 ; ++i) {
445 +            for (int j = i + 1; j < atoms.size(); ++j) {
446 +                a = atoms[i]->getGlobalIndex();
447 +                b = atoms[j]->getGlobalIndex();
448 +                exclude_.removePair(a, b);
449 +            }
450 +        }
451 +    }        
452 +
453 +    Molecule::CutoffGroupIterator cgIter;
454 +    CutoffGroup* cg;
455 +    for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) {
456 +        std::vector<Atom*> atoms = cg->getAtoms();
457 +        for (int i = 0; i < atoms.size() -1 ; ++i) {
458 +            for (int j = i + 1; j < atoms.size(); ++j) {
459 +                a = atoms[i]->getGlobalIndex();
460 +                b = atoms[j]->getGlobalIndex();
461 +                exclude_.removePair(a, b);
462 +            }
463 +        }
464 +    }  
465 +
466   }
467  
468  
# Line 642 | Line 697 | void SimInfo::setupFortranSim() {
697      }
698      
699      //setup fortran simulation
645    //gloalExcludes and molMembershipArray should go away (They are never used)
646    //why the hell fortran need to know molecule?
647    //OOPSE = Object-Obfuscated Parallel Simulation Engine
700      int nGlobalExcludes = 0;
701      int* globalExcludes = NULL;
702      int* excludeList = exclude_.getExcludeList();
# Line 751 | Line 803 | void SimInfo::setupCutoff() {
803      return maxCutoffRadius;
804   }
805  
806 < void SimInfo::setupCutoff() {
755 <    double rcut_;  //cutoff radius
756 <    double rsw_; //switching radius
806 > void SimInfo::getCutoff(double& rcut, double& rsw) {
807      
808      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
809          
# Line 764 | Line 814 | void SimInfo::setupCutoff() {
814                  "\tfor the cutoffRadius.\n");
815              painCave.isFatal = 0;
816              simError();
817 <            rcut_ = 15.0;
817 >            rcut = 15.0;
818          } else{
819 <            rcut_ = simParams_->getRcut();
819 >            rcut = simParams_->getRcut();
820          }
821  
822          if (!simParams_->haveRsw()){
# Line 776 | Line 826 | void SimInfo::setupCutoff() {
826                  "\t0.95 * cutoffRadius for the switchingRadius\n");
827              painCave.isFatal = 0;
828              simError();
829 <            rsw_ = 0.95 * rcut_;
829 >            rsw = 0.95 * rcut;
830          } else{
831 <            rsw_ = simParams_->getRsw();
831 >            rsw = simParams_->getRsw();
832          }
833  
834      } else {
# Line 786 | Line 836 | void SimInfo::setupCutoff() {
836          //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
837          
838          if (simParams_->haveRcut()) {
839 <            rcut_ = simParams_->getRcut();
839 >            rcut = simParams_->getRcut();
840          } else {
841              //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
842 <            rcut_ = calcMaxCutoffRadius();
842 >            rcut = calcMaxCutoffRadius();
843          }
844  
845          if (simParams_->haveRsw()) {
846 <            rsw_  = simParams_->getRsw();
846 >            rsw  = simParams_->getRsw();
847          } else {
848 <            rsw_ = rcut_;
848 >            rsw = rcut;
849          }
850      
851      }
852 <        
852 > }
853 >
854 > void SimInfo::setupCutoff() {
855 >    getCutoff(rcut_, rsw_);    
856      double rnblist = rcut_ + 1; // skin of neighbor list
857  
858      //Pass these cutoff radius etc. to fortran. This function should be called once and only once
# Line 831 | Line 884 | void SimInfo::setSnapshotManager(SnapshotManager* sman
884   }
885  
886   void SimInfo::setSnapshotManager(SnapshotManager* sman) {
887 +    if (sman_ == sman) {
888 +        return;
889 +    }    
890 +    delete sman_;
891      sman_ = sman;
892  
893      Molecule* mol;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines