diff --git a/src/AMIInterpolation/AMIInterpolation.C b/src/AMIInterpolation/AMIInterpolation.C index 799116e027..19bffee5bf 100644 --- a/src/AMIInterpolation/AMIInterpolation.C +++ b/src/AMIInterpolation/AMIInterpolation.C @@ -361,17 +361,12 @@ Foam::AMIInterpolation::calcProcMap procBb[Pstream::myProcNo()] = treeBoundBoxList(); } + // slightly increase size of bounding boxes to allow for cases where + // bounding boxes are perfectly alligned forAll(procBb[Pstream::myProcNo()], bbI) { treeBoundBox& bb = procBb[Pstream::myProcNo()][bbI]; - for (direction dir = 0; dir < vector::nComponents; dir++) - { - if (mag(bb.max()[dir] - bb.max()[dir]) < SMALL) - { - bb.min()[dir] -= 1E-6; - bb.max()[dir] += 1E-6; - } - } + bb.inflate(0.01); } Pstream::gatherList(procBb); @@ -1076,6 +1071,7 @@ Foam::AMIInterpolation::AMIInterpolation srcWeights_(), tgtAddress_(), tgtWeights_(), + tgtPatchSize_(tgtPatch.size()), startSeedI_(0), triMode_(triMode), projectPoints_(projectPoints), @@ -1338,7 +1334,8 @@ Foam::AMIInterpolation::interpolateToTarget ( new Field ( - tgtAddress_.size(), +// tgtAddress_.size(), + tgtPatchSize_, pTraits::zero ) ); diff --git a/src/AMIInterpolation/AMIInterpolation.H b/src/AMIInterpolation/AMIInterpolation.H index f39b883e8a..f3733b8b3d 100644 --- a/src/AMIInterpolation/AMIInterpolation.H +++ b/src/AMIInterpolation/AMIInterpolation.H @@ -121,6 +121,10 @@ class AMIInterpolation //- Weights of wource faces per target face scalarListList tgtWeights_; + //- Cache local size of target patch + // Note: size could be manipulated in parallel + label tgtPatchSize_; + //- Starting face seed index label startSeedI_; diff --git a/src/AMIInterpolation/patches/cyclicAMIFvPatch/cyclicAMIFvPatch.C b/src/AMIInterpolation/patches/cyclicAMIFvPatch/cyclicAMIFvPatch.C index 878d3b6ff8..fa88405077 100644 --- a/src/AMIInterpolation/patches/cyclicAMIFvPatch/cyclicAMIFvPatch.C +++ b/src/AMIInterpolation/patches/cyclicAMIFvPatch/cyclicAMIFvPatch.C @@ -132,7 +132,7 @@ Foam::tmp Foam::cyclicAMIFvPatch::internalFieldTransfer const labelUList& iF ) const { - return interpolate(neighbFvPatch().patchInternalField(iF)); + return neighbFvPatch().patchInternalField(iF); } diff --git a/src/AMIInterpolation/patches/cyclicAMIFvPatchField/cyclicAMIFvPatchField.C b/src/AMIInterpolation/patches/cyclicAMIFvPatchField/cyclicAMIFvPatchField.C index aba7f11a68..278b877d7f 100644 --- a/src/AMIInterpolation/patches/cyclicAMIFvPatchField/cyclicAMIFvPatchField.C +++ b/src/AMIInterpolation/patches/cyclicAMIFvPatchField/cyclicAMIFvPatchField.C @@ -145,29 +145,16 @@ Foam::cyclicAMIFvPatchField::patchNeighbourField() const const labelUList& nbrFaceCells = cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells(); - tmp > tpnf(new Field(nbrFaceCells.size())); - Field& pnf = tpnf(); + Field pnf(iField, nbrFaceCells); + tmp > tpnf(new Field(cyclicAMIPatch_.interpolate(pnf))); if (doTransform()) { - forAll(pnf, faceI) - { - pnf[faceI] = transform - ( - forwardT()[0], iField[nbrFaceCells[faceI]] - ); - } - } - else - { - forAll(pnf, faceI) - { - pnf[faceI] = iField[nbrFaceCells[faceI]]; - } + tpnf() = transform(forwardT(), tpnf()); } - return cyclicAMIPatch_.interpolate(pnf); + return tpnf; } @@ -202,12 +189,7 @@ void Foam::cyclicAMIFvPatchField::updateInterfaceMatrix const labelUList& nbrFaceCells = cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells(); - scalarField pnf(nbrFaceCells.size()); - - forAll(pnf, faceI) - { - pnf[faceI] = psiInternal[nbrFaceCells[faceI]]; - } + scalarField pnf(psiInternal, nbrFaceCells); pnf = cyclicAMIPatch_.interpolate(pnf); diff --git a/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index ba2bf63630..19a762b64d 100644 --- a/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -215,36 +215,39 @@ void Foam::cyclicAMIPolyPatch::calcTransforms } } - - // Calculate typical distance per face -// tols = calcFaceTol(matchTolerance(), pp1, pp1.points(), half1Ctrs); + if (debug) + { + Pout<< "patch: " << name() << nl + << " forwardT = " << forwardT() << nl + << " reverseT = " << reverseT() << nl + << " separation = " << separation() << nl + << " collocated = " << collocated() << nl << endl; + } } const Foam::searchableSurface& Foam::cyclicAMIPolyPatch::surf() { - if (projectionSurfaceType_ == "patch") - { - notImplemented("projectionSurfaceType_ == patch") - } - else - { - surfPtr_ = - searchableSurface::New + word surfType(surfDict_.lookup("type")); + word surfName(surfDict_.lookupOrDefault("name", name())); + + const polyMesh& mesh = boundaryMesh().mesh(); + + surfPtr_ = + searchableSurface::New + ( + surfType, + IOobject ( - projectionSurfaceType_, - IOobject - ( - projectionName_, - boundaryMesh().mesh().time().constant(), - "triSurface", - boundaryMesh().mesh(), - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - dict_ - ); - } + surfName, + boundaryMesh().mesh().time().constant(), + "triSurface", + boundaryMesh().mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + surfDict_ + ); return surfPtr_(); } @@ -284,6 +287,8 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI() meshTools::writeOBJ(osO, this->localFaces(), localPoints()); } + bool projectPoints(readBool(surfDict_.lookup("projectPoints"))); + // Construct/apply AMI interpolation to determine addressing and weights AMIPtr_.reset ( @@ -293,7 +298,7 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI() nbrPatch0, surf(), faceAreaIntersect::tmMesh, - projectPoints_ + projectPoints ) ); } @@ -377,7 +382,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch ) : coupledPolyPatch(name, size, start, index, bm), - dict_(dictionary::null), nbrPatchName_(word::null), nbrPatchID_(-1), transform_(UNKNOWN), @@ -386,9 +390,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch separationVector_(vector::zero), AMIPtr_(NULL), surfPtr_(NULL), - projectionSurfaceType_(word::null), - projectPoints_(false), - projectionName_(word::null) + surfDict_(dictionary::null) { // Neighbour patch might not be valid yet so no transformation // calculation possible @@ -404,7 +406,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch ) : coupledPolyPatch(name, dict, index, bm), - dict_(dict), nbrPatchName_(dict.lookup("neighbourPatch")), nbrPatchID_(-1), transform_(UNKNOWN), @@ -413,9 +414,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch separationVector_(vector::zero), AMIPtr_(NULL), surfPtr_(NULL), - projectionSurfaceType_(dict.lookup("projectionSurfaceType")), - projectPoints_(readBool(dict.lookup("projectPoints"))), - projectionName_(dict.lookupOrDefault("surfaceName", name)) + surfDict_(dict.subDict("surface")) { if (nbrPatchName_ == name) { @@ -489,7 +488,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch ) : coupledPolyPatch(pp, bm), - dict_(dictionary::null), nbrPatchName_(pp.nbrPatchName_), nbrPatchID_(-1), transform_(UNKNOWN), @@ -498,9 +496,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch separationVector_(vector::zero), AMIPtr_(NULL), surfPtr_(NULL), - projectionSurfaceType_(word::null), - projectPoints_(false), - projectionName_(word::null) + surfDict_(dictionary::null) { // Neighbour patch might not be valid yet so no transformation // calculation possible @@ -518,7 +514,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch ) : coupledPolyPatch(pp, bm, index, newSize, newStart), - dict_(dictionary::null), nbrPatchName_(nbrPatchName), nbrPatchID_(-1), transform_(UNKNOWN), @@ -527,9 +522,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch separationVector_(vector::zero), AMIPtr_(NULL), surfPtr_(NULL), - projectionSurfaceType_(word::null), - projectPoints_(false), - projectionName_(word::null) + surfDict_(dictionary::null) { if (nbrPatchName_ == name()) { @@ -561,7 +554,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch ) : coupledPolyPatch(pp, bm, index, mapAddressing, newStart), - dict_(pp.dict_), nbrPatchName_(pp.nbrPatchName_), nbrPatchID_(-1), transform_(pp.transform_), @@ -570,9 +562,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch separationVector_(pp.separationVector_), AMIPtr_(NULL), surfPtr_(NULL), - projectionSurfaceType_(pp.projectionSurfaceType_), - projectPoints_(pp.projectPoints_), - projectionName_(pp.projectionName_) + surfDict_(pp.surfDict_) {} @@ -759,12 +749,6 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const coupledPolyPatch::write(os); os.writeKeyword("neighbourPatch") << nbrPatchName_ << token::END_STATEMENT << nl; - os.writeKeyword("projectPoints") << projectPoints_ - << token::END_STATEMENT << nl; - os.writeKeyword("projectionSurfaceType") << projectionSurfaceType_ - << token::END_STATEMENT << nl; - os.writeKeyword("surfaceName") << projectionName_ - << token::END_STATEMENT << nl; switch (transform_) { case ROTATIONAL: @@ -796,6 +780,9 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const // no additional info to write } } + + os.writeKeyword(surfDict_.dictName()); + os << surfDict_; } diff --git a/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index 49a8a34d10..e733d3e727 100644 --- a/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/AMIInterpolation/patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -57,9 +57,6 @@ private: // Private data - //- Dictionary used during construction - const dictionary dict_; - //- Name of other half const word nbrPatchName_; @@ -94,14 +91,8 @@ private: //- Projection surface autoPtr surfPtr_; - //- Projection surface type - word projectionSurfaceType_; - - //- Flag to activate projection - bool projectPoints_; - - //- Name of projection object (if read) - const word projectionName_; + //- Dictionary used during projection surface construction + const dictionary surfDict_; // Private Member Functions