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

Comparing trunk/src/constraints/Rattle.cpp (file contents):
Revision 1980 by gezelter, Sat Apr 5 20:56:01 2014 UTC vs.
Revision 1981 by gezelter, Mon Apr 14 18:32:51 2014 UTC

# Line 50 | Line 50 | namespace OpenMD {
50      if (info_->getNConstraints() > 0)
51        doRattle_ = true;
52      
53 +    Globals* simParams = info_->getSimParams();
54  
55 <    if (info_->getSimParams()->haveDt()) {
56 <      dt_ = info_->getSimParams()->getDt();
55 >    if (simParams->haveDt()) {
56 >      dt_ = simParams->getDt();
57      } else {
58        sprintf(painCave.errMsg,
59                "Integrator Error: dt is not set\n");
# Line 60 | Line 61 | namespace OpenMD {
61        simError();
62      }    
63      currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
64 +    if (simParams->haveConstraintTime()){
65 +      constraintTime_ = simParams->getConstraintTime();
66 +    } else {
67 +      constraintTime_ = simParams->getStatusTime();
68 +    }
69 +
70 +    constraintOutputFile_ = getPrefix(info_->getFinalConfigFileName()) + ".constraintForces";
71 +
72 +    // create ConstraintWriter  
73 +    constraintWriter_ = new ConstraintWriter(info_, constraintOutputFile_.c_str());  
74 +
75 +    if (!constraintWriter_){
76 +      sprintf(painCave.errMsg, "Failed to create ConstraintWriter\n");
77 +      painCave.isFatal = 1;
78 +      simError();
79 +    }
80    }
81  
82    void Rattle::constraintA() {
# Line 69 | Line 86 | namespace OpenMD {
86    void Rattle::constraintB() {
87      if (!doRattle_) return;    
88      doConstraint(&Rattle::constraintPairB);
89 +
90 +    if (currentSnapshot_->getTime() >= currConstraintTime_){
91 +      Molecule* mol;
92 +      SimInfo::MoleculeIterator mi;
93 +      ConstraintPair* consPair;
94 +      Molecule::ConstraintPairIterator cpi;
95 +      std::list<ConstraintPair*> constraints;
96 +      for (mol = info_->beginMolecule(mi); mol != NULL;
97 +           mol = info_->nextMolecule(mi)) {
98 +        for (consPair = mol->beginConstraintPair(cpi); consPair != NULL;
99 +             consPair = mol->nextConstraintPair(cpi)) {
100 +          
101 +          constraints.push_back(consPair);
102 +        }
103 +      }
104 +      
105 +      constraintWriter_->writeConstraintForces(constraints);
106 +      currConstraintTime_ += constraintTime_;
107 +    }
108    }
109  
110    void Rattle::doConstraint(ConstraintPairFuncPtr func) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines