diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index 7a862ee9dacab94dc75585403ed937b5e0075c80..84028ebef507b440fef255669dbeebc861706000 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -44,7 +44,7 @@ const Foam::scalar Foam::cyclicACMIPolyPatch::tolerance_ = 1e-6; void Foam::cyclicACMIPolyPatch::initPatchFaceAreas() const { - if (!empty() && faceAreas0_.empty()) + if (!empty() && (faceAreas0_.empty() || boundaryMesh().mesh().moving())) { faceAreas0_ = faceAreas(); } @@ -52,9 +52,13 @@ void Foam::cyclicACMIPolyPatch::initPatchFaceAreas() const const cyclicACMIPolyPatch& nbrACMI = refCast<const cyclicACMIPolyPatch>(this->neighbPatch()); - if (!nbrACMI.empty() && nbrACMI.faceAreas0().empty()) + if + ( + !nbrACMI.empty() + && (nbrACMI.faceAreas0().empty() || boundaryMesh().mesh().moving()) + ) { - nbrACMI.initPatchFaceAreas(); + nbrACMI.faceAreas0_ = nbrACMI.faceAreas(); } } @@ -136,11 +140,13 @@ void Foam::cyclicACMIPolyPatch::setNeighbourFaceAreas() const void Foam::cyclicACMIPolyPatch::initGeometry(PstreamBuffers& pBufs) { + // Note: cyclicAMIPolyPatch clears AMI so do first + cyclicAMIPolyPatch::initGeometry(pBufs); + // Initialise the AMI so that base geometry (e.g. cell volumes) are - // correctly evaluated + // correctly evaluated before e.g. any of the processor patches gets + // hit (since uses cell volumes in its initGeometry) resetAMI(); - - cyclicAMIPolyPatch::initGeometry(pBufs); } @@ -156,7 +162,13 @@ void Foam::cyclicACMIPolyPatch::initMovePoints const pointField& p ) { + // Note: cyclicAMIPolyPatch clears AMI so do first cyclicAMIPolyPatch::initMovePoints(pBufs, p); + + // Initialise the AMI so that base geometry (e.g. cell volumes) are + // correctly evaluated before e.g. any of the processor patches gets + // hit (since uses cell volumes in its initGeometry) + resetAMI(); } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C index 231a2e0ba7a2ad673628c5afad7db19bb0b88def..a3a3707e015219e6cb4f59e24ee876660b63dbb9 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,7 +37,7 @@ Foam::tmp<Foam::Field<Type> > Foam::cyclicACMIPolyPatch::interpolate if (owner()) { - const scalarField& w = srcMask_; + const scalarField& w = AMI().srcWeightsSum(); tmp<Field<Type> > interpField(AMI().interpolateToSource(fldCouple)); @@ -45,7 +45,7 @@ Foam::tmp<Foam::Field<Type> > Foam::cyclicACMIPolyPatch::interpolate } else { - const scalarField& w = neighbPatch().tgtMask(); + const scalarField& w = neighbPatch().AMI().tgtWeightsSum(); tmp<Field<Type> > interpField ( @@ -82,16 +82,18 @@ void Foam::cyclicACMIPolyPatch::interpolate if (owner()) { - const scalarField& w = srcMask_; + const scalarField& w = AMI().srcWeightsSum(); AMI().interpolateToSource(fldCouple, cop, result); + result = result + (1.0 - w)*fldNonOverlap; } else { - const scalarField& w = neighbPatch().tgtMask(); + const scalarField& w = neighbPatch().AMI().tgtWeightsSum(); neighbPatch().AMI().interpolateToTarget(fldCouple, cop, result); + result = result + (1.0 - w)*fldNonOverlap; } } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index f58e99ce0e01e65646c8275b51513334e48eaef0..b8f9b3b2c0fbc8a24997a07a754a6f27dd737bae 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -24,9 +24,13 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicAMIPolyPatch.H" +#include "transformField.H" #include "SubField.H" +#include "polyMesh.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" +#include "faceAreaIntersect.H" +#include "ops.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -172,18 +176,19 @@ void Foam::cyclicAMIPolyPatch::calcTransforms scalar errorPos = mag(transformedAreaPos + area0); scalar errorNeg = mag(transformedAreaNeg + area0); - if (errorPos < errorNeg) - { - revT = revTPos; - } - else + scalar scaledErrorPos = errorPos/(mag(area0) + ROOTVSMALL); + scalar scaledErrorNeg = errorNeg/(mag(area0) + ROOTVSMALL); + + // One of the errors should be (close to) zero. If this is + // the reverse transformation flip the rotation angle. + revT = revTPos; + if (errorPos > errorNeg && scaledErrorNeg <= matchTolerance()) { revT = revTNeg; rotationAngle_ *= -1; } - scalar areaError = - min(errorPos, errorNeg)/(mag(area0) + ROOTVSMALL); + scalar areaError = min(scaledErrorPos, scaledErrorNeg); if (areaError > matchTolerance()) { @@ -406,6 +411,9 @@ void Foam::cyclicAMIPolyPatch::resetAMI void Foam::cyclicAMIPolyPatch::initGeometry(PstreamBuffers& pBufs) { + // The AMI is no longer valid. Leave it up to demand-driven calculation + AMIPtr_.clear(); + polyPatch::initGeometry(pBufs); } @@ -431,6 +439,9 @@ void Foam::cyclicAMIPolyPatch::initMovePoints const pointField& p ) { + // The AMI is no longer valid. Leave it up to demand-driven calculation + AMIPtr_.clear(); + polyPatch::initMovePoints(pBufs, p); // See below. Clear out any local geometry @@ -447,19 +458,15 @@ void Foam::cyclicAMIPolyPatch::movePoints polyPatch::movePoints(pBufs, p); calcTransforms(); - - // Note: resetAMI is called whilst in geometry update. So the slave - // side might not have reached 'movePoints'. Is explicitly handled by - // - clearing geometry of neighbour inside initMovePoints - // - not using localPoints() inside resetAMI - resetAMI(); } void Foam::cyclicAMIPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { - polyPatch::initUpdateMesh(pBufs); + // The AMI is no longer valid. Leave it up to demand-driven calculation AMIPtr_.clear(); + + polyPatch::initUpdateMesh(pBufs); }