cyclicAMIPolyPatch: corrected rotationAngle signs in parallel decomposition of cyclicAMI

Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1726
This commit is contained in:
Henry Weller
2015-10-23 08:31:11 +01:00
parent 1fb1af5e87
commit 7595f4c225

View File

@ -136,23 +136,23 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
if (rotationAngleDefined_) if (rotationAngleDefined_)
{ {
tensor T(rotationAxis_*rotationAxis_); const tensor T(rotationAxis_*rotationAxis_);
tensor S const tensor S
( (
0, -rotationAxis_.z(), rotationAxis_.y(), 0, -rotationAxis_.z(), rotationAxis_.y(),
rotationAxis_.z(), 0, -rotationAxis_.x(), rotationAxis_.z(), 0, -rotationAxis_.x(),
-rotationAxis_.y(), rotationAxis_.x(), 0 -rotationAxis_.y(), rotationAxis_.x(), 0
); );
tensor revTPos const tensor revTPos
( (
T T
+ cos(rotationAngle_)*(tensor::I - T) + cos(rotationAngle_)*(tensor::I - T)
+ sin(rotationAngle_)*S + sin(rotationAngle_)*S
); );
tensor revTNeg const tensor revTNeg
( (
T T
+ cos(-rotationAngle_)*(tensor::I - T) + cos(-rotationAngle_)*(tensor::I - T)
@ -161,27 +161,30 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
// Check - assume correct angle when difference in face areas // Check - assume correct angle when difference in face areas
// is the smallest // is the smallest
vector transformedAreaPos = gSum(half1Areas & revTPos); const vector transformedAreaPos = gSum(half1Areas & revTPos);
vector transformedAreaNeg = gSum(half1Areas & revTNeg); const vector transformedAreaNeg = gSum(half1Areas & revTNeg);
vector area0 = gSum(half0Areas); const vector area0 = gSum(half0Areas);
const scalar magArea0 = mag(area0) + ROOTVSMALL;
// Areas have opposite sign, so sum should be zero when // Areas have opposite sign, so sum should be zero when correct
// correct rotation applied // rotation applied
scalar errorPos = mag(transformedAreaPos + area0); const scalar errorPos = mag(transformedAreaPos + area0);
scalar errorNeg = mag(transformedAreaNeg + area0); const scalar errorNeg = mag(transformedAreaNeg + area0);
if (errorPos < errorNeg) const scalar normErrorPos = errorPos/magArea0;
{ const scalar normErrorNeg = errorNeg/magArea0;
revT = revTPos;
} if (errorPos > errorNeg && normErrorNeg < matchTolerance())
else
{ {
revT = revTNeg; revT = revTNeg;
rotationAngle_ *= -1; rotationAngle_ *= -1;
} }
else
{
revT = revTPos;
}
scalar areaError = const scalar areaError = min(normErrorPos, normErrorNeg);
min(errorPos, errorNeg)/(mag(area0) + ROOTVSMALL);
if (areaError > matchTolerance()) if (areaError > matchTolerance())
{ {
@ -195,8 +198,7 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
"const pointField&, " "const pointField&, "
"const vectorField&" "const vectorField&"
")" ")"
) ) << "Patch areas are not consistent within "
<< "Patch areas are not consistent within "
<< 100*matchTolerance() << 100*matchTolerance()
<< " % indicating a possible error in the specified " << " % indicating a possible error in the specified "
<< "angle of rotation" << nl << "angle of rotation" << nl