From 3ad25a12d4e0a2cd3cec9628e786beb72834c829 Mon Sep 17 00:00:00 2001 From: laurence Date: Tue, 11 Dec 2012 17:03:23 +0000 Subject: [PATCH] ENH: polyPatches + Move transform_ up to coupledPolyPatch + Add coincident full match to the transform type. This will fully match faces even if they have zero area. + Add transform type to the constructor as a default argument --- .../basic/coupled/coupledPolyPatch.C | 97 ++- .../basic/coupled/coupledPolyPatch.H | 30 +- .../constraint/cyclic/cyclicPolyPatch.C | 93 ++- .../constraint/cyclic/cyclicPolyPatch.H | 12 +- .../cyclicSlip/cyclicSlipPolyPatch.H | 5 +- .../nonuniformTransformCyclicPolyPatch.H | 5 +- .../constraint/oldCyclic/oldCyclicPolyPatch.C | 66 +- .../constraint/oldCyclic/oldCyclicPolyPatch.H | 20 +- .../constraint/processor/processorPolyPatch.C | 650 +++++++++++++----- .../constraint/processor/processorPolyPatch.H | 14 +- .../processorCyclicPolyPatch.C | 15 +- .../processorCyclicPolyPatch.H | 3 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 98 ++- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H | 10 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H | 7 - 15 files changed, 745 insertions(+), 380 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C index 4e43300134..28859afe4d 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C @@ -37,15 +37,16 @@ namespace Foam const scalar coupledPolyPatch::defaultMatchTol_ = 1e-4; template<> - const char* NamedEnum::names[] = + const char* NamedEnum::names[] = { "unknown", "rotational", "translational", + "coincidentFullMatch", "noOrdering" }; - const NamedEnum + const NamedEnum coupledPolyPatch::transformTypeNames; } @@ -129,14 +130,65 @@ void Foam::coupledPolyPatch::writeOBJ Foam::pointField Foam::coupledPolyPatch::getAnchorPoints ( const UList& faces, - const pointField& points + const pointField& points, + const transformType transform ) { pointField anchors(faces.size()); - forAll(faces, faceI) + if (transform == COINCIDENTFULLMATCH) { - anchors[faceI] = points[faces[faceI][0]]; + // Return the first point + forAll(faces, faceI) + { + anchors[faceI] = points[faces[faceI][0]]; + } + } + else + { + // Make anchor point unique + forAll(faces, faceI) + { + const face& f = faces[faceI]; + + bool unique = true; + + forAll(f, fp1) + { + const point& p1 = points[f[fp1]]; + + unique = true; + + for (label fp2 = 0; fp2 < f.size(); ++fp2) + { + if (f[fp1] == f[fp2]) + { + continue; + } + + const point& p2 = points[f[fp2]]; + + // @todo Change to a tolerance and possibly select closest + // point to the origin + if (p1 == p2) + { + unique = false; + break; + } + } + + if (unique) + { + anchors[faceI] = p1; + break; + } + } + + if (!unique) + { + anchors[faceI] = points[faces[faceI][0]]; + } + } } return anchors; @@ -172,7 +224,12 @@ Foam::scalarField Foam::coupledPolyPatch::calcFaceTol maxLenSqr = max(maxLenSqr, magSqr(pt - cc)); maxCmpt = max(maxCmpt, cmptMax(cmptMag(pt))); } - tols[faceI] = max(SMALL, max(SMALL*maxCmpt, Foam::sqrt(maxLenSqr))); + + tols[faceI] = max + ( + SMALL, + max(SMALL*maxCmpt, Foam::sqrt(maxLenSqr)) + ); } return tols; } @@ -230,7 +287,7 @@ Foam::label Foam::coupledPolyPatch::getRotation << Foam::sqrt(minDistSqr) << " to the anchor " << anchor << ". Continuing but results might be wrong." - << endl; + << nl << endl; } } @@ -292,7 +349,8 @@ void Foam::coupledPolyPatch::calcTransformTensors transform == ROTATIONAL || ( transform != TRANSLATIONAL - && (sum(mag(nf & nr)) < Cf.size()-error) + && transform != COINCIDENTFULLMATCH + && (sum(mag(nf & nr)) < Cf.size() - error) ) ) { @@ -427,11 +485,13 @@ Foam::coupledPolyPatch::coupledPolyPatch const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform ) : polyPatch(name, size, start, index, bm, patchType), - matchTolerance_(defaultMatchTol_) + matchTolerance_(defaultMatchTol_), + transform_(transform) {} @@ -445,7 +505,11 @@ Foam::coupledPolyPatch::coupledPolyPatch ) : polyPatch(name, dict, index, bm, patchType), - matchTolerance_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)) + matchTolerance_(dict.lookupOrDefault("matchTolerance", defaultMatchTol_)), + transform_ + ( + transformTypeNames.read(dict.lookupOrDefault("transform", "UNKNOWN")) + ) {} @@ -456,7 +520,8 @@ Foam::coupledPolyPatch::coupledPolyPatch ) : polyPatch(pp, bm), - matchTolerance_(pp.matchTolerance_) + matchTolerance_(pp.matchTolerance_), + transform_(pp.transform_) {} @@ -470,7 +535,8 @@ Foam::coupledPolyPatch::coupledPolyPatch ) : polyPatch(pp, bm, index, newSize, newStart), - matchTolerance_(pp.matchTolerance_) + matchTolerance_(pp.matchTolerance_), + transform_(pp.transform_) {} @@ -484,7 +550,8 @@ Foam::coupledPolyPatch::coupledPolyPatch ) : polyPatch(pp, bm, index, mapAddressing, newStart), - matchTolerance_(pp.matchTolerance_) + matchTolerance_(pp.matchTolerance_), + transform_(pp.transform_) {} @@ -503,6 +570,8 @@ void Foam::coupledPolyPatch::write(Ostream& os) const { os.writeKeyword("matchTolerance") << matchTolerance_ << token::END_STATEMENT << nl; + os.writeKeyword("transform") << transformTypeNames[transform_] + << token::END_STATEMENT << nl; } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H index 7cb56879c4..ebbd2ce062 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H @@ -60,9 +60,12 @@ public: UNKNOWN, // unspecified; automatic ordering ROTATIONAL, // rotation along coordinate axis TRANSLATIONAL, // translation + COINCIDENTFULLMATCH,// assume no transforms + // and check the points in faces match NOORDERING // unspecified, no automatic ordering }; - static const NamedEnum transformTypeNames; + + static const NamedEnum transformTypeNames; private: @@ -75,6 +78,9 @@ private: //- local matching tolerance const scalar matchTolerance_; + //- Type of transformation + transformType transform_; + //- offset (distance) vector from one side of the couple to the other mutable vectorField separation_; @@ -150,11 +156,12 @@ protected: label& vertI ); - //- Get f[0] for all faces + //- Get a unique anchor point for all faces static pointField getAnchorPoints ( const UList&, - const pointField& + const pointField&, + const transformType ); //- Get the number of vertices face f needs to be rotated such that @@ -184,7 +191,8 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform ); //- Construct from dictionary @@ -245,6 +253,20 @@ public: return !owner(); } + //- Type of transform + transformType transform() const + { + return transform_; + } + + //- Type of transform + // This is currently only for use when collapsing generated + // meshes that can have zero area faces. + transformType& transform() + { + return transform_; + } + //- Transform a patch-based position from other side to this side virtual void transformPosition(pointField&) const = 0; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index ce8f260382..730fa40249 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -164,16 +164,16 @@ void Foam::cyclicPolyPatch::calcTransforms << exit(FatalError); } - if (transform_ != neighbPatch().transform_) + if (transform() != neighbPatch().transform()) { FatalErrorIn ( "cyclicPolyPatch::calcTransforms()" ) << "Patch " << name() - << " has transform type " << transformTypeNames[transform_] + << " has transform type " << transformTypeNames[transform()] << ", neighbour patch " << neighbPatchName_ << " has transform type " - << neighbPatch().transformTypeNames[transform_] + << neighbPatch().transformTypeNames[neighbPatch().transform()] << exit(FatalError); } @@ -261,7 +261,7 @@ void Foam::cyclicPolyPatch::calcTransforms // Calculate transformation tensors - if (transform_ == ROTATIONAL) + if (transform() == ROTATIONAL) { // Calculate using the given rotation axis and centre. Do not // use calculated normals. @@ -320,11 +320,11 @@ void Foam::cyclicPolyPatch::calcTransforms half1Normals, half0Tols, matchTolerance(), - transform_ + transform() ); - if (transform_ == TRANSLATIONAL) + if (transform() == TRANSLATIONAL) { if (debug) { @@ -406,7 +406,7 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors { // Get geometric data on both halves. half0Ctrs = pp0.faceCentres(); - anchors0 = getAnchorPoints(pp0, pp0.points()); + anchors0 = getAnchorPoints(pp0, pp0.points(), transform()); half1Ctrs = pp1.faceCentres(); if (debug) @@ -421,7 +421,7 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors if (half0Ctrs.size()) { - switch (transform_) + switch (transform()) { case ROTATIONAL: { @@ -601,13 +601,13 @@ Foam::cyclicPolyPatch::cyclicPolyPatch const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform ) : - coupledPolyPatch(name, size, start, index, bm, patchType), + coupledPolyPatch(name, size, start, index, bm, patchType, transform), neighbPatchName_(word::null), neighbPatchID_(-1), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero), @@ -633,10 +633,9 @@ Foam::cyclicPolyPatch::cyclicPolyPatch const vector& separationVector ) : - coupledPolyPatch(name, size, start, index, bm, typeName), + coupledPolyPatch(name, size, start, index, bm, typeName, transform), neighbPatchName_(neighbPatchName), neighbPatchID_(-1), - transform_(transform), rotationAxis_(rotationAxis), rotationCentre_(rotationCentre), separationVector_(separationVector), @@ -660,7 +659,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch coupledPolyPatch(name, dict, index, bm, patchType), neighbPatchName_(dict.lookupOrDefault("neighbourPatch", word::null)), neighbPatchID_(-1), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero), @@ -693,37 +691,33 @@ Foam::cyclicPolyPatch::cyclicPolyPatch << exit(FatalIOError); } - if (dict.found("transform")) + switch (transform()) { - transform_ = transformTypeNames.read(dict.lookup("transform")); - switch (transform_) + case ROTATIONAL: { - case ROTATIONAL: - { - dict.lookup("rotationAxis") >> rotationAxis_; - dict.lookup("rotationCentre") >> rotationCentre_; + dict.lookup("rotationAxis") >> rotationAxis_; + dict.lookup("rotationCentre") >> rotationCentre_; - scalar magRot = mag(rotationAxis_); - if (magRot < SMALL) - { - FatalIOErrorIn("cyclicPolyPatch::cyclicPolyPatch(..)", dict) - << "Illegal rotationAxis " << rotationAxis_ << endl - << "Please supply a non-zero vector." - << exit(FatalIOError); - } - rotationAxis_ /= magRot; + scalar magRot = mag(rotationAxis_); + if (magRot < SMALL) + { + FatalIOErrorIn("cyclicPolyPatch::cyclicPolyPatch(..)", dict) + << "Illegal rotationAxis " << rotationAxis_ << endl + << "Please supply a non-zero vector." + << exit(FatalIOError); + } + rotationAxis_ /= magRot; - break; - } - case TRANSLATIONAL: - { - dict.lookup("separationVector") >> separationVector_; - break; - } - default: - { - // no additional info required - } + break; + } + case TRANSLATIONAL: + { + dict.lookup("separationVector") >> separationVector_; + break; + } + default: + { + // no additional info required } } @@ -741,7 +735,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch coupledPolyPatch(pp, bm), neighbPatchName_(pp.neighbPatchName()), neighbPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -766,7 +759,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch coupledPolyPatch(pp, bm, index, newSize, newStart), neighbPatchName_(neighbPatchName), neighbPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -798,7 +790,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch coupledPolyPatch(pp, bm, index, mapAddressing, newStart), neighbPatchName_(pp.neighbPatchName_), neighbPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -857,7 +848,7 @@ void Foam::cyclicPolyPatch::transformPosition(pointField& l) const { if (!parallel()) { - if (transform_ == ROTATIONAL) + if (transform() == ROTATIONAL) { l = Foam::transform(forwardT(), l-rotationCentre_) @@ -900,7 +891,7 @@ void Foam::cyclicPolyPatch::transformPosition(point& l, const label facei) const : forwardT()[facei] ); - if (transform_ == ROTATIONAL) + if (transform() == ROTATIONAL) { l = Foam::transform(T, l-rotationCentre_) + rotationCentre_; } @@ -1274,7 +1265,7 @@ bool Foam::cyclicPolyPatch::order rotation.setSize(pp.size()); rotation = 0; - if (transform_ == NOORDERING) + if (transform() == NOORDERING) { // No faces, nothing to change. return false; @@ -1455,12 +1446,10 @@ void Foam::cyclicPolyPatch::write(Ostream& os) const coupledPolyPatch::write(os); os.writeKeyword("neighbourPatch") << neighbPatchName_ << token::END_STATEMENT << nl; - switch (transform_) + switch (transform()) { case ROTATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("rotationAxis") << rotationAxis_ << token::END_STATEMENT << nl; os.writeKeyword("rotationCentre") << rotationCentre_ @@ -1469,16 +1458,12 @@ void Foam::cyclicPolyPatch::write(Ostream& os) const } case TRANSLATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("separationVector") << separationVector_ << token::END_STATEMENT << nl; break; } case NOORDERING: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; break; } default: diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H index f2f1c49a87..8f094da8cf 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H @@ -72,9 +72,6 @@ class cyclicPolyPatch //- Index of other half mutable label neighbPatchID_; - //- Type of transformation - rotational or translational - transformType transform_; - // For rotation //- Axis of rotation for rotational cyclics @@ -202,7 +199,8 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform = UNKNOWN ); //- Construct from components @@ -371,12 +369,6 @@ public: } } - //- Type of transform - transformType transform() const - { - return transform_; - } - //- Axis of rotation for rotational cyclics const vector& rotationAxis() const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclicSlip/cyclicSlipPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclicSlip/cyclicSlipPolyPatch.H index fc2de2d14f..9eed97fafe 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclicSlip/cyclicSlipPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclicSlip/cyclicSlipPolyPatch.H @@ -68,10 +68,11 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform = UNKNOWN ) : - cyclicPolyPatch(name, size, start, index, bm, patchType) + cyclicPolyPatch(name, size, start, index, bm, patchType, transform) {} //- Construct from dictionary diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPolyPatch.H index 8ed56b3878..75431fdaa8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPolyPatch.H @@ -68,10 +68,11 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform = UNKNOWN ) : - cyclicPolyPatch(name, size, start, index, bm, patchType) + cyclicPolyPatch(name, size, start, index, bm, patchType, transform) {} //- Construct from dictionary diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C index 7dc587bbfe..627aced76a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,23 +43,8 @@ namespace Foam addToRunTimeSelectionTable(polyPatch, oldCyclicPolyPatch, word); addToRunTimeSelectionTable(polyPatch, oldCyclicPolyPatch, dictionary); - - template<> - const char* Foam::NamedEnum - < - Foam::oldCyclicPolyPatch::transformType, - 3 - >::names[] = - { - "unknown", - "rotational", - "translational" - }; } -const Foam::NamedEnum - Foam::oldCyclicPolyPatch::transformTypeNames; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Foam::pointField Foam::oldCyclicPolyPatch::calcFaceCentres @@ -321,7 +306,7 @@ void Foam::oldCyclicPolyPatch::getCentresAndAnchors anchors0 = getAnchorPoints(half0Faces, pp.points()); half1Ctrs = calcFaceCentres(half1Faces, pp.points()); - switch (transform_) + switch (transform()) { case ROTATIONAL: { @@ -588,12 +573,12 @@ Foam::oldCyclicPolyPatch::oldCyclicPolyPatch const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform ) : - coupledPolyPatch(name, size, start, index, bm, patchType), + coupledPolyPatch(name, size, start, index, bm, patchType, transform), featureCos_(0.9), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero) @@ -611,7 +596,6 @@ Foam::oldCyclicPolyPatch::oldCyclicPolyPatch : coupledPolyPatch(name, dict, index, bm, patchType), featureCos_(0.9), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero) @@ -638,26 +622,22 @@ Foam::oldCyclicPolyPatch::oldCyclicPolyPatch dict.readIfPresent("featureCos", featureCos_); - if (dict.found("transform")) + switch (transform()) { - transform_ = transformTypeNames.read(dict.lookup("transform")); - switch (transform_) + case ROTATIONAL: { - case ROTATIONAL: - { - dict.lookup("rotationAxis") >> rotationAxis_; - dict.lookup("rotationCentre") >> rotationCentre_; - break; - } - case TRANSLATIONAL: - { - dict.lookup("separationVector") >> separationVector_; - break; - } - default: - { - // no additional info required - } + dict.lookup("rotationAxis") >> rotationAxis_; + dict.lookup("rotationCentre") >> rotationCentre_; + break; + } + case TRANSLATIONAL: + { + dict.lookup("separationVector") >> separationVector_; + break; + } + default: + { + // no additional info required } } } @@ -671,7 +651,6 @@ Foam::oldCyclicPolyPatch::oldCyclicPolyPatch : coupledPolyPatch(pp, bm), featureCos_(pp.featureCos_), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_) @@ -689,7 +668,6 @@ Foam::oldCyclicPolyPatch::oldCyclicPolyPatch : coupledPolyPatch(pp, bm, index, newSize, newStart), featureCos_(pp.featureCos_), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_) @@ -1269,12 +1247,10 @@ void Foam::oldCyclicPolyPatch::write(Ostream& os) const os.writeKeyword("featureCos") << featureCos_ << token::END_STATEMENT << nl; - switch (transform_) + switch (transform()) { case ROTATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("rotationAxis") << rotationAxis_ << token::END_STATEMENT << nl; os.writeKeyword("rotationCentre") << rotationCentre_ @@ -1283,8 +1259,6 @@ void Foam::oldCyclicPolyPatch::write(Ostream& os) const } case TRANSLATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("separationVector") << separationVector_ << token::END_STATEMENT << nl; break; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.H index 5d996988c2..d3d623dddb 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,27 +54,12 @@ class oldCyclicPolyPatch : public coupledPolyPatch { -public: - - enum transformType - { - UNKNOWN, - ROTATIONAL, - TRANSLATIONAL - }; - static const NamedEnum transformTypeNames; - - -private: - // Private data //- Morph:angle between normals of neighbouring faces. // Used to split cyclic into halves. scalar featureCos_; - //- Type of transformation - rotational or translational - transformType transform_; // For rotation @@ -199,7 +184,8 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform = UNKNOWN ); //- Construct from dictionary diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 05664dd6ea..94fbc8a0fb 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -34,6 +34,7 @@ License #include "Time.H" #include "transformList.H" #include "PstreamBuffers.H" +#include "const_circulator.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,10 +55,11 @@ Foam::processorPolyPatch::processorPolyPatch const label index, const polyBoundaryMesh& bm, const int myProcNo, - const int neighbProcNo + const int neighbProcNo, + const transformType transform ) : - coupledPolyPatch(name, size, start, index, bm, typeName), + coupledPolyPatch(name, size, start, index, bm, typeName, transform), myProcNo_(myProcNo), neighbProcNo_(neighbProcNo), neighbFaceCentres_(), @@ -173,7 +175,6 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) >> neighbFaceCellCentres_; } - // My normals vectorField faceNormals(size()); @@ -181,8 +182,7 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) vectorField nbrFaceNormals(neighbFaceAreas_.size()); // Face match tolerances - scalarField tols = - calcFaceTol(*this, points(), faceCentres()); + scalarField tols = calcFaceTol(*this, points(), faceCentres()); // Calculate normals from areas and check forAll(faceNormals, facei) @@ -191,13 +191,15 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) scalar nbrMagSf = mag(neighbFaceAreas_[facei]); scalar avSf = (magSf + nbrMagSf)/2.0; - if (magSf < ROOTVSMALL && nbrMagSf < ROOTVSMALL) + // For small face area calculation the results of the area + // calculation have been found to only be accurate to ~1e-20 + if (magSf < SMALL && nbrMagSf < SMALL) { // Undetermined normal. Use dummy normal to force separation - // check. (note use of sqrt(VSMALL) since that is how mag - // scales) + // check. faceNormals[facei] = point(1, 0, 0); - nbrFaceNormals[facei] = faceNormals[facei]; + nbrFaceNormals[facei] = -faceNormals[facei]; + tols[facei] = GREAT; } else if (mag(magSf - nbrMagSf) > matchTolerance()*sqr(tols[facei])) { @@ -271,7 +273,8 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs) faceNormals, nbrFaceNormals, matchTolerance()*tols, - matchTolerance() + matchTolerance(), + transform() ); } } @@ -391,6 +394,7 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs) { // Find face and index in face on this side. const face& f = localFaces()[nbrPointFace[nbrPointI]]; + label index = (f.size() - nbrPointIndex[nbrPointI]) % f.size(); label patchPointI = f[index]; @@ -486,7 +490,11 @@ void Foam::processorPolyPatch::initOrder const primitivePatch& pp ) const { - if (!Pstream::parRun()) + if + ( + !Pstream::parRun() + || transform() == NOORDERING + ) { return; } @@ -522,15 +530,154 @@ void Foam::processorPolyPatch::initOrder if (owner()) { - pointField anchors(getAnchorPoints(pp, pp.points())); + if (transform() == COINCIDENTFULLMATCH) + { + // Pass the patch points and faces across + UOPstream toNeighbour(neighbProcNo(), pBufs); + toNeighbour << pp.localPoints() + << pp.localFaces(); + } + else + { + const pointField& ppPoints = pp.points(); - // Now send all info over to the neighbour - UOPstream toNeighbour(neighbProcNo(), pBufs); - toNeighbour << pp.faceCentres() << anchors; + pointField anchors(getAnchorPoints(pp, ppPoints, transform())); + + // Get the average of the points of each face. This is needed in case + // the face centroid calculation is incorrect due tothe face having a + // very high aspect ratio. + pointField facePointAverages(pp.size(), point::zero); + forAll(pp, fI) + { + const labelList& facePoints = pp[fI]; + + forAll(facePoints, pI) + { + facePointAverages[fI] += ppPoints[facePoints[pI]]; + } + + facePointAverages[fI] /= facePoints.size(); + } + + // Now send all info over to the neighbour + UOPstream toNeighbour(neighbProcNo(), pBufs); + toNeighbour << pp.faceCentres() << pp.faceNormals() + << anchors << facePointAverages; + } } } +// Returns rotation. +// + -1 : no match +// + 0 : match +// + >0 : match if rotated clockwise by this amount +Foam::label Foam::processorPolyPatch::matchFace +( + const face& a, + const pointField& aPts, + const face& b, + const pointField& bPts, + const bool sameOrientation, + const scalar absTolSqr, + scalar& matchDistSqr +) +{ + if (a.size() != b.size()) + { + return -1; + } + + enum CirculatorBase::direction circulateDirection + = CirculatorBase::CLOCKWISE; + + if (!sameOrientation) + { + circulateDirection = CirculatorBase::ANTICLOCKWISE; + } + + label matchFp = -1; + + scalar closestMatchDistSqr = sqr(GREAT); + + const_circulator aCirc(a); + const_circulator bCirc(b); + + do + { + const scalar diffSqr = magSqr(aPts[aCirc()] - bPts[bCirc()]); + + if (diffSqr < absTolSqr) + { + // Found a matching point. Set the fulcrum of b to the iterator + const_circulator bCirc2 = bCirc; + ++aCirc; + + bCirc2.setFulcrumToIterator(); + + if (!sameOrientation) + { + --bCirc2; + } + else + { + ++bCirc2; + } + + matchDistSqr = diffSqr; + + do + { + const scalar diffSqr2 = magSqr(aPts[aCirc()] - bPts[bCirc2()]); + + if (diffSqr2 > absTolSqr) + { + // No match. + break; + } + + matchDistSqr += diffSqr2; + } + while + ( + aCirc.circulate(CirculatorBase::CLOCKWISE), + bCirc2.circulate(circulateDirection) + ); + + if (!aCirc.circulate()) + { + if (matchDistSqr < closestMatchDistSqr) + { + closestMatchDistSqr = matchDistSqr; + + if (!sameOrientation) + { + matchFp = a.size() - bCirc.nRotations(); + } + else + { + matchFp = bCirc.nRotations(); + } + + if (closestMatchDistSqr == 0) + { + break; + } + } + } + + // Reset aCirc + aCirc.setIteratorToFulcrum(); + } + + } while (bCirc.circulate(circulateDirection)); + + matchDistSqr = closestMatchDistSqr; + + return matchFp; +} + + // Return new ordering. Ordering is -faceMap: for every face index // the new face -rotation:for every new face the clockwise shift // of the original face. Return false if nothing changes (faceMap @@ -545,7 +692,11 @@ bool Foam::processorPolyPatch::order { // Note: we only get the faces that originate from internal faces. - if (!Pstream::parRun()) + if + ( + !Pstream::parRun() + || transform() == NOORDERING + ) { return false; } @@ -556,6 +707,8 @@ bool Foam::processorPolyPatch::order rotation.setSize(pp.size()); rotation = 0; + bool change = false; + if (owner()) { // Do nothing (i.e. identical mapping, zero rotation). @@ -565,176 +718,361 @@ bool Foam::processorPolyPatch::order faceMap[patchFaceI] = patchFaceI; } - return false; + if (transform() != COINCIDENTFULLMATCH) + { + const pointField& ppPoints = pp.points(); + + pointField anchors(getAnchorPoints(pp, ppPoints, transform())); + + // Calculate typical distance from face centre + scalarField tols + ( + matchTolerance()*calcFaceTol(pp, pp.points(), pp.faceCentres()) + ); + + forAll(faceMap, patchFaceI) + { + const point& wantedAnchor = anchors[patchFaceI]; + + rotation[patchFaceI] = getRotation + ( + ppPoints, + pp[patchFaceI], + wantedAnchor, + tols[patchFaceI] + ); + + if (rotation[patchFaceI] > 0) + { + change = true; + } + } + } + + return change; } else { - vectorField masterCtrs; - vectorField masterAnchors; - - // Receive data from neighbour + if (transform() == COINCIDENTFULLMATCH) { - UIPstream fromNeighbour(neighbProcNo(), pBufs); - fromNeighbour >> masterCtrs >> masterAnchors; - } + vectorField masterPts; + faceList masterFaces; - // Calculate typical distance from face centre - scalarField tols - ( - matchTolerance()*calcFaceTol(pp, pp.points(), pp.faceCentres()) - ); - - if (debug || masterCtrs.size() != pp.size()) - { { - OFstream nbrStr + UIPstream fromNeighbour(neighbProcNo(), pBufs); + fromNeighbour >> masterPts >> masterFaces; + } + + const pointField& localPts = pp.localPoints(); + const faceList& localFaces = pp.localFaces(); + + label nMatches = 0; + + forAll(pp, lFaceI) + { + const face& localFace = localFaces[lFaceI]; + label faceRotation = -1; + + const scalar absTolSqr = sqr(SMALL); + + scalar closestMatchDistSqr = sqr(GREAT); + scalar matchDistSqr = sqr(GREAT); + label closestFaceMatch = -1; + label closestFaceRotation = -1; + + forAll(masterFaces, mFaceI) + { + const face& masterFace = masterFaces[mFaceI]; + + faceRotation = matchFace + ( + localFace, + localPts, + masterFace, + masterPts, + false, + absTolSqr, + matchDistSqr + ); + + if + ( + faceRotation != -1 + && matchDistSqr < closestMatchDistSqr + ) + { + closestMatchDistSqr = matchDistSqr; + closestFaceMatch = mFaceI; + closestFaceRotation = faceRotation; + } + + if (closestMatchDistSqr == 0) + { + break; + } + } + + if (closestFaceRotation != -1 && closestMatchDistSqr == 0) + { + faceMap[lFaceI] = closestFaceMatch; + + rotation[lFaceI] = closestFaceRotation; + + if (lFaceI != closestFaceMatch || closestFaceRotation > 0) + { + change = true; + } + + nMatches++; + } + else + { + Pout<< "Number of matches = " << nMatches << " / " + << pp.size() << endl; + + pointField pts(localFace.size()); + forAll(localFace, pI) + { + const label localPtI = localFace[pI]; + pts[pI] = localPts[localPtI]; + } + + FatalErrorIn("Foam::processorPolyPatch::order(...) const") + << "No match for face " << localFace << nl << pts + << abort(FatalError); + } + } + + return change; + } + else + { + vectorField masterCtrs; + vectorField masterNormals; + vectorField masterAnchors; + vectorField masterFacePointAverages; + + // Receive data from neighbour + { + UIPstream fromNeighbour(neighbProcNo(), pBufs); + fromNeighbour >> masterCtrs >> masterNormals + >> masterAnchors >> masterFacePointAverages; + } + + // Calculate typical distance from face centre + scalarField tols + ( + matchTolerance()*calcFaceTol(pp, pp.points(), pp.faceCentres()) + ); + + if (debug || masterCtrs.size() != pp.size()) + { + { + OFstream nbrStr + ( + boundaryMesh().mesh().time().path() + /name() + "_nbrFaceCentres.obj" + ); + Pout<< "processorPolyPatch::order : " + << "Dumping neighbour faceCentres to " << nbrStr.name() + << endl; + forAll(masterCtrs, faceI) + { + writeOBJ(nbrStr, masterCtrs[faceI]); + } + } + + if (masterCtrs.size() != pp.size()) + { + FatalErrorIn + ( + "processorPolyPatch::order(const primitivePatch&" + ", labelList&, labelList&) const" + ) << "in patch:" << name() << " : " + << "Local size of patch is " << pp.size() << " (faces)." + << endl + << "Received from neighbour " << masterCtrs.size() + << " faceCentres!" + << abort(FatalError); + } + } + + // Geometric match of face centre vectors + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // 1. Try existing ordering and transformation + bool matchedAll = matchPoints + ( + pp.faceCentres(), + masterCtrs, + pp.faceNormals(), + masterNormals, + tols, + false, + faceMap + ); + + // Try using face point average for matching + if (!matchedAll) + { + const pointField& ppPoints = pp.points(); + + pointField facePointAverages(pp.size(), point::zero); + forAll(pp, fI) + { + const labelList& facePoints = pp[fI]; + + forAll(facePoints, pI) + { + facePointAverages[fI] += ppPoints[facePoints[pI]]; + } + + facePointAverages[fI] /= facePoints.size(); + } + + scalarField tols2 + ( + calcFaceTol(pp, pp.points(), facePointAverages) + ); + + labelList faceMap2(faceMap.size(), -1); + matchedAll = matchPoints + ( + facePointAverages, + masterFacePointAverages, + pp.faceNormals(), + masterNormals, + tols2, + true, + faceMap2 + ); + + forAll(faceMap, oldFaceI) + { + if (faceMap[oldFaceI] == -1) + { + faceMap[oldFaceI] = faceMap2[oldFaceI]; + } + } + + matchedAll = true; + + forAll(faceMap, oldFaceI) + { + if (faceMap[oldFaceI] == -1) + { + matchedAll = false; + } + } + } + + if (!matchedAll || debug) + { + // Dump faces + fileName str ( boundaryMesh().mesh().time().path() - /name() + "_nbrFaceCentres.obj" + /name() + "_faces.obj" ); - Pout<< "processorPolyPatch::order : " - << "Dumping neighbour faceCentres to " << nbrStr.name() - << endl; - forAll(masterCtrs, faceI) - { - writeOBJ(nbrStr, masterCtrs[faceI]); - } - } + Pout<< "processorPolyPatch::order :" + << " Writing faces to OBJ file " << str.name() << endl; + writeOBJ(str, pp, pp.points()); - if (masterCtrs.size() != pp.size()) - { - FatalErrorIn + OFstream ccStr ( - "processorPolyPatch::order(const primitivePatch&" - ", labelList&, labelList&) const" - ) << "in patch:" << name() << " : " - << "Local size of patch is " << pp.size() << " (faces)." - << endl - << "Received from neighbour " << masterCtrs.size() - << " faceCentres!" - << abort(FatalError); - } - } + boundaryMesh().mesh().time().path() + /name() + "_faceCentresConnections.obj" + ); - // Geometric match of face centre vectors - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Pout<< "processorPolyPatch::order :" + << " Dumping newly found match as lines between" + << " corresponding face centres to OBJ file " << ccStr.name() + << endl; - // 1. Try existing ordering and transformation - bool matchedAll = matchPoints - ( - pp.faceCentres(), - masterCtrs, - tols, - true, - faceMap - ); + label vertI = 0; - if (!matchedAll || debug) - { - // Dump faces - fileName str - ( - boundaryMesh().mesh().time().path() - /name() + "_faces.obj" - ); - Pout<< "processorPolyPatch::order :" - << " Writing faces to OBJ file " << str.name() << endl; - writeOBJ(str, pp, pp.points()); - - OFstream ccStr - ( - boundaryMesh().mesh().time().path() - /name() + "_faceCentresConnections.obj" - ); - - Pout<< "processorPolyPatch::order :" - << " Dumping newly found match as lines between" - << " corresponding face centres to OBJ file " << ccStr.name() - << endl; - - label vertI = 0; - - forAll(pp.faceCentres(), faceI) - { - label masterFaceI = faceMap[faceI]; - - if (masterFaceI != -1) + forAll(pp.faceCentres(), faceI) { - const point& c0 = masterCtrs[masterFaceI]; - const point& c1 = pp.faceCentres()[faceI]; - writeOBJ(ccStr, c0, c1, vertI); + label masterFaceI = faceMap[faceI]; + + if (masterFaceI != -1) + { + const point& c0 = masterCtrs[masterFaceI]; + const point& c1 = pp.faceCentres()[faceI]; + writeOBJ(ccStr, c0, c1, vertI); + } } } - } - if (!matchedAll) - { - SeriousErrorIn - ( - "processorPolyPatch::order(const primitivePatch&" - ", labelList&, labelList&) const" - ) << "in patch:" << name() << " : " - << "Cannot match vectors to faces on both sides of patch" - << endl - << " masterCtrs[0]:" << masterCtrs[0] << endl - << " ctrs[0]:" << pp.faceCentres()[0] << endl - << " Please check your topology changes or maybe you have" - << " multiple separated (from cyclics) processor patches" - << endl - << " Continuing with incorrect face ordering from now on!" - << endl; - - return false; - } - - // Set rotation. - forAll(faceMap, oldFaceI) - { - // The face f will be at newFaceI (after morphing) and we want its - // anchorPoint (= f[0]) to align with the anchorpoint for the - // corresponding face on the other side. - - label newFaceI = faceMap[oldFaceI]; - - const point& wantedAnchor = masterAnchors[newFaceI]; - - rotation[newFaceI] = getRotation - ( - pp.points(), - pp[oldFaceI], - wantedAnchor, - tols[oldFaceI] - ); - - if (rotation[newFaceI] == -1) + if (!matchedAll) { SeriousErrorIn ( "processorPolyPatch::order(const primitivePatch&" ", labelList&, labelList&) const" - ) << "in patch " << name() - << " : " - << "Cannot find point on face " << pp[oldFaceI] - << " with vertices " - << UIndirectList(pp.points(), pp[oldFaceI])() - << " that matches point " << wantedAnchor - << " when matching the halves of processor patch " << name() - << "Continuing with incorrect face ordering from now on!" + ) << "in patch:" << name() << " : " + << "Cannot match vectors to faces on both sides of patch" + << endl + << " masterCtrs[0]:" << masterCtrs[0] << endl + << " ctrs[0]:" << pp.faceCentres()[0] << endl + << " Please check your topology changes or maybe you have" + << " multiple separated (from cyclics) processor patches" + << endl + << " Continuing with incorrect face ordering from now on!" << endl; return false; } - } - forAll(faceMap, faceI) - { - if (faceMap[faceI] != faceI || rotation[faceI] != 0) + // Set rotation. + forAll(faceMap, oldFaceI) { - return true; - } - } + // The face f will be at newFaceI (after morphing) and we want its + // anchorPoint (= f[0]) to align with the anchorpoint for the + // corresponding face on the other side. - return false; + label newFaceI = faceMap[oldFaceI]; + + const point& wantedAnchor = masterAnchors[newFaceI]; + + rotation[newFaceI] = getRotation + ( + pp.points(), + pp[oldFaceI], + wantedAnchor, + tols[oldFaceI] + ); + + if (rotation[newFaceI] == -1) + { + SeriousErrorIn + ( + "processorPolyPatch::order(const primitivePatch&" + ", labelList&, labelList&) const" + ) << "in patch " << name() + << " : " + << "Cannot find point on face " << pp[oldFaceI] + << " with vertices " + << UIndirectList(pp.points(), pp[oldFaceI])() + << " that matches point " << wantedAnchor + << " when matching the halves of processor patch " << name() + << "Continuing with incorrect face ordering from now on!" + << endl; + + return false; + } + } + + forAll(faceMap, faceI) + { + if (faceMap[faceI] != faceI || rotation[faceI] != 0) + { + return true; + } + } + + return false; + } } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H index 2b39411ee5..f40f97c94f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.H @@ -134,7 +134,8 @@ public: const label index, const polyBoundaryMesh& bm, const int myProcNo, - const int neighbProcNo + const int neighbProcNo, + const transformType transform = UNKNOWN // transformation type ); //- Construct from dictionary @@ -309,6 +310,17 @@ public: // refer to *this (except for name() and type() etc.) virtual void initOrder(PstreamBuffers&, const primitivePatch&) const; + static label matchFace + ( + const face& localFace, + const pointField& localPts, + const face& masterFace, + const pointField& masterPts, + const bool sameOrientation, + const scalar absTolSqr, + scalar& matchDistSqr + ); + //- Return new ordering for primitivePatch. // Ordering is -faceMap: for every face // index of the new face -rotation:for every new face the clockwise diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index eaa818b9fe..8988a06eb2 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C @@ -51,10 +51,21 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch const polyBoundaryMesh& bm, const int myProcNo, const int neighbProcNo, - const word& referPatchName + const word& referPatchName, + const transformType transform ) : - processorPolyPatch(name, size, start, index, bm, myProcNo, neighbProcNo), + processorPolyPatch + ( + name, + size, + start, + index, + bm, + myProcNo, + neighbProcNo, + transform + ), tag_ ( Pstream::nProcs()*max(myProcNo, neighbProcNo) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H index 8d94466543..44aece8919 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H @@ -123,7 +123,8 @@ public: const polyBoundaryMesh& bm, const int myProcNo, const int neighbProcNo, - const word& referPatchName + const word& referPatchName, + const transformType transform = UNKNOWN ); //- Construct from dictionary diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index cd8f992236..49ba94fda2 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -120,21 +120,21 @@ void Foam::cyclicAMIPolyPatch::calcTransforms const vectorField& half1Areas ) { - if (transform_ != neighbPatch().transform_) + if (transform() != neighbPatch().transform()) { FatalErrorIn("cyclicAMIPolyPatch::calcTransforms()") << "Patch " << name() - << " has transform type " << transformTypeNames[transform_] + << " has transform type " << transformTypeNames[transform()] << ", neighbour patch " << nbrPatchName_ << " has transform type " - << neighbPatch().transformTypeNames[neighbPatch().transform_] + << neighbPatch().transformTypeNames[neighbPatch().transform()] << exit(FatalError); } // Calculate transformation tensors - switch (transform_) + switch (transform()) { case ROTATIONAL: { @@ -371,13 +371,13 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform ) : - coupledPolyPatch(name, size, start, index, bm, patchType), + coupledPolyPatch(name, size, start, index, bm, patchType, transform), nbrPatchName_(word::null), nbrPatchID_(-1), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero), @@ -403,7 +403,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch coupledPolyPatch(name, dict, index, bm, patchType), nbrPatchName_(dict.lookup("neighbourPatch")), nbrPatchID_(-1), - transform_(UNKNOWN), rotationAxis_(vector::zero), rotationCentre_(point::zero), separationVector_(vector::zero), @@ -429,46 +428,42 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch << exit(FatalIOError); } - if (dict.found("transform")) + switch (transform()) { - transform_ = transformTypeNames.read(dict.lookup("transform")); - switch (transform_) + case ROTATIONAL: { - case ROTATIONAL: - { - dict.lookup("rotationAxis") >> rotationAxis_; - dict.lookup("rotationCentre") >> rotationCentre_; + dict.lookup("rotationAxis") >> rotationAxis_; + dict.lookup("rotationCentre") >> rotationCentre_; - scalar magRot = mag(rotationAxis_); - if (magRot < SMALL) - { - FatalIOErrorIn - ( - "cyclicAMIPolyPatch::cyclicAMIPolyPatch" - "(" - "const word&, " - "const dictionary&, " - "const label, " - "const polyBoundaryMesh&" - ")", - dict - ) << "Illegal rotationAxis " << rotationAxis_ << endl - << "Please supply a non-zero vector." - << exit(FatalIOError); - } - rotationAxis_ /= magRot; + scalar magRot = mag(rotationAxis_); + if (magRot < SMALL) + { + FatalIOErrorIn + ( + "cyclicAMIPolyPatch::cyclicAMIPolyPatch" + "(" + "const word&, " + "const dictionary&, " + "const label, " + "const polyBoundaryMesh&" + ")", + dict + ) << "Illegal rotationAxis " << rotationAxis_ << endl + << "Please supply a non-zero vector." + << exit(FatalIOError); + } + rotationAxis_ /= magRot; - break; - } - case TRANSLATIONAL: - { - dict.lookup("separationVector") >> separationVector_; - break; - } - default: - { - // no additional info required - } + break; + } + case TRANSLATIONAL: + { + dict.lookup("separationVector") >> separationVector_; + break; + } + default: + { + // no additional info required } } @@ -486,7 +481,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch coupledPolyPatch(pp, bm), nbrPatchName_(pp.nbrPatchName_), nbrPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -513,7 +507,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch coupledPolyPatch(pp, bm, index, newSize, newStart), nbrPatchName_(nbrPatchName), nbrPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -554,7 +547,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch coupledPolyPatch(pp, bm, index, mapAddressing, newStart), nbrPatchName_(pp.nbrPatchName_), nbrPatchID_(-1), - transform_(pp.transform_), rotationAxis_(pp.rotationAxis_), rotationCentre_(pp.rotationCentre_), separationVector_(pp.separationVector_), @@ -672,7 +664,7 @@ void Foam::cyclicAMIPolyPatch::transformPosition(pointField& l) const { if (!parallel()) { - if (transform_ == ROTATIONAL) + if (transform() == ROTATIONAL) { l = Foam::transform(forwardT(), l - rotationCentre_) + rotationCentre_; @@ -718,7 +710,7 @@ void Foam::cyclicAMIPolyPatch::transformPosition : forwardT()[faceI] ); - if (transform_ == ROTATIONAL) + if (transform() == ROTATIONAL) { l = Foam::transform(T, l - rotationCentre_) + rotationCentre_; } @@ -796,12 +788,10 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const os.writeKeyword("neighbourPatch") << nbrPatchName_ << token::END_STATEMENT << nl; - switch (transform_) + switch (transform()) { case ROTATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("rotationAxis") << rotationAxis_ << token::END_STATEMENT << nl; os.writeKeyword("rotationCentre") << rotationCentre_ @@ -810,16 +800,12 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const } case TRANSLATIONAL: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; os.writeKeyword("separationVector") << separationVector_ << token::END_STATEMENT << nl; break; } case NOORDERING: { - os.writeKeyword("transform") << transformTypeNames[transform_] - << token::END_STATEMENT << nl; break; } default: diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index b1f420318e..b63747abfd 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -66,10 +66,6 @@ private: // Transformations - //- Type of transformation - rotational or translational - transformType transform_; - - // For rotation //- Axis of rotation for rotational cyclics @@ -161,7 +157,8 @@ public: const label start, const label index, const polyBoundaryMesh& bm, - const word& patchType + const word& patchType, + const transformType transform = UNKNOWN ); //- Construct from dictionary @@ -290,9 +287,6 @@ public: // Transformations - //- Type of transform - inline transformType transform() const; - //- Axis of rotation for rotational cyclic AMI inline const vector& rotationAxis() const; diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H index 3f3c2a4755..88d2ac02b6 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H @@ -39,13 +39,6 @@ Foam::cyclicAMIPolyPatch::neighbPatch() const } -inline Foam::coupledPolyPatch::transformType -Foam::cyclicAMIPolyPatch::transform() const -{ - return transform_; -} - - inline const Foam::vector& Foam::cyclicAMIPolyPatch::rotationAxis() const { return rotationAxis_;