--- trunk/src/restraints/RestraintForceManager.cpp 2014/02/26 14:14:50 1969 +++ trunk/src/restraints/RestraintForceManager.cpp 2014/10/16 19:13:51 2024 @@ -225,12 +225,18 @@ namespace OpenMD { evaluator.loadScriptString(objectSelection); seleMan.setSelectionSet(evaluator.evaluate()); int selectionCount = seleMan.getSelectionCount(); - + +#ifdef IS_MPI + MPI_Allreduce(MPI_IN_PLACE, &selectionCount, 1, MPI_INT, MPI_SUM, + MPI_COMM_WORLD); +#endif + sprintf(painCave.errMsg, "Restraint Info: The specified restraint objectSelection,\n" "\t\t%s\n" "\twill result in %d integrable objects being\n" "\trestrained.\n", objectSelection.c_str(), selectionCount); + painCave.severity = OPENMD_INFO; painCave.isFatal = 0; simError(); @@ -313,20 +319,16 @@ namespace OpenMD { void RestraintForceManager::calcForces(){ ForceManager::calcForces(); - RealType restPot_local, restPot; + RealType restPot(0.0); - restPot_local = doRestraints(1.0); + restPot = doRestraints(1.0); #ifdef IS_MPI - MPI_Allreduce(&restPot_local, &restPot, 1, - MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); -#else - restPot = restPot_local; + MPI_Allreduce(MPI_IN_PLACE, &restPot, 1, MPI_REALTYPE, MPI_SUM, + MPI_COMM_WORLD); #endif + currSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); - RealType pot = currSnapshot_->getLongRangePotential(); - pot += restPot; - currSnapshot_->setLongRangePotential(pot); currSnapshot_->setRestraintPotential(restPot); //write out forces and current positions of restrained molecules @@ -391,6 +393,7 @@ namespace OpenMD { std::vector struc; std::vector forces; + for(sd = (*rm)->beginIntegrableObject(ioi); sd != NULL; sd = (*rm)->nextIntegrableObject(ioi)) { @@ -409,12 +412,11 @@ namespace OpenMD { index++; } - unscaledPotential_ += mRest->getUnscaledPotential(); + unscaledPotential_ += mRest->getUnscaledPotential(); - restInfo = mRest->getRestraintInfo(); - // only collect data on restraints that we're going to print: if (mRest->getPrintRestraint()) + restInfo = mRest->getRestraintInfo(); restInfo_.push_back(restInfo); } @@ -451,7 +453,6 @@ namespace OpenMD { // phew. At this point, we should have the pointer to the // correct Object restraint in the variable oRest. - oRest->setScaleFactor(scalingFactor); Vector3d pos = (*ro)->getPos(); @@ -475,10 +476,9 @@ namespace OpenMD { unscaledPotential_ += oRest->getUnscaledPotential(); - restInfo = oRest->getRestraintInfo(); - // only collect data on restraints that we're going to print: if (oRest->getPrintRestraint()) + restInfo = oRest->getRestraintInfo(); restInfo_.push_back(restInfo); }