diff --git a/applications/utilities/mesh/conversion/star3ToFoam/coupledFacePair.H b/applications/utilities/mesh/conversion/star3ToFoam/coupledFacePair.H index 28fbc2f448..52597ff7db 100644 --- a/applications/utilities/mesh/conversion/star3ToFoam/coupledFacePair.H +++ b/applications/utilities/mesh/conversion/star3ToFoam/coupledFacePair.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.H index 6b73735cac..7102d84204 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoi2DMesh/cv2DControls/cv2DControls.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/pointFeatureEdgesTypes.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/pointFeatureEdgesTypes.H index f0acbe6c06..a0b8e2a1fa 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/pointFeatureEdgesTypes.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/pointFeatureEdgesTypes.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.H index 48dde412fd..3c5e9b2737 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index f15e2b2b6a..28e8ee9c24 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -997,7 +997,7 @@ bool Foam::polyMesh::upToDatePoints(const regIOobject& io) const void Foam::polyMesh::setUpToDatePoints(regIOobject& io) const { - io.eventNo() = points_.eventNo(); + io.eventNo() = points_.eventNo()+1; } diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.H b/src/dynamicMesh/boundaryPatch/boundaryPatch.H index 1366904cc0..32f8fdacae 100644 --- a/src/dynamicMesh/boundaryPatch/boundaryPatch.H +++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index bb8608de1d..f516b2ab8a 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -137,22 +137,15 @@ Foam::tmp> Foam::cyclicACMIFvPatchField::patchNeighbourField() const { const Field& iField = this->primitiveField(); - const labelUList& nbrFaceCellsCoupled = - cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); - const labelUList& faceCellsNonOverlap = - cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatch().faceCells(); - - Field pnfCoupled(iField, nbrFaceCellsCoupled); - Field pfNonOverlap(iField, faceCellsNonOverlap); - + const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); tmp> tpnf ( - new Field + cyclicACMIPatch_.interpolate ( - cyclicACMIPatch_.interpolate + Field ( - pnfCoupled, - pfNonOverlap + iField, + cpp.neighbPatch().faceCells() ) ) ); @@ -207,10 +200,12 @@ void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix const Pstream::commsTypes ) const { + const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); + // note: only applying coupled contribution const labelUList& nbrFaceCellsCoupled = - cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); + cpp.neighbPatch().faceCells(); scalarField pnf(psiInternal, nbrFaceCellsCoupled); @@ -237,10 +232,11 @@ void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix const Pstream::commsTypes ) const { + const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); + // note: only applying coupled contribution - const labelUList& nbrFaceCellsCoupled = - cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); + const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells(); Field pnf(psiInternal, nbrFaceCellsCoupled); @@ -258,149 +254,6 @@ void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix } -template -Foam::tmp> Foam::cyclicACMIFvPatchField::snGrad -( - const scalarField& deltaCoeffs -) const -{ - // note: only applying coupled contribution - return coupledFvPatchField::snGrad(deltaCoeffs); -} - - -template -void Foam::cyclicACMIFvPatchField::updateCoeffs() -{ - // update non-overlap patch - some will implement updateCoeffs, and - // others will implement evaluate - - // scale neighbour field by (1 - mask) - - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); - const fvPatchField& npf = nonOverlapPatchField(); - const_cast&>(npf).updateCoeffs(1.0 - mask); -} - - -template -void Foam::cyclicACMIFvPatchField::initEvaluate -( - const Pstream::commsTypes comms -) -{ - // update non-overlap patch (if not already updated by updateCoeffs) - - // scale neighbour field by (1 - mask) - - fvPatchField& npf = - const_cast&>(nonOverlapPatchField()); - - if (!npf.updated()) - { - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); - - npf.evaluate(comms); - - npf *= 1.0 - mask; - } -} - - -template -void Foam::cyclicACMIFvPatchField::evaluate -( - const Pstream::commsTypes comms -) -{ - // blend contributions from the coupled and non-overlap patches - - // neighbour patch field is updated via updateCoeffs or initEvaluate - // and is already scaled by (1 - mask) - const fvPatchField& npf = nonOverlapPatchField(); - - coupledFvPatchField::evaluate(comms); - const Field& cpf = *this; - - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); - Field::operator=(mask*cpf + npf); - - fvPatchField::evaluate(); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::valueInternalCoeffs -( - const tmp& w -) const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::valueInternalCoeffs(w); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::valueBoundaryCoeffs -( - const tmp& w -) const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::valueBoundaryCoeffs(w); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::gradientInternalCoeffs -( - const scalarField& deltaCoeffs -) const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::gradientInternalCoeffs(deltaCoeffs); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::gradientInternalCoeffs() const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::gradientInternalCoeffs(); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs -( - const scalarField& deltaCoeffs -) const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::gradientBoundaryCoeffs(deltaCoeffs); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs() const -{ - // note: do not blend based on mask field - // - when applied this is scaled by the areas which are already scaled - return coupledFvPatchField::gradientBoundaryCoeffs(); -} - - template void Foam::cyclicACMIFvPatchField::manipulateMatrix ( diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index b17c933a4c..33a6d6935f 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -218,63 +218,6 @@ public: const Pstream::commsTypes commsType ) const; - //- Return patch-normal gradient - virtual tmp> snGrad - ( - const scalarField& deltaCoeffs - ) const; - - //- Update the coefficients associated with the patch field - void updateCoeffs(); - - //- Initialise the evaluation of the patch field - virtual void initEvaluate - ( - const Pstream::commsTypes commsType - ); - - //- Evaluate the patch field - virtual void evaluate - ( - const Pstream::commsTypes commsType - ); - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp> valueInternalCoeffs - ( - const tmp& - ) const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp> valueBoundaryCoeffs - ( - const tmp& - ) const; - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp> gradientInternalCoeffs - ( - const scalarField& deltaCoeffs - ) const; - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp> gradientInternalCoeffs() const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp> gradientBoundaryCoeffs - ( - const scalarField& deltaCoeffs - ) const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp> gradientBoundaryCoeffs() const; - //- Manipulate matrix virtual void manipulateMatrix(fvMatrix& matrix); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C index 8812cd7b3a..58c23a5580 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C @@ -43,7 +43,12 @@ void Foam::cyclicACMIFvPatch::updateAreas() const { if (cyclicACMIPolyPatch_.updated()) { - // Set Sf and magSf for both sides' coupled and non-overlapping patches + if (debug) + { + Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for " + << name() << " and " << this->nonOverlapPatch().name() + << endl; + } // owner couple const_cast(Sf()) = patch().faceAreas(); @@ -81,25 +86,37 @@ void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const if (coupled()) { const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); - const fvPatch& nbrPatchNonOverlap = nonOverlapPatch(); - const scalarField deltas(nf() & coupledFvPatch::delta()); - const scalarField nbrDeltas + // These deltas are of the cyclic part alone - they are + // not affected by the amount of overlap with the nonOverlapPatch + scalarField nbrDeltas ( interpolate ( - nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(), - nbrPatchNonOverlap.nf() & nbrPatchNonOverlap.delta() + nbrPatch.nf() & nbrPatch.coupledFvPatch::delta() ) ); + scalar tol = cyclicACMIPolyPatch::tolerance(); + + forAll(deltas, facei) { scalar di = deltas[facei]; scalar dni = nbrDeltas[facei]; - w[facei] = dni/(di + dni); + if (dni < tol) + { + // Avoid zero weights on disconnected faces. This value + // will be weighted with the (zero) face area so will not + // influence calculations. + w[facei] = 1.0; + } + else + { + w[facei] = dni/(di + dni); + } } } else @@ -122,30 +139,12 @@ Foam::tmp Foam::cyclicACMIFvPatch::delta() const { if (coupled()) { - const cyclicACMIFvPatch& nbrPatchCoupled = neighbFvPatch(); - const fvPatch& nbrPatchNonOverlap = nonOverlapPatch(); + const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); const vectorField patchD(coupledFvPatch::delta()); - vectorField nbrPatchD - ( - interpolate - ( - nbrPatchCoupled.coupledFvPatch::delta(), - nbrPatchNonOverlap.delta() - ) - ); + vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta())); - const vectorField nbrPatchD0 - ( - interpolate - ( - vectorField(nbrPatchCoupled.size(), Zero), - nbrPatchNonOverlap.delta()() - ) - ); - - nbrPatchD -= nbrPatchD0; tmp tpdv(new vectorField(patchD.size())); vectorField& pdv = tpdv.ref(); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H index f4bfb00ad1..048ee61410 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H @@ -174,10 +174,11 @@ public: //- Return delta (P to N) vectors across coupled patch virtual tmp delta() const; + //- Interpolate (make sure to have uptodate areas) template tmp> interpolate ( - const Field& fldCoupled + const Field& fld ) const { updateAreas(); @@ -185,57 +186,18 @@ public: return cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate ( - fldCoupled + fld ); } + //- Interpolate (make sure to have uptodate areas) template tmp> interpolate ( - const tmp>& tfldCoupled + const tmp>& tfld ) const { - updateAreas(); - - return - cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate - ( - tfldCoupled - ); - } - - template - tmp> interpolate - ( - const Field& fldCoupled, - const Field& fldNonOverlap - ) const - { - updateAreas(); - - return - cyclicACMIPolyPatch_.interpolate - ( - fldCoupled, - fldNonOverlap - ); - } - - template - tmp> interpolate - ( - const tmp>& tFldCoupled, - const tmp>& tFldNonOverlap - ) const - { - updateAreas(); - - return - cyclicACMIPolyPatch_.interpolate - ( - tFldCoupled, - tFldNonOverlap - ); + return interpolate(tfld()); } diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.H b/src/mesh/blockMesh/curvedEdges/curvedEdge.H index 298c200b3a..c46457ba3e 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.H +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index 8de6e4f310..a2a1449704 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -378,10 +378,17 @@ public: //- Return const access to source patch weights inline const scalarListList& srcWeights() const; + //- Return access to source patch weights + inline scalarListList& srcWeights(); + //- Return const access to normalisation factor of source // patch weights (i.e. the sum before normalisation) inline const scalarField& srcWeightsSum() const; + //- Return access to normalisation factor of source + // patch weights (i.e. the sum before normalisation) + inline scalarField& srcWeightsSum(); + //- Source map pointer - valid only if singlePatchProc = -1 // This gets source data into a form to be consumed by // tgtAddress, tgtWeights @@ -399,10 +406,17 @@ public: //- Return const access to target patch weights inline const scalarListList& tgtWeights() const; + //- Return access to target patch weights + inline scalarListList& tgtWeights(); + //- Return const access to normalisation factor of target // patch weights (i.e. the sum before normalisation) inline const scalarField& tgtWeightsSum() const; + //- Return access to normalisation factor of target + // patch weights (i.e. the sum before normalisation) + inline scalarField& tgtWeightsSum(); + //- Target map pointer - valid only if singlePatchProc=-1. // This gets target data into a form to be consumed by // srcAddress, srcWeights diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H index 9c59cb6865..5e74e7b4c6 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H @@ -72,6 +72,14 @@ Foam::AMIInterpolation::srcWeights() const } +template +inline Foam::scalarListList& +Foam::AMIInterpolation::srcWeights() +{ + return srcWeights_; +} + + template inline const Foam::scalarField& Foam::AMIInterpolation::srcWeightsSum() const @@ -80,6 +88,14 @@ Foam::AMIInterpolation::srcWeightsSum() const } +template +inline Foam::scalarField& +Foam::AMIInterpolation::srcWeightsSum() +{ + return srcWeightsSum_; +} + + template inline const Foam::mapDistribute& Foam::AMIInterpolation::srcMap() const @@ -112,6 +128,14 @@ Foam::AMIInterpolation::tgtWeights() const } +template +inline Foam::scalarListList& +Foam::AMIInterpolation::tgtWeights() +{ + return tgtWeights_; +} + + template inline const Foam::scalarField& Foam::AMIInterpolation::tgtWeightsSum() const @@ -120,6 +144,14 @@ Foam::AMIInterpolation::tgtWeightsSum() const } +template +inline Foam::scalarField& +Foam::AMIInterpolation::tgtWeightsSum() +{ + return tgtWeightsSum_; +} + + template inline const Foam::mapDistribute& Foam::AMIInterpolation::tgtMap() const diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index 382faaff23..05dc64449d 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -38,35 +38,10 @@ namespace Foam addToRunTimeSelectionTable(polyPatch, cyclicACMIPolyPatch, dictionary); } -const Foam::scalar Foam::cyclicACMIPolyPatch::tolerance_ = 1e-6; +const Foam::scalar Foam::cyclicACMIPolyPatch::tolerance_ = 1e-10; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::cyclicACMIPolyPatch::initPatchFaceAreas() const -{ - if - ( - !empty() - && (faceAreas0_.empty() || boundaryMesh().mesh().moving()) - ) - { - faceAreas0_ = faceAreas(); - } - - const cyclicACMIPolyPatch& nbrACMI = - refCast(this->neighbPatch()); - - if - ( - !nbrACMI.empty() - && (nbrACMI.faceAreas0().empty() || boundaryMesh().mesh().moving()) - ) - { - nbrACMI.faceAreas0_ = nbrACMI.faceAreas(); - } -} - - void Foam::cyclicACMIPolyPatch::resetAMI ( const AMIPatchToPatchInterpolation::interpolationMethod& @@ -76,37 +51,117 @@ void Foam::cyclicACMIPolyPatch::resetAMI { const polyPatch& nonOverlapPatch = this->nonOverlapPatch(); - initPatchFaceAreas(); - - // Reset patch face areas based on original patch for AMI calculation - vectorField::subField Sf = faceAreas(); - vectorField::subField noSf = nonOverlapPatch.faceAreas(); - - forAll(Sf, facei) + if (debug) { - Sf[facei] = faceAreas0_[facei]; - noSf[facei] = faceAreas0_[facei]; + Pout<< "cyclicACMIPolyPatch::resetAMI : recalculating weights" + << " for " << name() << " and " << nonOverlapPatch.name() + << endl; } - // Calculate the AMI using partial face-area-weighted + if (boundaryMesh().mesh().hasCellCentres()) + { + WarningInFunction + << "The mesh already has cellCentres calculated when" + << " resetting ACMI " << name() << "." << endl + << "This is a problem since ACMI adapts the face areas" + << " (to close cells) so this has" << endl + << "to be done before cell centre calculation." << endl + << "This can happen if e.g. the cyclicACMI is after" + << " any processor patches in the boundary." << endl + << "Continuing with potential for incorrect geometry" + << " calculation and mass loss" << endl; + } + + + // Trigger re-building of faceAreas + (void)boundaryMesh().mesh().faceAreas(); + + + // Calculate the AMI using partial face-area-weighted. This leaves + // the weights as fractions of local areas (sum(weights) = 1 means + // face is fully covered) cyclicAMIPolyPatch::resetAMI ( AMIPatchToPatchInterpolation::imPartialFaceAreaWeight ); + AMIPatchToPatchInterpolation& AMI = + const_cast(this->AMI()); + srcMask_ = - min(scalar(1) - tolerance_, max(tolerance_, AMI().srcWeightsSum())); + min(scalar(1) - tolerance_, max(tolerance_, AMI.srcWeightsSum())); tgtMask_ = - min(scalar(1) - tolerance_, max(tolerance_, AMI().tgtWeightsSum())); + min(scalar(1) - tolerance_, max(tolerance_, AMI.tgtWeightsSum())); - forAll(Sf, facei) + + // Adapt owner side areas. Note that in uncoupled situations (e.g. + // decomposePar) srcMask, tgtMask can be zero size. + if (srcMask_.size()) { - Sf[facei] *= srcMask_[facei]; - noSf[facei] *= 1.0 - srcMask_[facei]; + vectorField::subField Sf = faceAreas(); + vectorField::subField noSf = nonOverlapPatch.faceAreas(); + + forAll(Sf, facei) + { + Sf[facei] *= srcMask_[facei]; + noSf[facei] *= 1.0 - srcMask_[facei]; + } + } + // Adapt slave side areas + if (tgtMask_.size()) + { + const cyclicACMIPolyPatch& cp = + refCast(this->neighbPatch()); + const polyPatch& pp = cp.nonOverlapPatch(); + + vectorField::subField Sf = cp.faceAreas(); + vectorField::subField noSf = pp.faceAreas(); + + forAll(Sf, facei) + { + Sf[facei] *= tgtMask_[facei]; + noSf[facei] *= 1.0 - tgtMask_[facei]; + } } - setNeighbourFaceAreas(); + // Re-normalise the weights since the effect of overlap is already + // accounted for in the area. + { + scalarListList& srcWeights = AMI.srcWeights(); + scalarField& srcWeightsSum = AMI.srcWeightsSum(); + forAll(srcWeights, i) + { + scalarList& wghts = srcWeights[i]; + if (wghts.size()) + { + scalar& sum = srcWeightsSum[i]; + + forAll(wghts, j) + { + wghts[j] /= sum; + } + sum = 1.0; + } + } + } + { + scalarListList& tgtWeights = AMI.tgtWeights(); + scalarField& tgtWeightsSum = AMI.tgtWeightsSum(); + forAll(tgtWeights, i) + { + scalarList& wghts = tgtWeights[i]; + if (wghts.size()) + { + scalar& sum = tgtWeightsSum[i]; + forAll(wghts, j) + { + wghts[j] /= sum; + } + sum = 1.0; + } + } + } // Set the updated flag updated_ = true; @@ -114,36 +169,13 @@ void Foam::cyclicACMIPolyPatch::resetAMI } -void Foam::cyclicACMIPolyPatch::setNeighbourFaceAreas() const -{ - const cyclicACMIPolyPatch& cp = - refCast(this->neighbPatch()); - const polyPatch& pp = cp.nonOverlapPatch(); - - const vectorField& faceAreas0 = cp.faceAreas0(); - - if (tgtMask_.size() == cp.size()) - { - vectorField::subField Sf = cp.faceAreas(); - vectorField::subField noSf = pp.faceAreas(); - - forAll(Sf, facei) - { - Sf[facei] = tgtMask_[facei]*faceAreas0[facei]; - noSf[facei] = (1.0 - tgtMask_[facei])*faceAreas0[facei]; - } - } - else - { - WarningInFunction - << "Target mask size differs to that of the neighbour patch\n" - << " May occur when decomposing." << endl; - } -} - - void Foam::cyclicACMIPolyPatch::initGeometry(PstreamBuffers& pBufs) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::initGeometry : " << name() << endl; + } + cyclicAMIPolyPatch::initGeometry(pBufs); // Initialise the AMI @@ -153,6 +185,10 @@ void Foam::cyclicACMIPolyPatch::initGeometry(PstreamBuffers& pBufs) void Foam::cyclicACMIPolyPatch::calcGeometry(PstreamBuffers& pBufs) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::calcGeometry : " << name() << endl; + } cyclicAMIPolyPatch::calcGeometry(pBufs); } @@ -163,6 +199,10 @@ void Foam::cyclicACMIPolyPatch::initMovePoints const pointField& p ) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::initMovePoints : " << name() << endl; + } cyclicAMIPolyPatch::initMovePoints(pBufs, p); // Initialise the AMI @@ -176,24 +216,40 @@ void Foam::cyclicACMIPolyPatch::movePoints const pointField& p ) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::movePoints : " << name() << endl; + } cyclicAMIPolyPatch::movePoints(pBufs, p); } void Foam::cyclicACMIPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::initUpdateMesh : " << name() << endl; + } cyclicAMIPolyPatch::initUpdateMesh(pBufs); } void Foam::cyclicACMIPolyPatch::updateMesh(PstreamBuffers& pBufs) { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::updateMesh : " << name() << endl; + } cyclicAMIPolyPatch::updateMesh(pBufs); } void Foam::cyclicACMIPolyPatch::clearGeom() { + if (debug) + { + Pout<< "cyclicACMIPolyPatch::clearGeom : " << name() << endl; + } cyclicAMIPolyPatch::clearGeom(); } @@ -224,7 +280,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch ) : cyclicAMIPolyPatch(name, size, start, index, bm, patchType, transform), - faceAreas0_(), nonOverlapPatchName_(word::null), nonOverlapPatchID_(-1), srcMask_(), @@ -248,7 +303,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch ) : cyclicAMIPolyPatch(name, dict, index, bm, patchType), - faceAreas0_(), nonOverlapPatchName_(dict.lookup("nonOverlapPatch")), nonOverlapPatchID_(-1), srcMask_(), @@ -279,7 +333,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch ) : cyclicAMIPolyPatch(pp, bm), - faceAreas0_(), nonOverlapPatchName_(pp.nonOverlapPatchName_), nonOverlapPatchID_(-1), srcMask_(), @@ -305,7 +358,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch ) : cyclicAMIPolyPatch(pp, bm, index, newSize, newStart, nbrPatchName), - faceAreas0_(), nonOverlapPatchName_(nonOverlapPatchName), nonOverlapPatchID_(-1), srcMask_(), @@ -337,7 +389,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch ) : cyclicAMIPolyPatch(pp, bm, index, mapAddressing, newStart), - faceAreas0_(), nonOverlapPatchName_(pp.nonOverlapPatchName_), nonOverlapPatchID_(-1), srcMask_(), diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.H index 987adc4dae..5e21fb5be5 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.H @@ -57,8 +57,8 @@ private: // Private data - //- Copy of the original patch face areas - mutable vectorField faceAreas0_; + //- Fraction of face area below which face is considered disconnected + static const scalar tolerance_; //- Name of non-overlapping patch const word nonOverlapPatchName_; @@ -78,14 +78,8 @@ private: protected: - static const scalar tolerance_; - - // Protected Member Functions - //- Initialise patch face areas - virtual void initPatchFaceAreas() const; - //- Reset the AMI interpolator virtual void resetAMI ( @@ -93,9 +87,6 @@ protected: AMIPatchToPatchInterpolation::imFaceAreaWeight ) const; - //- Set neighbour ACMI patch areas - virtual void setNeighbourFaceAreas() const; - //- Initialise the calculation of the patch geometry virtual void initGeometry(PstreamBuffers&); @@ -254,9 +245,6 @@ public: //- Return access to the updated flag inline bool updated() const; - //- Return access to the original patch face areas - inline const vectorField& faceAreas0() const; - //- Return a reference to the neighbour patch virtual const cyclicACMIPolyPatch& neighbPatch() const; @@ -275,34 +263,8 @@ public: //- Mask field where 1 = overlap, 0 = no-overlap inline const scalarField& mask() const; - - // Interpolations - - //- Interpolate field - template - tmp> interpolate - ( - const Field& fldCouple, - const Field& fldNonOverlap - ) const; - - //- Interpolate tmp field - template - tmp> interpolate - ( - const tmp>& tFldCouple, - const tmp>& tFldNonOverlap - ) const; - - //- Low-level interpolate List - template - void interpolate - ( - const UList& fldCouple, - const UList& fldNonOverlap, - const CombineOp& cop, - List& result - ) const; + //- Overlap tolerance + inline static scalar tolerance(); //- Calculate the patch geometry @@ -353,12 +315,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository - #include "cyclicACMIPolyPatchTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchI.H b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchI.H index 07f6b07bcb..6efbb7b561 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchI.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,12 +37,6 @@ inline bool Foam::cyclicACMIPolyPatch::updated() const } -inline const Foam::vectorField& Foam::cyclicACMIPolyPatch::faceAreas0() const -{ - return faceAreas0_; -} - - inline const Foam::word& Foam::cyclicACMIPolyPatch::nonOverlapPatchName() const { return nonOverlapPatchName_; @@ -80,4 +74,10 @@ inline const Foam::scalarField& Foam::cyclicACMIPolyPatch::mask() const } +inline Foam::scalar Foam::cyclicACMIPolyPatch::tolerance() +{ + return tolerance_; +} + + // ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C deleted file mode 100644 index 336e8caa2d..0000000000 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatchTemplates.C +++ /dev/null @@ -1,87 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -template -Foam::tmp> Foam::cyclicACMIPolyPatch::interpolate -( - const Field& fldCouple, - const Field& fldNonOverlap -) const -{ - // Note: do not scale AMI field as face areas have already been taken into - // account - - if (owner()) - { - return - AMI().interpolateToSource(fldCouple) - + (1.0 - AMI().srcWeightsSum())*fldNonOverlap; - } - else - { - return - neighbPatch().AMI().interpolateToTarget(fldCouple) - + (1.0 - neighbPatch().AMI().tgtWeightsSum())*fldNonOverlap; - } -} - - -template -Foam::tmp> Foam::cyclicACMIPolyPatch::interpolate -( - const tmp>& tFldCouple, - const tmp>& tFldNonOverlap -) const -{ - return interpolate(tFldCouple(), tFldNonOverlap()); -} - - -template -void Foam::cyclicACMIPolyPatch::interpolate -( - const UList& fldCouple, - const UList& fldNonOverlap, - const CombineOp& cop, - List& result -) const -{ - // Note: do not scale AMI field as face areas have already been taken into - // account - - if (owner()) - { - AMI().interpolateToSource(fldCouple, cop, result); - result += (1.0 - AMI().srcWeightsSum())*fldNonOverlap; - } - else - { - neighbPatch().AMI().interpolateToTarget(fldCouple, cop, result); - result += (1.0 - neighbPatch().AMI().tgtWeightsSum())*fldNonOverlap; - } -} - - -// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun index 66d148bb57..00132b6793 100755 --- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun +++ b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun @@ -13,7 +13,6 @@ if [ -d 0 ] ; then rm -rf 0 fi -runApplication createPatch -overwrite runApplication createBaffles -overwrite runApplication mergeOrSplitBaffles -split -overwrite diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/system/createPatchDict b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/system/createPatchDict deleted file mode 100644 index 9861be8d4e..0000000000 --- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/system/createPatchDict +++ /dev/null @@ -1,28 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - object createPatchDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Do a synchronisation of coupled points after creation of any patches. -// Note: this does not work with points that are on multiple coupled patches -// with transformations (i.e. cyclics). -pointSync false; - -// Patches to create. An empty patch list just removes patches with zero -// faces from $FOAM_CASE/constant/polyMesh/boundary. -patches -( -); - -// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre index 4b6c843cff..7bcc1f15b4 100755 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre +++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre @@ -11,7 +11,4 @@ runApplication topoSet -constant # split the mesh to generate the ACMI coupled patches runApplication createBaffles -overwrite -# remove zero-sized patches -runApplication createPatch -overwrite - cp -rf 0.orig 0 diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/system/createPatchDict b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/system/createPatchDict deleted file mode 100644 index cbfab2fa08..0000000000 --- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/system/createPatchDict +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - object createPatchDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// This application/dictionary controls: -// - optional: create new patches from boundary faces (either given as -// a set of patches or as a faceSet) -// - always: order faces on coupled patches such that they are opposite. This -// is done for all coupled faces, not just for any patches created. -// - optional: synchronise points on coupled patches. - -// 1. Create cyclic: -// - specify where the faces should come from -// - specify the type of cyclic. If a rotational specify the rotationAxis -// and centre to make matching easier -// - always create both halves in one invocation with correct 'neighbourPatch' -// setting. -// - optionally pointSync true to guarantee points to line up. - -// 2. Correct incorrect cyclic: -// This will usually fail upon loading: -// "face 0 area does not match neighbour 2 by 0.0100005%" -// " -- possible face ordering problem." -// - in polyMesh/boundary file: -// - loosen matchTolerance of all cyclics to get case to load -// - or change patch type from 'cyclic' to 'patch' -// and regenerate cyclic as above - - -// Do a synchronisation of coupled points after creation of any patches. -// Note: this does not work with points that are on multiple coupled patches -// with transformations (i.e. cyclics). -pointSync false; - -// Patches to create. -patches -( - // none -); - -// ************************************************************************* //