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 1983 by gezelter, Tue Apr 15 20:36:19 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines