--- trunk/src/brains/SimInfo.cpp 2005/01/25 21:59:18 274 +++ trunk/src/brains/SimInfo.cpp 2005/03/11 15:00:20 432 @@ -56,6 +56,7 @@ #include "UseTheForce/notifyCutoffs_interface.h" #include "utils/MemoryUtils.hpp" #include "utils/simError.h" +#include "selection/SelectionManager.hpp" #ifdef IS_MPI #include "UseTheForce/mpiComponentPlan.h" @@ -137,18 +138,21 @@ SimInfo::SimInfo(std::vector::iterator i; + for (i = molecules_.begin(); i != molecules_.end(); ++i) { + delete i->second; + } + molecules_.clear(); + + MemoryUtils::deletePointers(moleculeStamps_); delete sman_; delete simParams_; delete forceField_; - } int SimInfo::getNGlobalConstraints() { @@ -363,7 +367,32 @@ void SimInfo::addExcludePairs(Molecule* mol) { exclude_.addPair(c, d); } - + Molecule::RigidBodyIterator rbIter; + RigidBody* rb; + for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { + std::vector atoms = rb->getAtoms(); + for (int i = 0; i < atoms.size() -1 ; ++i) { + for (int j = i + 1; j < atoms.size(); ++j) { + a = atoms[i]->getGlobalIndex(); + b = atoms[j]->getGlobalIndex(); + exclude_.addPair(a, b); + } + } + } + + Molecule::CutoffGroupIterator cgIter; + CutoffGroup* cg; + for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { + std::vector atoms = cg->getAtoms(); + for (int i = 0; i < atoms.size() -1 ; ++i) { + for (int j = i + 1; j < atoms.size(); ++j) { + a = atoms[i]->getGlobalIndex(); + b = atoms[j]->getGlobalIndex(); + exclude_.addPair(a, b); + } + } + } + } void SimInfo::removeExcludePairs(Molecule* mol) { @@ -408,6 +437,32 @@ void SimInfo::removeExcludePairs(Molecule* mol) { exclude_.removePair(c, d); } + Molecule::RigidBodyIterator rbIter; + RigidBody* rb; + for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { + std::vector atoms = rb->getAtoms(); + for (int i = 0; i < atoms.size() -1 ; ++i) { + for (int j = i + 1; j < atoms.size(); ++j) { + a = atoms[i]->getGlobalIndex(); + b = atoms[j]->getGlobalIndex(); + exclude_.removePair(a, b); + } + } + } + + Molecule::CutoffGroupIterator cgIter; + CutoffGroup* cg; + for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { + std::vector atoms = cg->getAtoms(); + for (int i = 0; i < atoms.size() -1 ; ++i) { + for (int j = i + 1; j < atoms.size(); ++j) { + a = atoms[i]->getGlobalIndex(); + b = atoms[j]->getGlobalIndex(); + exclude_.removePair(a, b); + } + } + } + } @@ -642,9 +697,6 @@ void SimInfo::setupFortranSim() { } //setup fortran simulation - //gloalExcludes and molMembershipArray should go away (They are never used) - //why the hell fortran need to know molecule? - //OOPSE = Object-Obfuscated Parallel Simulation Engine int nGlobalExcludes = 0; int* globalExcludes = NULL; int* excludeList = exclude_.getExcludeList(); @@ -751,9 +803,7 @@ double SimInfo::calcMaxCutoffRadius() { return maxCutoffRadius; } -void SimInfo::setupCutoff() { - double rcut_; //cutoff radius - double rsw_; //switching radius +void SimInfo::getCutoff(double& rcut, double& rsw) { if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { @@ -764,9 +814,9 @@ void SimInfo::setupCutoff() { "\tfor the cutoffRadius.\n"); painCave.isFatal = 0; simError(); - rcut_ = 15.0; + rcut = 15.0; } else{ - rcut_ = simParams_->getRcut(); + rcut = simParams_->getRcut(); } if (!simParams_->haveRsw()){ @@ -776,9 +826,9 @@ void SimInfo::setupCutoff() { "\t0.95 * cutoffRadius for the switchingRadius\n"); painCave.isFatal = 0; simError(); - rsw_ = 0.95 * rcut_; + rsw = 0.95 * rcut; } else{ - rsw_ = simParams_->getRsw(); + rsw = simParams_->getRsw(); } } else { @@ -786,20 +836,23 @@ void SimInfo::setupCutoff() { //meta-data file, the maximum cutoff radius calculated from forcefiled will be used if (simParams_->haveRcut()) { - rcut_ = simParams_->getRcut(); + rcut = simParams_->getRcut(); } else { //set cutoff radius to the maximum cutoff radius based on atom types in the whole system - rcut_ = calcMaxCutoffRadius(); + rcut = calcMaxCutoffRadius(); } if (simParams_->haveRsw()) { - rsw_ = simParams_->getRsw(); + rsw = simParams_->getRsw(); } else { - rsw_ = rcut_; + rsw = rcut; } } - +} + +void SimInfo::setupCutoff() { + getCutoff(rcut_, rsw_); double rnblist = rcut_ + 1; // skin of neighbor list //Pass these cutoff radius etc. to fortran. This function should be called once and only once @@ -831,6 +884,10 @@ void SimInfo::setSnapshotManager(SnapshotManager* sman } void SimInfo::setSnapshotManager(SnapshotManager* sman) { + if (sman_ == sman) { + return; + } + delete sman_; sman_ = sman; Molecule* mol;