--- trunk/src/restraints/RestraintForceManager.cpp 2014/03/06 19:34:22 1973 +++ trunk/src/restraints/RestraintForceManager.cpp 2014/10/16 19:13:51 2024 @@ -225,7 +225,12 @@ 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" @@ -314,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 @@ -411,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); } @@ -476,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); }