本文整理汇总了C++中Molecule::beginConstraintPair方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::beginConstraintPair方法的具体用法?C++ Molecule::beginConstraintPair怎么用?C++ Molecule::beginConstraintPair使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::beginConstraintPair方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constraintB
void Rattle::constraintB() {
if (!doRattle_) return;
doConstraint(&Rattle::constraintPairB);
if (currentSnapshot_->getTime() >= currConstraintTime_){
Molecule* mol;
SimInfo::MoleculeIterator mi;
ConstraintPair* consPair;
Molecule::ConstraintPairIterator cpi;
std::list<ConstraintPair*> constraints;
for (mol = info_->beginMolecule(mi); mol != NULL;
mol = info_->nextMolecule(mi)) {
for (consPair = mol->beginConstraintPair(cpi); consPair != NULL;
consPair = mol->nextConstraintPair(cpi)) {
constraints.push_back(consPair);
}
}
constraintWriter_->writeConstraintForces(constraints);
currConstraintTime_ += constraintTime_;
}
}
示例2: doConstraint
void Shake::doConstraint(ConstraintPairFuncPtr func) {
if (!doShake_) return;
Molecule* mol;
SimInfo::MoleculeIterator mi;
ConstraintElem* consElem;
Molecule::ConstraintElemIterator cei;
ConstraintPair* consPair;
Molecule::ConstraintPairIterator cpi;
for (mol = info_->beginMolecule(mi); mol != NULL;
mol = info_->nextMolecule(mi)) {
for (consElem = mol->beginConstraintElem(cei); consElem != NULL;
consElem = mol->nextConstraintElem(cei)) {
consElem->setMoved(true);
consElem->setMoving(false);
}
}
//main loop of constraint algorithm
int done = 0;
int iteration = 0;
while(!done && iteration < maxConsIteration_){
done = 1;
//loop over every constraint pair
for (mol = info_->beginMolecule(mi); mol != NULL;
mol = info_->nextMolecule(mi)) {
for (consPair = mol->beginConstraintPair(cpi); consPair != NULL;
consPair = mol->nextConstraintPair(cpi)) {
//dispatch constraint algorithm
if(consPair->isMoved()) {
int exeStatus = (this->*func)(consPair);
switch(exeStatus){
case consFail:
sprintf(painCave.errMsg,
"Constraint failure in Shake::constrainA, "
"Constraint Fail\n");
painCave.isFatal = 1;
simError();
break;
case consSuccess:
// constrain the pair by moving two elements
done = 0;
consPair->getConsElem1()->setMoving(true);
consPair->getConsElem2()->setMoving(true);
break;
case consAlready:
// current pair is already constrained, do not need to
// move the elements
break;
default:
sprintf(painCave.errMsg, "ConstraintAlgorithm::doConstraint() "
"Error: unrecognized status");
painCave.isFatal = 1;
simError();
break;
}
}
}
}//end for(iter->first())
#ifdef IS_MPI
MPI_Allreduce(MPI_IN_PLACE, &done, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
#endif
errorCheckPoint();
for (mol = info_->beginMolecule(mi); mol != NULL;
mol = info_->nextMolecule(mi)) {
for (consElem = mol->beginConstraintElem(cei); consElem != NULL;
consElem = mol->nextConstraintElem(cei)) {
consElem->setMoved(consElem->getMoving());
consElem->setMoving(false);
}
}
iteration++;
}//end while
if (!done){
sprintf(painCave.errMsg,
"Constraint failure in Shake::constrainA, "
"too many iterations: %d\n",
iteration);
painCave.isFatal = 1;
simError();
}
errorCheckPoint();
}