--- trunk/src/restraints/RestraintForceManager.cpp 2009/11/25 20:02:06 1390 +++ trunk/src/restraints/RestraintForceManager.cpp 2010/07/09 19:29:05 1464 @@ -89,6 +89,8 @@ namespace OpenMD { int nRestraintStamps = simParam->getNRestraintStamps(); std::vector stamp = simParam->getRestraintStamps(); + std::vector stuntDoubleIndex; + for (int i = 0; i < nRestraintStamps; i++){ std::string myType = toUpperCopy(stamp[i]->getType()); @@ -134,6 +136,7 @@ namespace OpenMD { int myrank = MPI::COMM_WORLD.Get_rank(); if (info_->getMolToProc(molIndex) == myrank) { + // If we were supposed to have it but got a null, then freak out. #endif @@ -149,6 +152,15 @@ namespace OpenMD { #endif } + +#ifdef IS_MPI + // only handle this molecular restraint if this processor owns the + // molecule + int myrank = MPI::COMM_WORLD.Get_rank(); + if (info_->getMolToProc(molIndex) == myrank) { + +#endif + MolecularRestraint* rest = new MolecularRestraint(); std::string restPre("mol_"); @@ -184,7 +196,9 @@ namespace OpenMD { restraints_.push_back(rest); mol->addProperty(new RestraintData("Restraint", rest)); restrainedMols_.push_back(mol); - +#ifdef IS_MPI + } +#endif } else if (myType.compare("OBJECT") == 0) { std::string objectSelection; @@ -220,7 +234,8 @@ namespace OpenMD { for (sd = seleMan.beginSelected(selei); sd != NULL; sd = seleMan.nextSelected(selei)) { - + stuntDoubleIndex.push_back(sd->getGlobalIntegrableObjectIndex()); + ObjectRestraint* rest = new ObjectRestraint(); if (stamp[i]->haveDisplacementSpringConstant()) { @@ -260,16 +275,14 @@ namespace OpenMD { // are times when it won't use restraints at all, so only open the // restraint file if we are actually using restraints: - if (simParam->getUseRestraints()) { + if (simParam->getUseRestraints()) { std::string refFile = simParam->getRestraint_file(); - RestReader* rr = new RestReader(info, refFile); - + RestReader* rr = new RestReader(info, refFile, stuntDoubleIndex); rr->readReferenceStructure(); } restOutput_ = getPrefix(info_->getFinalConfigFileName()) + ".rest"; restOut = new RestWriter(info_, restOutput_.c_str(), restraints_); - if(!restOut){ sprintf(painCave.errMsg, "Restraint error: Failed to create RestWriter\n"); painCave.isFatal = 1; @@ -292,9 +305,9 @@ namespace OpenMD { currRestTime_ = currSnapshot_->getTime(); } - void RestraintForceManager::calcForces(bool needPotential, bool needStress){ + void RestraintForceManager::calcForces(){ - ForceManager::calcForces(needPotential, needStress); + ForceManager::calcForces(); RealType restPot_local, restPot; restPot_local = doRestraints(1.0); @@ -374,7 +387,7 @@ namespace OpenMD { std::vector forces; for(sd = (*rm)->beginIntegrableObject(ioi); sd != NULL; - sd = (*rm)->nextIntegrableObject(ioi)) { + sd = (*rm)->nextIntegrableObject(ioi)) { struc.push_back(sd->getPos()); }