--- trunk/OOPSE/libmdtools/ConstraintAlgorithm.cpp 2004/06/03 21:51:55 1232 +++ trunk/OOPSE/libmdtools/ConstraintAlgorithm.cpp 2004/06/04 19:30:05 1248 @@ -2,6 +2,7 @@ #include "ConstraintPair.hpp" #include "SimInfo.hpp" #include "ConstraintManager.hpp" +#include "simError.h" //////////////////////////////////////////////////////////////////////////////// //Implementation of ConstraintAlgorithm @@ -27,7 +28,7 @@ void ConstraintAlgorithm::doConstrain(){ } void ConstraintAlgorithm::doConstrain(){ - const int maxConsIteration = 30; + const int maxConsIteration = 300; bool done; int iteration; int maxIteration; @@ -37,6 +38,7 @@ void ConstraintAlgorithm::doConstrain(){ int exeStatus; + error = false; for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ consElem = ceIter->currentItem(); @@ -62,7 +64,8 @@ void ConstraintAlgorithm::doConstrain(){ switch(exeStatus){ case consFail: - cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; + cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; + error = true; break; case consSuccess: //constrain the pair by moving two elements @@ -76,13 +79,16 @@ void ConstraintAlgorithm::doConstrain(){ case consPairHandlerFail: //can not found call back functor for constraint pair cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint pair " << endl; + error = true; break; case consElemHandlerFail: //can not found callback functor for constraint element cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint element " << endl; + error = true; break; default: cerr << "ConstraintAlgorithm::doConstrain() Error: unrecognized status" << endl; + error = true; break; } }//end for(iter->first()) @@ -95,7 +101,15 @@ void ConstraintAlgorithm::doConstrain(){ iteration++; }//end while - + + //if (!done){ + // error = true; + // sprintf(painCave.errMsg, + // "Constraint failure in constrainB, too many iterations: %d\n", + // iteration); + // painCave.isFatal = 1; + // simError(); + //} } @@ -103,7 +117,8 @@ int ConstraintAlgorithm::doConstrainPair(ConstraintPai map::iterator foundResult; CallbackFunctor* functor; - foundResult = callbackMap.find(typeid(consPair)); + //typeid must operate on deferenced, otherwise it will return the type_info of base class + foundResult = callbackMap.find(TypeInfo(typeid(*consPair))); if (foundResult != callbackMap.end()){ functor = foundResult->second; return (*functor)(consPair); @@ -147,11 +162,12 @@ ConsAlgoFramework::~ConsAlgoFramework(){ ConsAlgoFramework::~ConsAlgoFramework(){ delete ceIter; } + void ConsAlgoFramework::doPreConstraint(){ ConstraintElement* consElem; for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ consElem = ceIter->currentItem(); consElem->saveOldState(); - } -} + } +}