ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/restraints/RestraintForceManager.cpp
(Generate patch)

Comparing trunk/src/restraints/RestraintForceManager.cpp (file contents):
Revision 1360 by cli2, Mon Sep 7 16:31:51 2009 UTC vs.
Revision 1366 by gezelter, Fri Oct 16 20:42:29 2009 UTC

# Line 78 | Line 78 | namespace oopse {
78        restTime_ = simParam->getStatusTime();
79      } else {
80        sprintf(painCave.errMsg,
81 <              "Restraint warning: If you use restraints without setting\n",
82 <              "\tstatusTime, no restraint data will be written to the rest\n",
81 >              "Restraint warning: If you use restraints without setting\n"
82 >              "\tstatusTime, no restraint data will be written to the rest\n"
83                "\tfile.\n");
84        painCave.isFatal = 0;
85        simError();
# Line 109 | Line 109 | namespace oopse {
109            molIndex = stamp[i]->getMolIndex();
110          }
111          
112 <        Molecule* mol = info_->getMoleculeByGlobalIndex(molIndex);
113 <        
114 <        if (mol == NULL) {
112 >        if (molIndex < 0) {
113            sprintf(painCave.errMsg,
114 <                  "Restraint Error: A molecular restraint was specified, but\n"
115 <                  "\tno molecule was found with global index %d.\n",
118 <                  molIndex);
114 >                  "Restraint Error: A molecular restraint was specified\n"
115 >                  "\twith a molIndex that was less than 0\n");
116            painCave.isFatal = 1;
117            simError();      
118 +        }
119 +        if (molIndex >= info_->getNGlobalMolecules()) {
120 +          sprintf(painCave.errMsg,
121 +                  "Restraint Error: A molecular restraint was specified with\n"
122 +                  "\ta molIndex that was greater than the total number of molecules\n");
123 +          painCave.isFatal = 1;
124 +          simError();      
125 +        }
126 +      
127 +        Molecule* mol = info_->getMoleculeByGlobalIndex(molIndex);
128 +        
129 +        if (mol == NULL) {
130 + #ifdef IS_MPI
131 +          // getMoleculeByGlobalIndex returns a NULL in parallel if
132 +          // this proc doesn't have the molecule.  Do a quick check to
133 +          // make sure another processor is supposed to have it.
134 +        
135 +          int myrank = MPI::COMM_WORLD.Get_rank();
136 +          if (info_->getMolToProc(molIndex) == myrank) {
137 +            // If we were supposed to have it but got a null, then freak out.
138 + #endif
139 +
140 +            sprintf(painCave.errMsg,
141 +                    "Restraint Error: A molecular restraint was specified, but\n"
142 +                    "\tno molecule was found with global index %d.\n",
143 +                    molIndex);
144 +            painCave.isFatal = 1;
145 +            simError();    
146 +
147 + #ifdef IS_MPI
148 +          }
149 + #endif
150          }
151          
152          MolecularRestraint* rest = new MolecularRestraint();
# Line 148 | Line 177 | namespace oopse {
177          if (stamp[i]->haveRestrainedSwingXAngle()) {
178            rest->setRestrainedSwingXAngle(stamp[i]->getRestrainedSwingXAngle() * M_PI/180.0);
179          }
180 +        if (stamp[i]->havePrint()) {
181 +          rest->setPrintRestraint(stamp[i]->getPrint());
182 +        }
183  
184          restraints_.push_back(rest);
185          mol->addProperty(new RestraintData("Restraint", rest));
# Line 170 | Line 202 | namespace oopse {
202  
203          SelectionEvaluator evaluator(info);
204          SelectionManager seleMan(info);
205 <        
205 >                
206          evaluator.loadScriptString(objectSelection);
207          seleMan.setSelectionSet(evaluator.evaluate());        
208          int selectionCount = seleMan.getSelectionCount();
# Line 211 | Line 243 | namespace oopse {
243            }
244            if (stamp[i]->haveRestrainedSwingYAngle()) {
245              rest->setRestrainedSwingYAngle(stamp[i]->getRestrainedSwingYAngle());
246 <          }        
246 >          }    
247 >          if (stamp[i]->havePrint()) {
248 >            rest->setPrintRestraint(stamp[i]->getPrint());
249 >          }
250 >    
251            restraints_.push_back(rest);
252            sd->addProperty(new RestraintData("Restraint", rest));
253            restrainedObjs_.push_back(sd);                    
# Line 357 | Line 393 | namespace oopse {
393        unscaledPotential_ += mRest->getUnscaledPotential();
394  
395        restInfo = mRest->getRestraintInfo();
396 <      restInfo_.push_back(restInfo);
396 >
397 >      // only collect data on restraints that we're going to print:
398 >      if (mRest->getPrintRestraint())
399 >        restInfo_.push_back(restInfo);
400      }
401  
402      for(ro=restrainedObjs_.begin(); ro != restrainedObjs_.end(); ++ro){
# Line 418 | Line 457 | namespace oopse {
457        unscaledPotential_ += oRest->getUnscaledPotential();
458  
459        restInfo = oRest->getRestraintInfo();
460 <      restInfo_.push_back(restInfo);
460 >
461 >      // only collect data on restraints that we're going to print:
462 >      if (oRest->getPrintRestraint())
463 >        restInfo_.push_back(restInfo);
464      }
465  
466      return unscaledPotential_ * scalingFactor;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines