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

Comparing trunk/OOPSE-2.0/src/brains/SimInfo.cpp (file contents):
Revision 1976 by tim, Fri Feb 4 22:44:15 2005 UTC vs.
Revision 2119 by tim, Fri Mar 11 15:55:17 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 72 | Line 73 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
73                                  nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
74                                  nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0),
75                                  nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0),
76 <                                sman_(NULL), fortranInitialized_(false), selectMan_(NULL) {
76 >                                sman_(NULL), fortranInitialized_(false) {
77  
78              
79      std::vector<std::pair<MoleculeStamp*, int> >::iterator i;
# Line 138 | Line 139 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
139      molToProcMap_.resize(nGlobalMols_);
140   #endif
141  
141    selectMan_ = new SelectionManager(nGlobalAtoms_ + nGlobalRigidBodies_);
142    selectMan_->selectAll();
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_;
153    delete selectMan_;
156   }
157  
158   int SimInfo::getNGlobalConstraints() {
# Line 365 | 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   }
384  
385   void SimInfo::removeExcludePairs(Molecule* mol) {
# Line 410 | Line 424 | void SimInfo::removeExcludePairs(Molecule* mol) {
424          exclude_.removePair(c, d);        
425      }
426  
427 +    Molecule::RigidBodyIterator rbIter;
428 +    RigidBody* rb;
429 +    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
430 +        std::vector<Atom*> atoms = rb->getAtoms();
431 +        for (int i = 0; i < atoms.size() -1 ; ++i) {
432 +            for (int j = i + 1; j < atoms.size(); ++j) {
433 +                a = atoms[i]->getGlobalIndex();
434 +                b = atoms[j]->getGlobalIndex();
435 +                exclude_.removePair(a, b);
436 +            }
437 +        }
438 +    }        
439 +
440   }
441  
442  
# Line 644 | Line 671 | void SimInfo::setupFortranSim() {
671      }
672      
673      //setup fortran simulation
647    //gloalExcludes and molMembershipArray should go away (They are never used)
648    //why the hell fortran need to know molecule?
649    //OOPSE = Object-Obfuscated Parallel Simulation Engine
674      int nGlobalExcludes = 0;
675      int* globalExcludes = NULL;
676      int* excludeList = exclude_.getExcludeList();
# Line 753 | Line 777 | void SimInfo::setupCutoff() {
777      return maxCutoffRadius;
778   }
779  
780 < void SimInfo::setupCutoff() {
757 <    double rcut_;  //cutoff radius
758 <    double rsw_; //switching radius
780 > void SimInfo::getCutoff(double& rcut, double& rsw) {
781      
782      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
783          
# Line 766 | Line 788 | void SimInfo::setupCutoff() {
788                  "\tfor the cutoffRadius.\n");
789              painCave.isFatal = 0;
790              simError();
791 <            rcut_ = 15.0;
791 >            rcut = 15.0;
792          } else{
793 <            rcut_ = simParams_->getRcut();
793 >            rcut = simParams_->getRcut();
794          }
795  
796          if (!simParams_->haveRsw()){
# Line 778 | Line 800 | void SimInfo::setupCutoff() {
800                  "\t0.95 * cutoffRadius for the switchingRadius\n");
801              painCave.isFatal = 0;
802              simError();
803 <            rsw_ = 0.95 * rcut_;
803 >            rsw = 0.95 * rcut;
804          } else{
805 <            rsw_ = simParams_->getRsw();
805 >            rsw = simParams_->getRsw();
806          }
807  
808      } else {
# Line 788 | Line 810 | void SimInfo::setupCutoff() {
810          //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
811          
812          if (simParams_->haveRcut()) {
813 <            rcut_ = simParams_->getRcut();
813 >            rcut = simParams_->getRcut();
814          } else {
815              //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
816 <            rcut_ = calcMaxCutoffRadius();
816 >            rcut = calcMaxCutoffRadius();
817          }
818  
819          if (simParams_->haveRsw()) {
820 <            rsw_  = simParams_->getRsw();
820 >            rsw  = simParams_->getRsw();
821          } else {
822 <            rsw_ = rcut_;
822 >            rsw = rcut;
823          }
824      
825      }
826 <        
826 > }
827 >
828 > void SimInfo::setupCutoff() {
829 >    getCutoff(rcut_, rsw_);    
830      double rnblist = rcut_ + 1; // skin of neighbor list
831  
832      //Pass these cutoff radius etc. to fortran. This function should be called once and only once
# Line 833 | Line 858 | void SimInfo::setSnapshotManager(SnapshotManager* sman
858   }
859  
860   void SimInfo::setSnapshotManager(SnapshotManager* sman) {
861 +    if (sman_ == sman) {
862 +        return;
863 +    }    
864 +    delete sman_;
865      sman_ = sman;
866  
867      Molecule* mol;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines