--- branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp 2004/11/15 18:02:15 1739 +++ branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp 2004/11/30 19:58:25 1804 @@ -33,15 +33,18 @@ #include #include "brains/SimInfo.hpp" +#include "primitives/Molecule.hpp" +#include "UseTheForce/notifyCutoffs_interface.h" #include "utils/MemoryUtils.hpp" +#include "utils/simError.h" namespace oopse { -SimInfo::SimInfo(const std::vector >& molStampPairs, +SimInfo::SimInfo(std::vector >& molStampPairs, ForceField* ff, Globals* globals) : forceField_(ff), globals_(globals), nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), nIntegrableObjects_(0), - nCutoffGroups_(0), nConstraints_(0), nZConstraint_(0), sman_(NULL), + nCutoffGroups_(0), nConstraints_(0), nZconstraint_(0), sman_(NULL), fortranInitialized_(false) { std::vector >::iterator i; @@ -63,8 +66,6 @@ SimInfo::SimInfo(const std::vectorbeginTorsion(torsionIter); torsion != NULL; torsion = mol->nextBond(torsionIter)) { + for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { a = torsion->getAtomA()->getGlobalIndex(); b = torsion->getAtomB()->getGlobalIndex(); c = torsion->getAtomC()->getGlobalIndex(); @@ -367,7 +368,7 @@ void SimInfo::removeExcludePairs(Molecule* mol) { exclude_.removePair(b, c); } - for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextBond(torsionIter)) { + for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { a = torsion->getAtomA()->getGlobalIndex(); b = torsion->getAtomB()->getGlobalIndex(); c = torsion->getAtomC()->getGlobalIndex(); @@ -391,7 +392,7 @@ void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp curStampId = molStampIds_.size(); moleculeStamps_.push_back(molStamp); - molStampIds_.insert(molStampIds_.end(), nmol, curStampId) + molStampIds_.insert(molStampIds_.end(), nmol, curStampId); } void SimInfo::update() { @@ -425,9 +426,9 @@ std::set SimInfo::getUniqueAtomTypes() { } std::set SimInfo::getUniqueAtomTypes() { - typename SimInfo::MoleculeIterator mi; + SimInfo::MoleculeIterator mi; Molecule* mol; - typename Molecule::AtomIterator ai; + Molecule::AtomIterator ai; Atom* atom; std::set atomTypes; @@ -465,15 +466,15 @@ void SimInfo::setupSimType() { //loop over all of the atom types for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { - useLennardJones |= i->isLennardJones(); - useElectrostatic |= i->isElectrostatic(); - useEAM |= i->isEAM(); - useCharge |= i->isCharge(); - useDirectional |= i->isDirectional(); - useDipole |= i->isDipole(); - useGayBerne |= i->isGayBerne(); - useSticky |= i->isSticky(); - useShape |= i->isShape(); + useLennardJones |= (*i)->isLennardJones(); + useElectrostatic |= (*i)->isElectrostatic(); + useEAM |= (*i)->isEAM(); + useCharge |= (*i)->isCharge(); + useDirectional |= (*i)->isDirectional(); + useDipole |= (*i)->isDipole(); + useGayBerne |= (*i)->isGayBerne(); + useSticky |= (*i)->isSticky(); + useShape |= (*i)->isShape(); } if (useSticky || useDipole || useGayBerne || useShape) { @@ -539,7 +540,18 @@ void SimInfo::setupSimType() { fInfo_.SIM_uses_RF = useRF; if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { - fInfo_.dielect = dielectric; + + if (globals_->haveDielectric()) { + fInfo_.dielect = globals_->getDielectric(); + } else { + sprintf(painCave.errMsg, + "SimSetup Error: No Dielectric constant was set.\n" + "\tYou are trying to use Reaction Field without" + "\tsetting a dielectric constant!\n"); + painCave.isFatal = 1; + simError(); + } + } else { fInfo_.dielect = 0.0; } @@ -561,11 +573,11 @@ void SimInfo::setupFortranSim() { //calculate mass ratio of cutoff group std::vector mfact; - typename SimInfo::MoleculeIterator mi; + SimInfo::MoleculeIterator mi; Molecule* mol; - typename Molecule::CutoffGroupIterator ci; + Molecule::CutoffGroupIterator ci; CutoffGroup* cg; - typename Molecule::AtomIterator ai; + Molecule::AtomIterator ai; Atom* atom; double totalMass; @@ -606,9 +618,11 @@ void SimInfo::setupFortranSim() { //gloalExcludes and molMembershipArray should go away (They are never used) //why the hell fortran need to know molecule? //OOPSE = Object-Obfuscated Parallel Simulation Engine - - setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, exclude_->getExcludeList(), - &nGlobalExcludes, globalExcludes, molMembershipArray, + int nGlobalExcludes = 0; + int* globalExcludes = NULL; + int* excludeList = exclude_.getExcludeList(); + setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , + &nGlobalExcludes, globalExcludes, &molMembershipArray[0], &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); if( isError ){ @@ -634,9 +648,9 @@ void SimInfo::setupFortranParallel() { //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex std::vector localToGlobalAtomIndex(getNAtoms(), 0); std::vector localToGlobalCutoffGroupIndex; - typename SimInfo::MoleculeIterator mi; - typename Molecule::AtomIterator ai; - typename Molecule::CutoffGroupIterator ci; + SimInfo::MoleculeIterator mi; + Molecule::AtomIterator ai; + Molecule::CutoffGroupIterator ci; Molecule* mol; Atom* atom; CutoffGroup* cg; @@ -690,8 +704,8 @@ double SimInfo::calcMaxCutoffRadius() { double SimInfo::calcMaxCutoffRadius() { - std::vector atomTypes; - std::vector::iterator i; + std::set atomTypes; + std::set::iterator i; std::vector cutoffRadius; //get the unique atom types @@ -702,7 +716,7 @@ double SimInfo::calcMaxCutoffRadius() { cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); } - double maxCutoffRadius = std::max_element(cutoffRadius.begin(), cutoffRadius.end()); + double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); #ifdef IS_MPI //pick the max cutoff radius among the processors #endif @@ -752,7 +766,7 @@ void SimInfo::setupCutoff() { } if (globals_->haveRsw()) { - rsw_ = globals_->getRsw() + rsw_ = globals_->getRsw(); } else { rsw_ = rcut_; }