From 826e009c2e958ddb2713b2f1a9e74626ec1f552b Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Mon, 30 Apr 2018 14:33:15 +0100 Subject: [PATCH] cycicACMI: Removed duplicate code in fv and fvs patches and fields --- .../constraint/cyclic/cyclicFvPatchField.H | 10 - .../cyclicACMI/cyclicACMIFvPatchField.C | 230 +----------------- .../cyclicACMI/cyclicACMIFvPatchField.H | 127 +--------- .../cyclicAMI/cyclicAMIFvPatchField.H | 10 - .../cyclicACMI/cyclicACMIFvsPatchField.C | 135 ---------- .../cyclicACMI/cyclicACMIFvsPatchField.H | 63 +---- .../cyclicACMI/cyclicACMIFvsPatchFields.C | 3 +- .../constraint/cyclicACMI/cyclicACMIFvPatch.C | 113 ++------- .../constraint/cyclicACMI/cyclicACMIFvPatch.H | 140 ++--------- .../constraint/cyclicAMI/cyclicAMIFvPatch.C | 48 ++-- .../constraint/cyclicAMI/cyclicAMIFvPatch.H | 13 +- 11 files changed, 102 insertions(+), 790 deletions(-) delete mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H index 15ce65da2..ca361e478 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H @@ -78,16 +78,6 @@ class cyclicFvPatchField const cyclicFvPatch& cyclicPatch_; - // Private Member Functions - - //- Return neighbour side field given internal fields - template - tmp> neighbourSideField - ( - const Field& - ) const; - - public: //- Runtime type information diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 79982c9c0..5e76dcd9d 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -26,157 +26,8 @@ License #include "cyclicACMIFvPatchField.H" #include "transformField.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField -( - const fvPatch& p, - const DimensionedField& iF -) -: - coupledFvPatchField(p, iF), - cyclicACMILduInterfaceField(), - cyclicACMIPatch_(refCast(p)) -{} - - -template -Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - coupledFvPatchField(p, iF, dict, dict.found("value")), - cyclicACMILduInterfaceField(), - cyclicACMIPatch_(refCast(p)) -{ - if (!isA(p)) - { - FatalIOErrorInFunction - ( - dict - ) << " patch type '" << p.type() - << "' not constraint type '" << typeName << "'" - << "\n for patch " << p.name() - << " of field " << this->internalField().name() - << " in file " << this->internalField().objectPath() - << exit(FatalIOError); - } - - if (!dict.found("value") && this->coupled()) - { - this->evaluate(Pstream::commsTypes::blocking); - } -} - - -template -Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField -( - const cyclicACMIFvPatchField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - coupledFvPatchField(ptf, p, iF, mapper), - cyclicACMILduInterfaceField(), - cyclicACMIPatch_(refCast(p)) -{ - if (!isA(this->patch())) - { - FatalErrorInFunction - << "' not constraint type '" << typeName << "'" - << "\n for patch " << p.name() - << " of field " << this->internalField().name() - << " in file " << this->internalField().objectPath() - << exit(FatalIOError); - } -} - - - -template -Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField -( - const cyclicACMIFvPatchField& ptf -) -: - coupledFvPatchField(ptf), - cyclicACMILduInterfaceField(), - cyclicACMIPatch_(ptf.cyclicACMIPatch_) -{} - - -template -Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField -( - const cyclicACMIFvPatchField& ptf, - const DimensionedField& iF -) -: - coupledFvPatchField(ptf, iF), - cyclicACMILduInterfaceField(), - cyclicACMIPatch_(ptf.cyclicACMIPatch_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -bool Foam::cyclicACMIFvPatchField::coupled() const -{ - return cyclicACMIPatch_.coupled(); -} - - -template -Foam::tmp> -Foam::cyclicACMIFvPatchField::patchNeighbourField() const -{ - const Field& iField = this->primitiveField(); - const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); - tmp> tpnf - ( - cyclicACMIPatch_.interpolate - ( - Field - ( - iField, - cpp.neighbPatch().faceCells() - ) - ) - ); - - if (doTransform()) - { - tpnf.ref() = transform(forwardT(), tpnf()); - } - - return tpnf; -} - - -template -const Foam::cyclicACMIFvPatchField& -Foam::cyclicACMIFvPatchField::neighbourPatchField() const -{ - const GeometricField& fld = - static_cast&> - ( - this->primitiveField() - ); - - return refCast> - ( - fld.boundaryField()[cyclicACMIPatch_.neighbPatchID()] - ); -} - - template const Foam::fvPatchField& Foam::cyclicACMIFvPatchField::nonOverlapPatchField() const @@ -187,71 +38,10 @@ Foam::cyclicACMIFvPatchField::nonOverlapPatchField() const this->primitiveField() ); - return fld.boundaryField()[cyclicACMIPatch_.nonOverlapPatchID()]; -} - - -template -void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix -( - scalarField& result, - const scalarField& psiInternal, - const scalarField& coeffs, - const direction cmpt, - const Pstream::commsTypes -) const -{ - const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); - - // note: only applying coupled contribution - - const labelUList& nbrFaceCellsCoupled = - cpp.neighbPatch().faceCells(); - - scalarField pnf(psiInternal, nbrFaceCellsCoupled); - - // Transform according to the transformation tensors - transformCoupleField(pnf, cmpt); - - const labelUList& faceCells = cyclicACMIPatch_.faceCells(); - - pnf = cyclicACMIPatch_.interpolate(pnf); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } -} - - -template -void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix -( - Field& result, - const Field& psiInternal, - const scalarField& coeffs, - const Pstream::commsTypes -) const -{ - const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch(); - - // note: only applying coupled contribution - - const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells(); - - Field pnf(psiInternal, nbrFaceCellsCoupled); - - // Transform according to the transformation tensors - transformCoupleField(pnf); - - const labelUList& faceCells = cyclicACMIPatch_.faceCells(); - - pnf = cyclicACMIPatch_.interpolate(pnf); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + return fld.boundaryField() + [ + cyclicACMIPatch().cyclicACMIPatch().nonOverlapPatchID() + ]; } @@ -261,7 +51,7 @@ void Foam::cyclicACMIFvPatchField::manipulateMatrix fvMatrix& matrix ) { - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + const scalarField& mask = cyclicACMIPatch().cyclicACMIPatch().mask(); // nothing to be done by the AMI, but re-direct to non-overlap patch // with non-overlap patch weights @@ -280,18 +70,10 @@ void Foam::cyclicACMIFvPatchField::updateCoeffs() // Pass in (1 - mask) to give non-overlap patch the chance to do // manipulation of non-face based data - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + const scalarField& mask = cyclicACMIPatch().cyclicACMIPatch().mask(); const fvPatchField& npf = nonOverlapPatchField(); const_cast&>(npf).updateWeightedCoeffs(1.0 - mask); } -template -void Foam::cyclicACMIFvPatchField::write(Ostream& os) const -{ - fvPatchField::write(os); - this->writeEntry("value", os); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index 7f7921dd9..46b2b9c78 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -52,8 +52,7 @@ SourceFiles #ifndef cyclicACMIFvPatchField_H #define cyclicACMIFvPatchField_H -#include "coupledFvPatchField.H" -#include "cyclicACMILduInterfaceField.H" +#include "cyclicAMIFvPatchField.H" #include "cyclicACMIFvPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,25 +67,8 @@ namespace Foam template class cyclicACMIFvPatchField : - public coupledFvPatchField, - public cyclicACMILduInterfaceField + public cyclicAMIFvPatchField { - // Private data - - //- Local reference cast into the cyclic patch - const cyclicACMIFvPatch& cyclicACMIPatch_; - - - // Private Member Functions - - //- Return neighbour side field given internal fields - template - tmp> neighbourSideField - ( - const Field& - ) const; - - public: //- Runtime type information @@ -95,32 +77,8 @@ public: // Constructors - //- Construct from patch and internal field - cyclicACMIFvPatchField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - cyclicACMIFvPatchField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given cyclicACMIFvPatchField onto a new patch - cyclicACMIFvPatchField - ( - const cyclicACMIFvPatchField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - cyclicACMIFvPatchField(const cyclicACMIFvPatchField&); + //- Inherit parent constructors + using cyclicAMIFvPatchField::cyclicAMIFvPatchField; //- Construct and return a clone virtual tmp> clone() const @@ -131,13 +89,6 @@ public: ); } - //- Construct as copy setting internal field reference - cyclicACMIFvPatchField - ( - const cyclicACMIFvPatchField&, - const DimensionedField& - ); - //- Construct and return a clone setting internal field reference virtual tmp> clone ( @@ -155,26 +106,22 @@ public: // Access - //- Return local reference cast into the cyclic AMI patch + //- Return the fv patch const cyclicACMIFvPatch& cyclicACMIPatch() const { - return cyclicACMIPatch_; + return refCast(this->patch()); } // Evaluation functions - //- Return true if coupled. Note that the underlying patch - // is not coupled() - the points don't align - virtual bool coupled() const; - //- Return true if this patch field fixes a value // Needed to check if a level has to be specified while solving // Poissons equations virtual bool fixesValue() const { const scalarField& mask = - cyclicACMIPatch_.cyclicACMIPatch().mask(); + cyclicACMIPatch().cyclicACMIPatch().mask(); if (gMax(mask) > 1e-5) { @@ -188,74 +135,14 @@ public: } } - - //- Return neighbour coupled internal cell data - virtual tmp> patchNeighbourField() const; - - //- Return reference to neighbour patchField - const cyclicACMIFvPatchField& neighbourPatchField() const; - //- Return reference to non-overlapping patchField const fvPatchField& nonOverlapPatchField() const; - //- Update result field based on interface functionality - virtual void updateInterfaceMatrix - ( - scalarField& result, - const scalarField& psiInternal, - const scalarField& coeffs, - const direction cmpt, - const Pstream::commsTypes commsType - ) const; - - //- Update result field based on interface functionality - virtual void updateInterfaceMatrix - ( - Field&, - const Field&, - const scalarField&, - const Pstream::commsTypes commsType - ) const; - //- Manipulate matrix virtual void manipulateMatrix(fvMatrix& matrix); //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - - - // Cyclic AMI coupled interface functions - - //- Does the patch field perform the transformation - virtual bool doTransform() const - { - return - !(cyclicACMIPatch_.parallel() || pTraits::rank == 0); - } - - //- Return face transformation tensor - virtual const tensorField& forwardT() const - { - return cyclicACMIPatch_.forwardT(); - } - - //- Return neighbour-cell transformation tensor - virtual const tensorField& reverseT() const - { - return cyclicACMIPatch_.reverseT(); - } - - //- Return rank of component for transform - virtual int rank() const - { - return pTraits::rank; - } - - - // I-O - - //- Write - virtual void write(Ostream& os) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H index 19606b1fb..f8e55c0c0 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H @@ -82,16 +82,6 @@ class cyclicAMIFvPatchField const cyclicAMIFvPatch& cyclicAMIPatch_; - // Private Member Functions - - //- Return neighbour side field given internal fields - template - tmp> neighbourSideField - ( - const Field& - ) const; - - public: //- Runtime type information diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C deleted file mode 100644 index d230e64d5..000000000 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C +++ /dev/null @@ -1,135 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013-2015 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 . - -\*---------------------------------------------------------------------------*/ - -#include "cyclicACMIFvsPatchField.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField -( - const fvPatch& p, - const DimensionedField& iF -) -: - coupledFvsPatchField(p, iF), - cyclicACMIPatch_(refCast(p)) -{} - - -template -Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField -( - const cyclicACMIFvsPatchField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - coupledFvsPatchField(ptf, p, iF, mapper), - cyclicACMIPatch_(refCast(p)) -{ - if (!isA(this->patch())) - { - FatalErrorInFunction - << "Field type does not correspond to patch type for patch " - << this->patch().index() << "." << endl - << "Field type: " << typeName << endl - << "Patch type: " << this->patch().type() - << exit(FatalError); - } -} - - -template -Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - coupledFvsPatchField(p, iF, dict), - cyclicACMIPatch_(refCast(p)) -{ - if (!isA(p)) - { - FatalIOErrorInFunction - ( - dict - ) << "patch " << this->patch().index() << " not cyclicACMI type. " - << "Patch type = " << p.type() - << exit(FatalIOError); - } -} - - -template -Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField -( - const cyclicACMIFvsPatchField& ptf -) -: - coupledFvsPatchField(ptf), - cyclicACMIPatch_(ptf.cyclicACMIPatch_) -{} - - -template -Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField -( - const cyclicACMIFvsPatchField& ptf, - const DimensionedField& iF -) -: - coupledFvsPatchField(ptf, iF), - cyclicACMIPatch_(ptf.cyclicACMIPatch_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -bool Foam::cyclicACMIFvsPatchField::coupled() const -{ - if - ( - Pstream::parRun() - || ( - this->cyclicACMIPatch_.size() - && this->cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().size() - ) - ) - { - return true; - } - else - { - return false; - } -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H index b0b0d5745..3537e5f5d 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ SourceFiles #ifndef cyclicACMIFvsPatchField_H #define cyclicACMIFvsPatchField_H -#include "coupledFvsPatchField.H" +#include "cyclicAMIFvsPatchField.H" #include "cyclicACMIFvPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,14 +50,8 @@ namespace Foam template class cyclicACMIFvsPatchField : - public coupledFvsPatchField + public cyclicAMIFvsPatchField { - // Private data - - //- Local reference cast into the cyclic patch - const cyclicACMIFvPatch& cyclicACMIPatch_; - - public: //- Runtime type information @@ -66,35 +60,8 @@ public: // Constructors - //- Construct from patch and internal field - cyclicACMIFvsPatchField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - cyclicACMIFvsPatchField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given cyclicACMIFvsPatchField onto a new patch - cyclicACMIFvsPatchField - ( - const cyclicACMIFvsPatchField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - cyclicACMIFvsPatchField - ( - const cyclicACMIFvsPatchField& - ); + //- Inherit parent constructors + using cyclicAMIFvsPatchField::cyclicAMIFvsPatchField; //- Construct and return a clone virtual tmp> clone() const @@ -105,13 +72,6 @@ public: ); } - //- Construct as copy setting internal field reference - cyclicACMIFvsPatchField - ( - const cyclicACMIFvsPatchField&, - const DimensionedField& - ); - //- Construct and return a clone setting internal field reference virtual tmp> clone ( @@ -123,13 +83,6 @@ public: new cyclicACMIFvsPatchField(*this, iF) ); } - - // Member functions - - // Access - - //- Return true if running parallel - virtual bool coupled() const; }; @@ -139,12 +92,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository - #include "cyclicACMIFvsPatchField.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C index efe05703d..2b0502415 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C @@ -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-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "cyclicACMIFvsPatchFields.H" #include "fvsPatchFields.H" +#include "surfaceMesh.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C index 58c23a558..d8b58d2c2 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,16 +37,16 @@ namespace Foam } -// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::cyclicACMIFvPatch::updateAreas() const { - if (cyclicACMIPolyPatch_.updated()) + if (cyclicACMIPatch().updated()) { if (debug) { Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for " - << name() << " and " << this->nonOverlapPatch().name() + << name() << " and " << nonOverlapFvPatch().name() << endl; } @@ -55,58 +55,49 @@ void Foam::cyclicACMIFvPatch::updateAreas() const const_cast(magSf()) = mag(patch().faceAreas()); // owner non-overlapping - const fvPatch& nonOverlapPatch = this->nonOverlapPatch(); + const fvPatch& nonOverlapPatch = nonOverlapFvPatch(); const_cast(nonOverlapPatch.Sf()) = nonOverlapPatch.patch().faceAreas(); const_cast(nonOverlapPatch.magSf()) = mag(nonOverlapPatch.patch().faceAreas()); // neighbour couple - const cyclicACMIFvPatch& nbrACMI = neighbPatch(); + const cyclicACMIFvPatch& nbrACMI = neighbFvPatch(); const_cast(nbrACMI.Sf()) = nbrACMI.patch().faceAreas(); const_cast(nbrACMI.magSf()) = mag(nbrACMI.patch().faceAreas()); // neighbour non-overlapping - const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapPatch(); + const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapFvPatch(); const_cast(nbrNonOverlapPatch.Sf()) = nbrNonOverlapPatch.patch().faceAreas(); const_cast(nbrNonOverlapPatch.magSf()) = mag(nbrNonOverlapPatch.patch().faceAreas()); // set the updated flag - cyclicACMIPolyPatch_.setUpdated(false); + cyclicACMIPatch().setUpdated(false); } } +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const { if (coupled()) { - const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); - const scalarField deltas(nf() & coupledFvPatch::delta()); - // 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() - ) - ); + const scalarField deltan(this->deltan()); + const scalarField nbrDeltan(this->nbrDeltan()); - scalar tol = cyclicACMIPolyPatch::tolerance(); - - - forAll(deltas, facei) + forAll(deltan, facei) { - scalar di = deltas[facei]; - scalar dni = nbrDeltas[facei]; + scalar di = deltan[facei]; + scalar dni = nbrDeltan[facei]; - if (dni < tol) + if (dni < cyclicACMIPolyPatch::tolerance()) { // Avoid zero weights on disconnected faces. This value // will be weighted with the (zero) face area so will not @@ -127,76 +118,4 @@ void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::cyclicACMIFvPatch::coupled() const -{ - return Pstream::parRun() || (this->size() && neighbFvPatch().size()); -} - - -Foam::tmp Foam::cyclicACMIFvPatch::delta() const -{ - if (coupled()) - { - const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); - - const vectorField patchD(coupledFvPatch::delta()); - - vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta())); - - - tmp tpdv(new vectorField(patchD.size())); - vectorField& pdv = tpdv.ref(); - - // do the transformation if necessary - if (parallel()) - { - forAll(patchD, facei) - { - const vector& ddi = patchD[facei]; - const vector& dni = nbrPatchD[facei]; - - pdv[facei] = ddi - dni; - } - } - else - { - forAll(patchD, facei) - { - const vector& ddi = patchD[facei]; - const vector& dni = nbrPatchD[facei]; - - pdv[facei] = ddi - transform(forwardT()[0], dni); - } - } - - return tpdv; - } - else - { - return coupledFvPatch::delta(); - } -} - - -Foam::tmp Foam::cyclicACMIFvPatch::interfaceInternalField -( - const labelUList& internalData -) const -{ - return patchInternalField(internalData); -} - - -Foam::tmp Foam::cyclicACMIFvPatch::internalFieldTransfer -( - const Pstream::commsTypes commsType, - const labelUList& iF -) const -{ - return neighbFvPatch().patchInternalField(iF); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H index 2b5b5bdba..ba273ab57 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H @@ -35,10 +35,8 @@ SourceFiles #ifndef cyclicACMIFvPatch_H #define cyclicACMIFvPatch_H -#include "coupledFvPatch.H" -#include "cyclicACMILduInterface.H" +#include "cyclicAMIFvPatch.H" #include "cyclicACMIPolyPatch.H" -#include "fvBoundaryMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,23 +49,22 @@ namespace Foam class cyclicACMIFvPatch : - public coupledFvPatch, - public cyclicACMILduInterface + public cyclicAMIFvPatch { - // Private data +private: - const cyclicACMIPolyPatch& cyclicACMIPolyPatch_; + // Private member functions + + //- Update the patch areas after AMI update + void updateAreas() const; protected: // Protected Member functions - //- Update the patch areas after AMI update - void updateAreas() const; - //- Make patch weighting factors - void makeWeights(scalarField&) const; + virtual void makeWeights(scalarField&) const; public: @@ -81,9 +78,7 @@ public: //- Construct from polyPatch cyclicACMIFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm) : - coupledFvPatch(patch, bm), - cyclicACMILduInterface(), - cyclicACMIPolyPatch_(refCast(patch)) + cyclicAMIFvPatch(patch, bm) {} @@ -91,49 +86,11 @@ public: // Access - //- Return local reference cast into the cyclic patch - const cyclicACMIPolyPatch& cyclicACMIPatch() const - { - return cyclicACMIPolyPatch_; - } - - //- Return neighbour - virtual label neighbPatchID() const - { - return cyclicACMIPolyPatch_.neighbPatchID(); - } - - virtual bool owner() const - { - return cyclicACMIPolyPatch_.owner(); - } - - //- Return neighbour fvPatch - virtual const cyclicACMIFvPatch& neighbPatch() const - { - return refCast - ( - this->boundaryMesh()[cyclicACMIPolyPatch_.neighbPatchID()] - ); - } - - //- Return neighbour - virtual label nonOverlapPatchID() const - { - return cyclicACMIPolyPatch_.nonOverlapPatchID(); - } - - //- Return non-overlapping fvPatch - virtual const fvPatch& nonOverlapPatch() const - { - return this->boundaryMesh()[nonOverlapPatchID()]; - } - //- Return a reference to the AMI interpolators virtual const PtrList& AMIs() const { const PtrList& AMIs = - cyclicACMIPolyPatch_.AMIs(); + cyclicAMIFvPatch::AMIs(); updateAreas(); @@ -144,89 +101,36 @@ public: virtual const List& AMITransforms() const { const List& AMITransforms = - cyclicACMIPolyPatch_.AMITransforms(); + cyclicAMIFvPatch::AMITransforms(); updateAreas(); return AMITransforms; } - //- Are the cyclic planes parallel - virtual bool parallel() const + //- Return the poly patch + const cyclicACMIPolyPatch& cyclicACMIPatch() const { - return cyclicACMIPolyPatch_.parallel(); - } - - //- Return face transformation tensor - virtual const tensorField& forwardT() const - { - return cyclicACMIPolyPatch_.forwardT(); - } - - //- Return neighbour-cell transformation tensor - virtual const tensorField& reverseT() const - { - return cyclicACMIPolyPatch_.reverseT(); + return refCast(this->patch()); } + //- Return the neighbour patch const cyclicACMIFvPatch& neighbFvPatch() const { return refCast ( - this->boundaryMesh()[cyclicACMIPolyPatch_.neighbPatchID()] + this->boundaryMesh()[this->cyclicAMIPatch().neighbPatchID()] ); } - //- Return true if this patch is coupled. This is equivalent - // to the coupledPolyPatch::coupled() if parallel running or - // both sides present, false otherwise - virtual bool coupled() const; - - //- 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& fld - ) const + //- Return the non-overlap patch + const fvPatch& nonOverlapFvPatch() const { - updateAreas(); - - return - cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate - ( - fld - ); + return this->boundaryMesh() + [ + cyclicACMIPatch().nonOverlapPatchID() + ]; } - - //- Interpolate (make sure to have uptodate areas) - template - tmp> interpolate - ( - const tmp>& tfld - ) const - { - return interpolate(tfld()); - } - - - // Interface transfer functions - - //- Return the values of the given internal data adjacent to - // the interface as a field - virtual tmp interfaceInternalField - ( - const labelUList& internalData - ) const; - - //- Return neighbour field - virtual tmp internalFieldTransfer - ( - const Pstream::commsTypes commsType, - const labelUList& internalData - ) const; }; diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index a71241b49..33003c0b8 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,26 +37,24 @@ namespace Foam } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -bool Foam::cyclicAMIFvPatch::coupled() const +Foam::tmp Foam::cyclicAMIFvPatch::deltan() const { - return Pstream::parRun() || (this->size() && neighbFvPatch().size()); + return nf() & coupledFvPatch::delta(); } -void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const +Foam::tmp Foam::cyclicAMIFvPatch::nbrDeltan() const { if (coupled()) { const cyclicAMIFvPatch& nbrPatch = neighbFvPatch(); - const scalarField deltas(nf() & coupledFvPatch::delta()); - - tmp tnbrDeltas; + tmp tnbrDeltan; if (applyLowWeightCorrection()) { - tnbrDeltas = + tnbrDeltan = interpolate ( nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(), @@ -65,16 +63,30 @@ void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const } else { - tnbrDeltas = + tnbrDeltan = interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()); } - const scalarField& nbrDeltas = tnbrDeltas(); + return tnbrDeltan; + } + else + { + return tmp(); + } +} - forAll(deltas, facei) + +void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const +{ + if (coupled()) + { + const scalarField deltan(this->deltan()); + const scalarField nbrDeltan(this->nbrDeltan()); + + forAll(deltan, facei) { - scalar di = deltas[facei]; - scalar dni = nbrDeltas[facei]; + scalar di = deltan[facei]; + scalar dni = nbrDeltan[facei]; w[facei] = dni/(di + dni); } @@ -87,6 +99,14 @@ void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::cyclicAMIFvPatch::coupled() const +{ + return Pstream::parRun() || (this->size() && neighbFvPatch().size()); +} + + Foam::tmp Foam::cyclicAMIFvPatch::delta() const { const cyclicAMIFvPatch& nbrPatch = neighbFvPatch(); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H index 5dba5fe49..137d32dfd 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H @@ -63,8 +63,14 @@ protected: // Protected Member functions + //- Return the patch-normal component of the deltas + tmp deltan() const; + + //- Return the neighbour patch-normal component of the deltas + tmp nbrDeltan() const; + //- Make patch weighting factors - void makeWeights(scalarField&) const; + virtual void makeWeights(scalarField&) const; public: @@ -94,18 +100,19 @@ public: return cyclicAMIPolyPatch_; } - //- Return neighbour + //- Return the neighbour patch ID virtual label neighbPatchID() const { return cyclicAMIPolyPatch_.neighbPatchID(); } + //- Is this side the owner? virtual bool owner() const { return cyclicAMIPolyPatch_.owner(); } - //- Return processor number + //- Return the neighbour patch virtual const cyclicAMIFvPatch& neighbPatch() const { return refCast