mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -82,8 +82,6 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
|
|||||||
|
|
||||||
forAll(constraints_, cI)
|
forAll(constraints_, cI)
|
||||||
{
|
{
|
||||||
// Info<< nl << "Constraint " << cI << endl;
|
|
||||||
|
|
||||||
// constraint position
|
// constraint position
|
||||||
point cP = vector::zero;
|
point cP = vector::zero;
|
||||||
|
|
||||||
@ -106,6 +104,23 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
|
|||||||
|
|
||||||
allConverged = allConverged && constraintConverged;
|
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
|
// Accumulate constraint force
|
||||||
cFA += cF;
|
cFA += cF;
|
||||||
|
|
||||||
@ -113,7 +128,7 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
|
|||||||
cMA += cM + ((cP - centreOfMass()) ^ cF);
|
cMA += cM + ((cP - centreOfMass()) ^ cF);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(!allConverged && ++iter < maxConstraintIters_);
|
} while(++iter < maxConstraintIters_ && !allConverged);
|
||||||
|
|
||||||
if (iter >= maxConstraintIters_)
|
if (iter >= maxConstraintIters_)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -87,7 +87,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::constrain
|
|||||||
deltaT
|
deltaT
|
||||||
);
|
);
|
||||||
|
|
||||||
scalar theta = acos(predictedDir & fixedAxis_);
|
scalar theta = acos(min(predictedDir & fixedAxis_, 1.0));
|
||||||
|
|
||||||
vector rotationAxis = fixedAxis_ ^ predictedDir;
|
vector rotationAxis = fixedAxis_ ^ predictedDir;
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain
|
|||||||
{
|
{
|
||||||
predictedDir /= magPredictedDir;
|
predictedDir /= magPredictedDir;
|
||||||
|
|
||||||
theta = acos(predictedDir & refDir);
|
theta = acos(min(predictedDir & refDir, 1.0));
|
||||||
|
|
||||||
// Recalculating axis to give correct sign to angle
|
// Recalculating axis to give correct sign to angle
|
||||||
axis = (refDir ^ predictedDir);
|
axis = (refDir ^ predictedDir);
|
||||||
|
|||||||
@ -106,7 +106,7 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
|
|||||||
newDir -= (axis_ & newDir)*axis_;
|
newDir -= (axis_ & newDir)*axis_;
|
||||||
newDir /= mag(newDir);
|
newDir /= mag(newDir);
|
||||||
|
|
||||||
scalar theta = mag(acos(oldDir & newDir));
|
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
|
||||||
|
|
||||||
// Temporary axis with sign information.
|
// Temporary axis with sign information.
|
||||||
vector a = (oldDir ^ newDir);
|
vector a = (oldDir ^ newDir);
|
||||||
|
|||||||
@ -108,7 +108,7 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
|
|||||||
newDir -= (axis_ & newDir)*axis_;
|
newDir -= (axis_ & newDir)*axis_;
|
||||||
newDir /= mag(newDir);
|
newDir /= mag(newDir);
|
||||||
|
|
||||||
scalar theta = mag(acos(oldDir & newDir));
|
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
|
||||||
|
|
||||||
// Temporary axis with sign information.
|
// Temporary axis with sign information.
|
||||||
vector a = (oldDir ^ newDir);
|
vector a = (oldDir ^ newDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user