--- branches/development/src/brains/SimInfo.cpp 2012/07/06 22:01:58 1767 +++ branches/development/src/brains/SimInfo.cpp 2013/01/09 22:02:30 1830 @@ -88,7 +88,8 @@ namespace OpenMD { vector components = simParams->getComponents(); - for (vector::iterator i = components.begin(); i !=components.end(); ++i) { + for (vector::iterator i = components.begin(); + i !=components.end(); ++i) { molStamp = (*i)->getMoleculeStamp(); nMolWithSameStamp = (*i)->getNMol(); @@ -231,26 +232,28 @@ namespace OpenMD { vector::iterator k; Molecule* mol; - StuntDouble* integrableObject; + StuntDouble* sd; Atom* atom; ndf_local = 0; nfq_local = 0; for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { - for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; - integrableObject = mol->nextIntegrableObject(j)) { + for (sd = mol->beginIntegrableObject(j); sd != NULL; + sd = mol->nextIntegrableObject(j)) { + ndf_local += 3; - if (integrableObject->isDirectional()) { - if (integrableObject->isLinear()) { + if (sd->isDirectional()) { + if (sd->isLinear()) { ndf_local += 2; } else { ndf_local += 3; } } } + for (atom = mol->beginFluctuatingCharge(k); atom != NULL; atom = mol->nextFluctuatingCharge(k)) { if (atom->isFluctuatingCharge()) { @@ -265,8 +268,9 @@ namespace OpenMD { ndf_local -= nConstraints_; #ifdef IS_MPI - MPI_Allreduce(&ndf_local,&ndf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&nfq_local,&nGlobalFluctuatingCharges_,1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + MPI::COMM_WORLD.Allreduce(&ndf_local, &ndf_, 1, MPI::INT,MPI::SUM); + MPI::COMM_WORLD.Allreduce(&nfq_local, &nGlobalFluctuatingCharges_, 1, + MPI::INT, MPI::SUM); #else ndf_ = ndf_local; nGlobalFluctuatingCharges_ = nfq_local; @@ -280,7 +284,7 @@ namespace OpenMD { int SimInfo::getFdf() { #ifdef IS_MPI - MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); + MPI::COMM_WORLD.Allreduce(&fdf_local, &fdf_, 1, MPI::INT, MPI::SUM); #else fdf_ = fdf_local; #endif @@ -312,19 +316,20 @@ namespace OpenMD { MoleculeIterator i; vector::iterator j; Molecule* mol; - StuntDouble* integrableObject; + StuntDouble* sd; // Raw degrees of freedom that we have to set ndfRaw_local = 0; for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { - for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; - integrableObject = mol->nextIntegrableObject(j)) { + for (sd = mol->beginIntegrableObject(j); sd != NULL; + sd = mol->nextIntegrableObject(j)) { + ndfRaw_local += 3; - if (integrableObject->isDirectional()) { - if (integrableObject->isLinear()) { + if (sd->isDirectional()) { + if (sd->isLinear()) { ndfRaw_local += 2; } else { ndfRaw_local += 3; @@ -335,7 +340,7 @@ namespace OpenMD { } #ifdef IS_MPI - MPI_Allreduce(&ndfRaw_local,&ndfRaw_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); + MPI::COMM_WORLD.Allreduce(&ndfRaw_local, &ndfRaw_, 1, MPI::INT, MPI::SUM); #else ndfRaw_ = ndfRaw_local; #endif @@ -348,7 +353,8 @@ namespace OpenMD { #ifdef IS_MPI - MPI_Allreduce(&ndfTrans_local,&ndfTrans_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); + MPI::COMM_WORLD.Allreduce(&ndfTrans_local, &ndfTrans_, 1, + MPI::INT, MPI::SUM); #else ndfTrans_ = ndfTrans_local; #endif @@ -384,14 +390,13 @@ namespace OpenMD { Molecule::RigidBodyIterator rbIter; RigidBody* rb; Molecule::IntegrableObjectIterator ii; - StuntDouble* integrableObject; + StuntDouble* sd; - for (integrableObject = mol->beginIntegrableObject(ii); - integrableObject != NULL; - integrableObject = mol->nextIntegrableObject(ii)) { + for (sd = mol->beginIntegrableObject(ii); sd != NULL; + sd = mol->nextIntegrableObject(ii)) { - if (integrableObject->isRigidBody()) { - rb = static_cast(integrableObject); + if (sd->isRigidBody()) { + rb = static_cast(sd); vector atoms = rb->getAtoms(); set rigidAtoms; for (int i = 0; i < static_cast(atoms.size()); ++i) { @@ -402,8 +407,8 @@ namespace OpenMD { } } else { set oneAtomSet; - oneAtomSet.insert(integrableObject->getGlobalIndex()); - atomGroups.insert(map >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); + oneAtomSet.insert(sd->getGlobalIndex()); + atomGroups.insert(map >::value_type(sd->getGlobalIndex(), oneAtomSet)); } } @@ -537,14 +542,13 @@ namespace OpenMD { Molecule::RigidBodyIterator rbIter; RigidBody* rb; Molecule::IntegrableObjectIterator ii; - StuntDouble* integrableObject; + StuntDouble* sd; - for (integrableObject = mol->beginIntegrableObject(ii); - integrableObject != NULL; - integrableObject = mol->nextIntegrableObject(ii)) { + for (sd = mol->beginIntegrableObject(ii); sd != NULL; + sd = mol->nextIntegrableObject(ii)) { - if (integrableObject->isRigidBody()) { - rb = static_cast(integrableObject); + if (sd->isRigidBody()) { + rb = static_cast(sd); vector atoms = rb->getAtoms(); set rigidAtoms; for (int i = 0; i < static_cast(atoms.size()); ++i) { @@ -555,8 +559,8 @@ namespace OpenMD { } } else { set oneAtomSet; - oneAtomSet.insert(integrableObject->getGlobalIndex()); - atomGroups.insert(map >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); + oneAtomSet.insert(sd->getGlobalIndex()); + atomGroups.insert(map >::value_type(sd->getGlobalIndex(), oneAtomSet)); } } @@ -780,7 +784,8 @@ namespace OpenMD { void SimInfo::setupSimVariables() { useAtomicVirial_ = simParams_->getUseAtomicVirial(); - // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true + // we only call setAccumulateBoxDipole if the accumulateBoxDipole + // parameter is true calcBoxDipole_ = false; if ( simParams_->haveAccumulateBoxDipole() ) if ( simParams_->getAccumulateBoxDipole() ) { @@ -874,7 +879,6 @@ namespace OpenMD { void SimInfo::prepareTopology() { - int nExclude, nOneTwo, nOneThree, nOneFour; //calculate mass ratio of cutoff group SimInfo::MoleculeIterator mi; @@ -923,11 +927,6 @@ namespace OpenMD { //scan topology - nExclude = excludedInteractions_.getSize(); - nOneTwo = oneTwoInteractions_.getSize(); - nOneThree = oneThreeInteractions_.getSize(); - nOneFour = oneFourInteractions_.getSize(); - int* excludeList = excludedInteractions_.getPairList(); int* oneTwoList = oneTwoInteractions_.getPairList(); int* oneThreeList = oneThreeInteractions_.getPairList(); @@ -978,15 +977,18 @@ namespace OpenMD { for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { - for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { + for (atom = mol->beginAtom(atomIter); atom != NULL; + atom = mol->nextAtom(atomIter)) { atom->setSnapshotManager(sman_); } - for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { + for (rb = mol->beginRigidBody(rbIter); rb != NULL; + rb = mol->nextRigidBody(rbIter)) { rb->setSnapshotManager(sman_); } - for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { + for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; + cg = mol->nextCutoffGroup(cgIter)) { cg->setSnapshotManager(sman_); } } @@ -1001,28 +1003,26 @@ namespace OpenMD { StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) { - return IOIndexToIntegrableObject.at(index); + if (index >= int(IOIndexToIntegrableObject.size())) { + sprintf(painCave.errMsg, + "SimInfo::getIOIndexToIntegrableObject Error: Integrable Object\n" + "\tindex exceeds number of known objects!\n"); + painCave.isFatal = 1; + simError(); + return NULL; + } else + return IOIndexToIntegrableObject.at(index); } void SimInfo::setIOIndexToIntegrableObject(const vector& v) { IOIndexToIntegrableObject= v; } -/* - void SimInfo::setStuntDoubleFromGlobalIndex(vector v) { - assert( v.size() == nAtoms_ + nRigidBodies_); - sdByGlobalIndex_ = v; - } - StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) { - //assert(index < nAtoms_ + nRigidBodies_); - return sdByGlobalIndex_.at(index); - } -*/ int SimInfo::getNGlobalConstraints() { int nGlobalConstraints; #ifdef IS_MPI - MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, - MPI_COMM_WORLD); + MPI::COMM_WORLD.Allreduce(&nConstraints_, &nGlobalConstraints, 1, + MPI::INT, MPI::SUM); #else nGlobalConstraints = nConstraints_; #endif