ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ConstraintAlgorithm.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/ConstraintAlgorithm.cpp (file contents):
Revision 1234 by tim, Fri Jun 4 03:15:31 2004 UTC vs.
Revision 1452 by tim, Mon Aug 23 15:11:36 2004 UTC

# Line 2 | Line 2
2   #include "ConstraintPair.hpp"
3   #include "SimInfo.hpp"
4   #include "ConstraintManager.hpp"
5 + #include "simError.h"
6 + #include "Vector3d.hpp"
7  
8   ////////////////////////////////////////////////////////////////////////////////
9   //Implementation of ConstraintAlgorithm
10   ////////////////////////////////////////////////////////////////////////////////
11   ConstraintAlgorithm::ConstraintAlgorithm(SimInfo* rhs){
12    info = rhs;
13 <  cpIter = info->consMan->creatPairIterator();
14 <  ceIter = info->consMan->creatElementIterator();  
13 >  cpIter = info->consMan->createPairIterator();
14 >  ceIter = info->consMan->createElementIterator();  
15   }
16  
17   ConstraintAlgorithm::~ConstraintAlgorithm(){
# Line 27 | Line 29 | void ConstraintAlgorithm::doConstrain(){
29   }
30  
31   void ConstraintAlgorithm::doConstrain(){
32 <  const int maxConsIteration = 30;
32 >  const int maxConsIteration = 20;
33    bool done;
34    int iteration;
35    int maxIteration;
# Line 36 | Line 38 | void ConstraintAlgorithm::doConstrain(){
38    ConstraintPair* consPair;
39    int exeStatus;
40  
41 <
41 >  error = false;
42    
43    for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){
44      consElem =  ceIter->currentItem();
# Line 61 | Line 63 | void ConstraintAlgorithm::doConstrain(){
63          exeStatus = doConstrainPair(consPair);
64  
65        switch(exeStatus){
66 +        case consExceedMaxIter:
67 +          //cerr << "ConstraintAlgorithm::doConstrain() Error: can not constrain the bond within maximum iteration" << endl;        
68 +          error = true;
69 +          
70          case consFail:
71 <          cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl;          
71 >          //cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl;        
72 >          error = true;
73            break;
74          case consSuccess:
75            //constrain the pair by moving two elements
# Line 76 | Line 83 | void ConstraintAlgorithm::doConstrain(){
83          case consPairHandlerFail:
84            //can not found call back functor for constraint pair
85            cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint pair " << endl;
86 +          error = true;
87            break;          
88          case consElemHandlerFail:
89            //can not found callback functor for constraint element
90            cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint element " << endl;
91 +          error = true;
92            break;
93          default:          
94            cerr << "ConstraintAlgorithm::doConstrain() Error: unrecognized status" << endl;
95 +          error = true;
96            break;
97        }      
98      }//end for(iter->first())
# Line 95 | Line 105 | void ConstraintAlgorithm::doConstrain(){
105  
106      iteration++;
107    }//end while
108 <  
108 >
109 >  //if (!done){
110 >  //  error = true;
111 >  //  sprintf(painCave.errMsg,
112 >  //          "Constraint failure in constrainB, too many iterations: %d\n",
113 >  //          iteration);
114 >  //  painCave.isFatal = 1;
115 >  //  simError();    
116 >  //}
117   }
118  
119  
# Line 142 | Line 160 | ConsAlgoFramework::ConsAlgoFramework(SimInfo* rhs){
160   //Implementation of ConsAlgoFramework
161   ////////////////////////////////////////////////////////////////////////////////
162   ConsAlgoFramework::ConsAlgoFramework(SimInfo* rhs){
163 <  ceIter = rhs->consMan->creatElementIterator();  
163 >  ceIter = rhs->consMan->createElementIterator();  
164   }
165  
166   ConsAlgoFramework::~ConsAlgoFramework(){
# Line 151 | Line 169 | void ConsAlgoFramework::doPreConstraint(){
169  
170   void ConsAlgoFramework::doPreConstraint(){
171    ConstraintElement* consElem;
172 +  Vector3d zeroVector(0.0, 0.0, 0.0);
173    
174    for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){
175      consElem =  ceIter->currentItem();
176      consElem->saveOldState();
177 +    consElem->setConsForce(zeroVector);
178 +    consElem->setConsTorque(zeroVector);
179    }
180   }  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines