diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 359c651020..0578ab9060 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -150,6 +150,7 @@ void Foam::cyclicPolyPatch::calcTransforms } + // Some sanity checks if (half0Ctrs.size() != half1Ctrs.size()) { @@ -163,6 +164,22 @@ void Foam::cyclicPolyPatch::calcTransforms << exit(FatalError); } + if (transform_ != neighbPatch().transform_) + { + FatalErrorIn + ( + "cyclicPolyPatch::calcTransforms()" + ) << "Patch " << name() + << " has transform type " << transformTypeNames[transform_] + << ", neighbour patch " << neighbPatchName_ + << " has transform type " + << neighbPatch().transformTypeNames[transform_] + << exit(FatalError); + } + + + // Calculate transformation tensors + if (half0Ctrs.size() > 0) { vectorField half0Normals(half0Areas.size()); @@ -275,6 +292,71 @@ void Foam::cyclicPolyPatch::calcTransforms matchTol, transform_ ); + + + if (transform_ == TRANSLATIONAL) + { + if (debug) + { + Pout<< "cyclicPolyPatch::calcTransforms :" + << " Specified separation vector : " + << separationVector_ << endl; + } + + // Check that separation vectors are same. + const scalar avgTol = average(half0Tols); + if + ( + mag(separationVector_ + neighbPatch().separationVector_) + > avgTol + ) + { + WarningIn + ( + "cyclicPolyPatch::calcTransforms()" + ) << "Specified separation vector " << separationVector_ + << " differs by that of neighbouring patch " + << neighbPatch().separationVector_ + << " by more than tolerance " << avgTol << endl + << "patch:" << name() + << " neighbour:" << neighbPatchName_ + << endl; + } + + + // Override computed transform with specified. + if + ( + separation().size() != 1 + || mag(separation()[0] - separationVector_) > avgTol + ) + { + WarningIn + ( + "cyclicPolyPatch::calcTransforms()" + ) << "Specified separationVector " << separationVector_ + << " differs from computed separation vector " + << separation() << endl + << "This probably means your geometry is not consistent" + << " with the specified separation and might lead" + << " to problems." << endl + << "Continuing with specified separation vector " + << separationVector_ << endl + << "patch:" << name() + << " neighbour:" << neighbPatchName_ + << endl; + } + + // Set tensors + const_cast(forwardT()).clear(); + const_cast(reverseT()).clear(); + const_cast(separation()) = vectorField + ( + 1, + separationVector_ + ); + const_cast(collocated()) = boolList(1, false); + } } } } @@ -299,6 +381,16 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors anchors0 = getAnchorPoints(pp0, pp0.points()); half1Ctrs = pp1.faceCentres(); + if (debug) + { + Pout<< "cyclicPolyPatch::getCentresAndAnchors :" + << " patch:" << name() << nl + << "half0 untransformed faceCentres (avg) : " + << gAverage(half0Ctrs) << nl + << "half1 untransformed faceCentres (avg) : " + << gAverage(half1Ctrs) << endl; + } + switch (transform_) { case ROTATIONAL: @@ -355,23 +447,21 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors break; } - //- Problem: usually specified translation is not accurate enough - //- to get proper match so keep automatic determination over here. - //case TRANSLATIONAL: - //{ - // // Transform 0 points. - // - // if (debug) - // { - // Pout<< "cyclicPolyPatch::getCentresAndAnchors :" - // << "Specified translation : " << separationVector_ - // << endl; - // } - // - // half0Ctrs += separationVector_; - // anchors0 += separationVector_; - // break; - //} + case TRANSLATIONAL: + { + // Transform 0 points. + + if (debug) + { + Pout<< "cyclicPolyPatch::getCentresAndAnchors :" + << "Specified translation : " << separationVector_ + << endl; + } + + half0Ctrs -= separationVector_; + anchors0 -= separationVector_; + break; + } default: { // Assumes that cyclic is planar. This is also the initial @@ -1132,6 +1222,13 @@ bool Foam::cyclicPolyPatch::order labelList& rotation ) const { + if (debug) + { + Pout<< "order : of " << pp.size() + << " faces of patch:" << name() + << " neighbour:" << neighbPatchName_ + << endl; + } faceMap.setSize(pp.size()); faceMap = -1; @@ -1174,6 +1271,14 @@ bool Foam::cyclicPolyPatch::order tols ); + if (debug) + { + Pout<< "half0 transformed faceCentres (avg) : " + << gAverage(half0Ctrs) << nl + << "half1 untransformed faceCentres (avg) : " + << gAverage(half1Ctrs) << endl; + } + // Geometric match of face centre vectors bool matchedAll = matchPoints (