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 1979 by gezelter, Sat Apr 5 20:56:01 2014 UTC vs.
Revision 1982 by gezelter, Tue Apr 15 12:12:23 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines