diff --git a/etc/codeTemplates/dynamicCode/codeStreamTemplate.C b/etc/codeTemplates/dynamicCode/codeStreamTemplate.C index 3288b7cefb..5d69d99632 100644 --- a/etc/codeTemplates/dynamicCode/codeStreamTemplate.C +++ b/etc/codeTemplates/dynamicCode/codeStreamTemplate.C @@ -29,6 +29,7 @@ Description #include "dictionary.H" #include "Ostream.H" #include "Pstream.H" +#include "unitConversion.H" //{{{ begin codeInclude ${codeInclude} diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C index a8b6a6da67..c7f442f03a 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C @@ -28,6 +28,7 @@ License #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" +#include "unitConversion.H" //{{{ begin codeInclude ${codeInclude} //}}} end codeInclude diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index 61cba180c3..a747b528b6 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -26,6 +26,7 @@ License #include "functionObjectTemplate.H" #include "Time.H" #include "fvCFD.H" +#include "unitConversion.H" //{{{ begin codeInclude ${codeInclude} diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 6e169d64bc..da569b2e21 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -577,9 +577,6 @@ $(interpolations)/interpolationTable/tableReaders/tableReaders.C $(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C $(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C -algorithms/MeshWave/MeshWaveName.C -algorithms/MeshWave/FaceCellWaveName.C - algorithms/indexedOctree/indexedOctreeName.C algorithms/indexedOctree/treeDataCell.C diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H index 368782d0a3..91db5fc873 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H @@ -96,18 +96,6 @@ public: //- Destructor virtual ~coupledFacePointPatch(); - - - // Member Functions - - // Access - - //- Return true because this patch is coupled - virtual bool coupled() const - { - return true; - } - }; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index ceb6220585..0fa859bddb 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -285,7 +285,8 @@ public: //- Return boundaryMesh reference const polyBoundaryMesh& boundaryMesh() const; - //- Return true if this patch field is coupled + //- Return true if this patch is geometrically coupled (i.e. faces and + // points correspondence) virtual bool coupled() const { return false; @@ -299,7 +300,7 @@ public: //- Slice list to patch template - const typename List::subList patchSlice(const List& l) const + const typename List::subList patchSlice(const UList& l) const { return typename List::subList(l, this->size(), start_); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index 8e358063fa..31729346e2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -106,7 +106,7 @@ Foam::cyclicAMIFvPatchField::cyclicAMIFvPatchField << exit(FatalIOError); } - if (cyclicAMIPatch_.coupled()) + if (this->coupled()) { this->evaluate(Pstream::blocking); } @@ -140,6 +140,27 @@ Foam::cyclicAMIFvPatchField::cyclicAMIFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +bool Foam::cyclicAMIFvPatchField::coupled() const +{ + if + ( + Pstream::parRun() + || ( + this->cyclicAMIPatch_.size() + && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size() + ) + ) + { + return true; + } + else + { + return false; + } +} + + template Foam::tmp > Foam::cyclicAMIFvPatchField::patchNeighbourField() const diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H index 9a4e5f6b4c..2e05111cb6 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H @@ -147,8 +147,12 @@ public: // Evaluation functions + //- Return true if coupled. Note that the underlying patch + // is not coupled() - the points don't align. + virtual bool coupled() const; + //- Return neighbour coupled internal cell data - tmp > patchNeighbourField() const; + virtual tmp > patchNeighbourField() const; //- Return reference to neighbour patchField const cyclicAMIFvPatchField& neighbourPatchField() const; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index 7e3152e131..0130909d04 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -154,7 +154,7 @@ public: } //- Return neighbour field given internal field - tmp > patchNeighbourField() const; + virtual tmp > patchNeighbourField() const; // Evaluation functions diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C index a347bc4347..0ffe6b9c95 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C @@ -123,4 +123,27 @@ Foam::cyclicAMIFvsPatchField::cyclicAMIFvsPatchField {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::cyclicAMIFvsPatchField::coupled() const +{ + if + ( + Pstream::parRun() + || ( + this->cyclicAMIPatch_.size() + && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size() + ) + ) + { + return true; + } + else + { + return false; + } +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H index fe84983134..d55ff5cd5d 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H @@ -123,6 +123,14 @@ public: new cyclicAMIFvsPatchField(*this, iF) ); } + + // Member functions + + // Access + + //- Return true if running parallel + virtual bool coupled() const; + }; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C index 6002a07e1c..27f5b72fcf 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C @@ -132,7 +132,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const // Build the d-vectors vectorField pd = p.delta(); - if (p.coupled()) + if (pw.coupled()) { forAll(pd, patchFacei) { @@ -185,7 +185,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const // Build the d-vectors vectorField pd = p.delta(); - if (p.coupled()) + if (pw.coupled()) { forAll(pd, patchFacei) { @@ -256,7 +256,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const label patchFacei = facei - mesh.boundaryMesh()[patchi].start(); - if (mesh.boundary()[patchi].coupled()) + if (w.boundaryField()[patchi].coupled()) { scalar wf = max ( diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C index 85c6f3f61f..021241fa27 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C @@ -103,7 +103,7 @@ Foam::extendedCellToFaceStencil::extendedCellToFaceStencil(const polyMesh& mesh) forAll(patches, patchI) { - if (isA(patches[patchI])) + if (patches[patchI].coupled()) { const coupledPolyPatch& cpp = refCast(patches[patchI]); diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C index 0943d86685..4f364dc288 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C @@ -38,7 +38,7 @@ Foam::extendedFaceToCellStencil::extendedFaceToCellStencil(const polyMesh& mesh) forAll(patches, patchI) { - if (isA(patches[patchI])) + if (patches[patchI].coupled()) { const coupledPolyPatch& cpp = refCast(patches[patchI]); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H index 312a453c44..b69b2a05dc 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H @@ -157,7 +157,7 @@ public: forAll(mesh.boundary(), patchi) { - if (mesh.boundary()[patchi].coupled()) + if (clippedLinearWeights.boundaryField()[patchi].coupled()) { clippedLinearWeights.boundaryField()[patchi] = max diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H index 5dd8ee104a..3f3cae05fe 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H @@ -129,7 +129,7 @@ public: forAll(mesh.boundary(), patchI) { - if (mesh.boundary()[patchI].coupled()) + if (reverseLinearWeights.boundaryField()[patchI].coupled()) { reverseLinearWeights.boundaryField()[patchI] = 1.0 - cdWeights.boundaryField()[patchI]; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C index 0f2a765ea8..36fb2aa035 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C @@ -316,7 +316,7 @@ Foam::FacePostProcessing::FacePostProcessing if ( - !pp.coupled() + !magSf.boundaryField()[patchI].coupled() || refCast(pp).owner() ) { diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index a0965ff941..cae738707d 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -30,6 +30,37 @@ License #include "mergePoints.H" #include "mapDistribute.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + //- Combine operator for interpolateToSource/Target + template + class combineBinaryOp + { + const BinaryOp& bop_; + + public: + + combineBinaryOp(const BinaryOp& bop) + : + bop_(bop) + {} + + void operator() + ( + Type& x, + const label faceI, + const Type& y, + const scalar weight + ) const + { + x = bop_(x, weight*y); + } + }; +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -1773,94 +1804,12 @@ void Foam::AMIInterpolation::update template -template -Foam::tmp > -Foam::AMIInterpolation::interpolateToSource +template +void Foam::AMIInterpolation::interpolateToTarget ( - const Field& fld, - const BinaryOp& bop -) const -{ - if (fld.size() != tgtAddress_.size()) - { - FatalErrorIn - ( - "AMIInterpolation::interpolateToSource(const Field) const" - ) << "Supplied field size is not equal to target patch size" << nl - << " source patch = " << srcAddress_.size() << nl - << " target patch = " << tgtAddress_.size() << nl - << " supplied field = " << fld.size() - << abort(FatalError); - } - - tmp > tresult - ( - new Field - ( - srcAddress_.size(), - pTraits::zero - ) - ); - - Field& result = tresult(); - - if (singlePatchProc_ == -1) - { - const mapDistribute& map = tgtMapPtr_(); - - Field work(fld); - map.distribute(work); - - forAll(result, faceI) - { - const labelList& faces = srcAddress_[faceI]; - const scalarList& weights = srcWeights_[faceI]; - - forAll(faces, i) - { - result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); - } - } - } - else - { - forAll(result, faceI) - { - const labelList& faces = srcAddress_[faceI]; - const scalarList& weights = srcWeights_[faceI]; - - forAll(faces, i) - { - result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); - } - } - } - - return tresult; -} - - -template -template -Foam::tmp > -Foam::AMIInterpolation::interpolateToSource -( - const tmp >& tFld, - const BinaryOp& bop -) const -{ - return interpolateToSource(tFld(), bop); -} - - - -template -template -Foam::tmp > -Foam::AMIInterpolation::interpolateToTarget -( - const Field& fld, - const BinaryOp& bop + const UList& fld, + const CombineOp& bop, + List& result ) const { if (fld.size() != srcAddress_.size()) @@ -1875,22 +1824,13 @@ Foam::AMIInterpolation::interpolateToTarget << abort(FatalError); } - tmp > tresult - ( - new Field - ( - tgtAddress_.size(), - pTraits::zero - ) - ); - - Field& result = tresult(); + result.setSize(tgtAddress_.size()); if (singlePatchProc_ == -1) { const mapDistribute& map = srcMapPtr_(); - Field work(fld); + List work(fld); map.distribute(work); forAll(result, faceI) @@ -1900,7 +1840,7 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); + bop(result[faceI], faceI, work[faces[i]], weights[i]); } } } @@ -1913,10 +1853,126 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); + bop(result[faceI], faceI, fld[faces[i]], weights[i]); } } } +} + + +template +template +void Foam::AMIInterpolation::interpolateToSource +( + const UList& fld, + const CombineOp& bop, + List& result +) const +{ + if (fld.size() != tgtAddress_.size()) + { + FatalErrorIn + ( + "AMIInterpolation::interpolateToSource(const Field) const" + ) << "Supplied field size is not equal to target patch size" << nl + << " source patch = " << srcAddress_.size() << nl + << " target patch = " << tgtAddress_.size() << nl + << " supplied field = " << fld.size() + << abort(FatalError); + } + + result.setSize(srcAddress_.size()); + + if (singlePatchProc_ == -1) + { + const mapDistribute& map = tgtMapPtr_(); + + List work(fld); + map.distribute(work); + + forAll(result, faceI) + { + const labelList& faces = srcAddress_[faceI]; + const scalarList& weights = srcWeights_[faceI]; + + forAll(faces, i) + { + bop(result[faceI], faceI, work[faces[i]], weights[i]); + } + } + } + else + { + forAll(result, faceI) + { + const labelList& faces = srcAddress_[faceI]; + const scalarList& weights = srcWeights_[faceI]; + + forAll(faces, i) + { + bop(result[faceI], faceI, fld[faces[i]], weights[i]); + } + } + } +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const Field& fld, + const BinaryOp& bop +) const +{ + tmp > tresult + ( + new Field + ( + srcAddress_.size(), + pTraits::zero + ) + ); + + interpolateToSource(fld, combineBinaryOp(bop), tresult()); + + return tresult; +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const tmp >& tFld, + const BinaryOp& bop +) const +{ + return interpolateToSource(tFld, bop); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToTarget +( + const Field& fld, + const BinaryOp& bop +) const +{ + tmp > tresult + ( + new Field + ( + tgtAddress_.size(), + pTraits::zero + ) + ); + + interpolateToTarget(fld, combineBinaryOp(bop), tresult()); return tresult; } @@ -1931,7 +1987,7 @@ Foam::AMIInterpolation::interpolateToTarget const BinaryOp& bop ) const { - return interpolateToTarget(tFld(), bop); + return interpolateToTarget(tFld, bop); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index e43180db6f..c9aa12da90 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -404,7 +404,30 @@ public: // Evaluation - //- Interpolate from target to source with supplied op + // Low-level + + //- Interpolate from target to source with supplied op + // to combine existing value with remote value and weight + template + void interpolateToSource + ( + const UList& fld, + const CombineOp& bop, + List& result + ) const; + + //- Interpolate from source to target with supplied op + // to combine existing value with remote value and weight + template + void interpolateToTarget + ( + const UList& fld, + const CombineOp& bop, + List& result + ) const; + + + //- Interpolate from target to source with supplied binary op template tmp > interpolateToSource ( @@ -412,7 +435,8 @@ public: const BinaryOp& bop ) const; - //- Interpolate from target tmp field to source with supplied op + //- Interpolate from target tmp field to source with supplied + // binary op template tmp > interpolateToSource ( @@ -464,7 +488,6 @@ public: const tmp >& tFld ) const; - // Checks //- Write face connectivity as OBJ file diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H index 3ade3aeaef..78c69e0ad0 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H @@ -107,6 +107,17 @@ public: //- Destructor virtual ~cyclicAMIPointPatch(); + + + // Member Functions + + //- Is patch 'coupled'. Note that on AMI the geometry is not + // coupled but the fields are! + virtual bool coupled() const + { + return false; + } + }; diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index b6769849f7..d281afc21f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -548,23 +548,6 @@ Foam::cyclicAMIPolyPatch::~cyclicAMIPolyPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::cyclicAMIPolyPatch::coupled() const -{ - if - ( - Pstream::parRun() - || (size() && neighbPatch().size()) - ) - { - return true; - } - else - { - return false; - } -} - - Foam::label Foam::cyclicAMIPolyPatch::neighbPatchID() const { if (nbrPatchID_ == -1) diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index ced7968171..dcd26799c0 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -254,10 +254,12 @@ public: // Access - //- Return true only if is coupled. Note that for non-parallel - // operation of a decomposed case this can return the wrong - // result - virtual bool coupled() const; + //- Is patch 'coupled'. Note that on AMI the geometry is not + // coupled but the fields are! + virtual bool coupled() const + { + return false; + } //- Neighbour patch name inline const word& neighbPatchName() const; @@ -316,6 +318,15 @@ public: const tmp >& tFld ) const; + //- Low-level interpolate List + template + void interpolate + ( + const UList& fld, + const BinaryOp& bop, + List& result + ) const; + //- Calculate the patch geometry virtual void calcGeometry diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C index ccafd75fd4..4bf59fba41 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C @@ -59,4 +59,23 @@ Foam::tmp > Foam::cyclicAMIPolyPatch::interpolate } +template +void Foam::cyclicAMIPolyPatch::interpolate +( + const UList& fld, + const BinaryOp& bop, + List& result +) const +{ + if (owner()) + { + AMIPtr_->interpolateToSource(fld, bop, result); + } + else + { + neighbPatch().AMIPtr_->interpolateToTarget(fld, bop, result); + } +} + + // ************************************************************************* // diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 4ba28fce08..e1c9854902 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -30,14 +30,21 @@ meshSearch/meshSearch.C meshTools/meshTools.C -pWave = PointEdgeWave +algorithms = algorithms + +pWave = $(algorithms)/PointEdgeWave $(pWave)/PointEdgeWaveName.C $(pWave)/pointEdgePoint.C -patchWave = PatchEdgeFaceWave +patchWave = $(algorithms)/PatchEdgeFaceWave $(patchWave)/PatchEdgeFaceWaveName.C $(patchWave)/patchEdgeFaceInfo.C +meshWave = $(algorithms)/MeshWave +$(meshWave)/MeshWaveName.C +$(meshWave)/FaceCellWaveName.C + + regionSplit/regionSplit.C indexedOctree/treeDataEdge.C diff --git a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C b/src/meshTools/algorithms/MeshWave/FaceCellWave.C similarity index 77% rename from src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C rename to src/meshTools/algorithms/MeshWave/FaceCellWave.C index 5b11137329..c0e1e72ee8 100644 --- a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.C @@ -27,11 +27,14 @@ License #include "polyMesh.H" #include "processorPolyPatch.H" #include "cyclicPolyPatch.H" +#include "cyclicAMIPolyPatch.H" #include "OPstream.H" #include "IPstream.H" #include "PstreamReduceOps.H" #include "debug.H" #include "typeInfo.H" +#include "SubField.H" +#include "globalMeshData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,6 +47,53 @@ Foam::scalar Foam::FaceCellWave::propagationTol_ = 0.01; template Foam::label Foam::FaceCellWave::dummyTrackData_ = 12345; +namespace Foam +{ + //- Combine operator for AMIInterpolation + template + class combine + { + FaceCellWave& solver_; + + const polyPatch& patch_; + + public: + + combine + ( + FaceCellWave& solver, + const polyPatch& patch + ) + : + solver_(solver), + patch_(patch) + {} + + + void operator() + ( + Type& x, + const label faceI, + const Type& y, + const scalar weight + ) const + { + if (y.valid(solver_.data())) + { + x.updateFace + ( + solver_.mesh(), + patch_.start() + faceI, + y, + solver_.propagationTol(), + solver_.data() + ); + } + } + }; +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -244,11 +294,12 @@ void Foam::FaceCellWave::checkCyclic // Check if has cyclic patches template -bool Foam::FaceCellWave::hasCyclicPatch() const +template +bool Foam::FaceCellWave::hasPatch() const { forAll(mesh_.boundaryMesh(), patchI) { - if (isA(mesh_.boundaryMesh()[patchI])) + if (isA(mesh_.boundaryMesh()[patchI])) { return true; } @@ -446,119 +497,117 @@ void Foam::FaceCellWave::offset template void Foam::FaceCellWave::handleProcPatches() { + const globalMeshData& pData = mesh_.globalData(); + + // Which patches are processor patches + const labelList& procPatches = pData.processorPatches(); + // Send all PstreamBuffers pBufs(Pstream::nonBlocking); - forAll(mesh_.boundaryMesh(), patchI) + forAll(procPatches, i) { - const polyPatch& patch = mesh_.boundaryMesh()[patchI]; + label patchI = procPatches[i]; - if (isA(patch)) + const processorPolyPatch& procPatch = + refCast(mesh_.boundaryMesh()[patchI]); + + // Allocate buffers + label nSendFaces; + labelList sendFaces(procPatch.size()); + List sendFacesInfo(procPatch.size()); + + // Determine which faces changed on current patch + nSendFaces = getChangedPatchFaces + ( + procPatch, + 0, + procPatch.size(), + sendFaces, + sendFacesInfo + ); + + // Adapt wallInfo for leaving domain + leaveDomain + ( + procPatch, + nSendFaces, + sendFaces, + sendFacesInfo + ); + + if (debug) { - // Allocate buffers - label nSendFaces; - labelList sendFaces(patch.size()); - List sendFacesInfo(patch.size()); - - // Determine which faces changed on current patch - nSendFaces = getChangedPatchFaces - ( - patch, - 0, - patch.size(), - sendFaces, - sendFacesInfo - ); - - // Adapt wallInfo for leaving domain - leaveDomain - ( - patch, - nSendFaces, - sendFaces, - sendFacesInfo - ); - - const processorPolyPatch& procPatch = - refCast(patch); - - if (debug) - { - Pout<< " Processor patch " << patchI << ' ' << patch.name() - << " communicating with " << procPatch.neighbProcNo() - << " Sending:" << nSendFaces - << endl; - } - - UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs); - //writeFaces(nSendFaces, sendFaces, sendFacesInfo, toNeighbour); - toNeighbour - << SubList