cyclicAMIPolyPatch: Correct particle transformations across cyclic AMI patches

Patch provided by Daniel Jasiński
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1694
This commit is contained in:
Henry
2015-05-20 12:44:31 +01:00
parent 36ca836f28
commit a3232e5de7
3 changed files with 103 additions and 24 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -1051,10 +1051,10 @@ void Foam::particle::hitCyclicAMIPatch
{ {
const cyclicAMIPolyPatch& receiveCpp = cpp.neighbPatch(); const cyclicAMIPolyPatch& receiveCpp = cpp.neighbPatch();
// patch face index on sending side // Patch face index on sending side
label patchFaceI = faceI_ - cpp.start(); label patchFaceI = faceI_ - cpp.start();
// patch face index on receiving side - also updates position // Patch face index on receiving side - also updates position
patchFaceI = cpp.pointFace(patchFaceI, direction, position_); patchFaceI = cpp.pointFace(patchFaceI, direction, position_);
if (patchFaceI < 0) if (patchFaceI < 0)
@ -1074,7 +1074,7 @@ void Foam::particle::hitCyclicAMIPatch
<< " at position " << position_ << abort(FatalError); << " at position " << position_ << abort(FatalError);
} }
// convert face index into global numbering // Convert face index into global numbering
faceI_ = patchFaceI + receiveCpp.start(); faceI_ = patchFaceI + receiveCpp.start();
cellI_ = mesh_.faceOwner()[faceI_]; cellI_ = mesh_.faceOwner()[faceI_];
@ -1086,9 +1086,6 @@ void Foam::particle::hitCyclicAMIPatch
// Now the particle is on the receiving side // Now the particle is on the receiving side
// Have patch transform the position
receiveCpp.transformPosition(position_, patchFaceI);
// Transform the properties // Transform the properties
if (!receiveCpp.parallel()) if (!receiveCpp.parallel())
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,13 +24,9 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cyclicAMIPolyPatch.H" #include "cyclicAMIPolyPatch.H"
#include "transformField.H"
#include "SubField.H" #include "SubField.H"
#include "polyMesh.H"
#include "Time.H" #include "Time.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "faceAreaIntersect.H"
#include "ops.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -165,13 +161,13 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
+ sin(-rotationAngle_)*S + sin(-rotationAngle_)*S
); );
// 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); vector transformedAreaPos = gSum(half1Areas & revTPos);
vector transformedAreaNeg = gSum(half1Areas & revTNeg); vector transformedAreaNeg = gSum(half1Areas & revTNeg);
vector area0 = gSum(half0Areas); vector area0 = gSum(half0Areas);
// areas have opposite sign, so sum should be zero when // Areas have opposite sign, so sum should be zero when
// correct rotation applied // correct rotation applied
scalar errorPos = mag(transformedAreaPos + area0); scalar errorPos = mag(transformedAreaPos + area0);
scalar errorNeg = mag(transformedAreaNeg + area0); scalar errorNeg = mag(transformedAreaNeg + area0);
@ -357,7 +353,7 @@ void Foam::cyclicAMIPolyPatch::resetAMI
meshTools::writeOBJ(os, neighbPatch().localFaces(), nbrPoints); meshTools::writeOBJ(os, neighbPatch().localFaces(), nbrPoints);
} }
// transform neighbour patch to local system // Transform neighbour patch to local system
transformPosition(nbrPoints); transformPosition(nbrPoints);
primitivePatch nbrPatch0 primitivePatch nbrPatch0
( (
@ -617,7 +613,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
} }
default: default:
{ {
// no additional info required // No additional info required
} }
} }
@ -922,6 +918,64 @@ void Foam::cyclicAMIPolyPatch::transformPosition
} }
void Foam::cyclicAMIPolyPatch::reverseTransformPosition
(
point& l,
const label faceI
) const
{
if (!parallel())
{
const tensor& T =
(
reverseT().size() == 1
? reverseT()[0]
: reverseT()[faceI]
);
if (transform() == ROTATIONAL)
{
l = Foam::transform(T, l - rotationCentre_) + rotationCentre_;
}
else
{
l = Foam::transform(T, l);
}
}
else if (separated())
{
const vector& s =
(
separation().size() == 1
? separation()[0]
: separation()[faceI]
);
l += s;
}
}
void Foam::cyclicAMIPolyPatch::reverseTransformDirection
(
vector& d,
const label faceI
) const
{
if (!parallel())
{
const tensor& T =
(
reverseT().size() == 1
? reverseT()[0]
: reverseT()[faceI]
);
d = Foam::transform(T, d);
}
}
void Foam::cyclicAMIPolyPatch::calcGeometry void Foam::cyclicAMIPolyPatch::calcGeometry
( (
const primitivePatch& referPatch, const primitivePatch& referPatch,
@ -966,7 +1020,6 @@ bool Foam::cyclicAMIPolyPatch::order
rotation.setSize(pp.size()); rotation.setSize(pp.size());
rotation = 0; rotation = 0;
// do nothing
return false; return false;
} }
@ -978,28 +1031,43 @@ Foam::label Foam::cyclicAMIPolyPatch::pointFace
point& p point& p
) const ) const
{ {
point prt(p);
reverseTransformPosition(prt, faceI);
vector nrt(n);
reverseTransformDirection(nrt, faceI);
label nbrFaceI = -1;
if (owner()) if (owner())
{ {
return AMI().tgtPointFace nbrFaceI = AMI().tgtPointFace
( (
*this, *this,
neighbPatch(), neighbPatch(),
n, nrt,
faceI, faceI,
p prt
); );
} }
else else
{ {
return neighbPatch().AMI().srcPointFace nbrFaceI = neighbPatch().AMI().srcPointFace
( (
neighbPatch(), neighbPatch(),
*this, *this,
n, nrt,
faceI, faceI,
p prt
); );
} }
if (nbrFaceI >= 0)
{
p = prt;
}
return nbrFaceI;
} }
@ -1042,7 +1110,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
} }
default: default:
{ {
// no additional info to write // No additional info to write
} }
} }

View File

@ -329,6 +329,20 @@ public:
const label faceI const label faceI
) const; ) const;
//- Transform a patch-based position from this side to nbr side
virtual void reverseTransformPosition
(
point& l,
const label faceI
) const;
//- Transform a patch-based direction from this side to nbr side
virtual void reverseTransformDirection
(
vector& d,
const label faceI
) const;
// Interpolations // Interpolations