| 2 |
|
#include "ConstraintPair.hpp" |
| 3 |
|
#include "SimInfo.hpp" |
| 4 |
|
#include "ConstraintManager.hpp" |
| 5 |
+ |
#include "simError.h" |
| 6 |
|
|
| 7 |
|
//////////////////////////////////////////////////////////////////////////////// |
| 8 |
|
//Implementation of ConstraintAlgorithm |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
void ConstraintAlgorithm::doConstrain(){ |
| 31 |
< |
const int maxConsIteration = 30; |
| 31 |
> |
const int maxConsIteration = 1; |
| 32 |
|
bool done; |
| 33 |
|
int iteration; |
| 34 |
|
int maxIteration; |
| 38 |
|
int exeStatus; |
| 39 |
|
|
| 40 |
|
|
| 41 |
+ |
error = false; |
| 42 |
|
|
| 43 |
|
for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ |
| 44 |
|
consElem = ceIter->currentItem(); |
| 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 |
| 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()) |
| 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 |
|
|
| 121 |
|
map<TypeInfo, CallbackFunctor*>::iterator foundResult; |
| 122 |
|
CallbackFunctor* functor; |
| 123 |
|
|
| 124 |
< |
foundResult = callbackMap.find(typeid(consPair)); |
| 124 |
> |
//typeid must operate on deferenced, otherwise it will return the type_info of base class |
| 125 |
> |
foundResult = callbackMap.find(TypeInfo(typeid(*consPair))); |
| 126 |
|
if (foundResult != callbackMap.end()){ |
| 127 |
|
functor = foundResult->second; |
| 128 |
|
return (*functor)(consPair); |
| 166 |
|
ConsAlgoFramework::~ConsAlgoFramework(){ |
| 167 |
|
delete ceIter; |
| 168 |
|
} |
| 169 |
+ |
|
| 170 |
|
void ConsAlgoFramework::doPreConstraint(){ |
| 171 |
|
ConstraintElement* consElem; |
| 172 |
|
|
| 173 |
|
for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ |
| 174 |
|
consElem = ceIter->currentItem(); |
| 175 |
|
consElem->saveOldState(); |
| 176 |
< |
} |
| 177 |
< |
} |
| 176 |
> |
} |
| 177 |
> |
} |