Commit c931631f authored by graham's avatar graham
Browse files

BUG: sixDoFRigidBodyMotion. Fixing nan appearances when argument of acos > 1.0

Adding more constraint reporting.

Changed order of evaluation of while condition to make +iter first,
otherwise doesn't increment iter, reporting 0 iterations.
parent 2170345d
......@@ -82,8 +82,6 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
forAll(constraints_, cI)
{
// Info<< nl << "Constraint " << cI << endl;
// constraint position
point cP = vector::zero;
......@@ -106,6 +104,23 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
allConverged = allConverged && constraintConverged;
if (report_)
{
Info<< "Constraint " << constraints_[cI].name()
<< ": force " << cF << " moment " << cM;
if (constraintConverged)
{
Info<< " - converged";
}
else
{
Info<< " - not converged";
}
Info<< endl;
}
// Accumulate constraint force
cFA += cF;
......@@ -113,7 +128,7 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
cMA += cM + ((cP - centreOfMass()) ^ cF);
}
} while(!allConverged && ++iter < maxConstraintIters_);
} while(++iter < maxConstraintIters_ && !allConverged);
if (iter >= maxConstraintIters_)
{
......
......@@ -87,7 +87,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::constrain
deltaT
);
scalar theta = acos(predictedDir & fixedAxis_);
scalar theta = acos(min(predictedDir & fixedAxis_, 1.0));
vector rotationAxis = fixedAxis_ ^ predictedDir;
......
......@@ -114,7 +114,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain
{
predictedDir /= magPredictedDir;
theta = acos(predictedDir & refDir);
theta = acos(min(predictedDir & refDir, 1.0));
// Recalculating axis to give correct sign to angle
axis = (refDir ^ predictedDir);
......
......@@ -106,7 +106,7 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
newDir -= (axis_ & newDir)*axis_;
newDir /= mag(newDir);
scalar theta = mag(acos(oldDir & newDir));
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
// Temporary axis with sign information.
vector a = (oldDir ^ newDir);
......
......@@ -108,7 +108,7 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
newDir -= (axis_ & newDir)*axis_;
newDir /= mag(newDir);
scalar theta = mag(acos(oldDir & newDir));
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
// Temporary axis with sign information.
vector a = (oldDir ^ newDir);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment