From 87056a2308ce0d942e04fe49bfa7543dc0a2b743 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Wed, 7 Dec 2016 09:25:42 +0000 Subject: [PATCH] ENH: pairPatchAgglomeration - updated constructors --- .../faceAgglomerate/faceAgglomerate.C | 46 ++++++++++--------- .../extractEulerianParticles.C | 20 ++++++-- .../pairPatchAgglomeration.C | 41 ++++++----------- .../pairPatchAgglomeration.H | 15 +++--- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C index 5efc025508..cb5e3bba00 100644 --- a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C +++ b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +69,6 @@ int main(int argc, char *argv[]) bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration")); - const polyBoundaryMesh& boundary = mesh.boundaryMesh(); labelListIOList finalAgglom @@ -95,15 +94,20 @@ int main(int argc, char *argv[]) { label patchi = patchids[i]; const polyPatch& pp = boundary[patchi]; + if (!pp.coupled()) { Info << "\nAgglomerating patch : " << pp.name() << endl; + pairPatchAgglomeration agglomObject ( - pp, + pp.localFaces(), + pp.localPoints(), agglomDict.subDict(pp.name()) ); + agglomObject.agglomerate(); + finalAgglom[patchi] = agglomObject.restrictTopBottomAddressing(); @@ -116,42 +120,42 @@ int main(int argc, char *argv[]) } - // - All patches which are not agglomarated are identity for finalAgglom - forAll(boundary, patchid) + // All patches which are not agglomerated are identity for finalAgglom + forAll(boundary, patchi) { - if (finalAgglom[patchid].size() == 0) + if (finalAgglom[patchi].size() == 0) { - finalAgglom[patchid] = identity(boundary[patchid].size()); + finalAgglom[patchi] = identity(boundary[patchi].size()); } } // Sync agglomeration across coupled patches labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1); - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.coupled()) { - finalAgglom[patchid] = identity(pp.size()); + finalAgglom[patchi] = identity(pp.size()); forAll(pp, i) { - nbrAgglom[pp.start() - mesh.nInternalFaces() + i] = - finalAgglom[patchid][i]; + const label agglomi = pp.start() - mesh.nInternalFaces() + i; + nbrAgglom[agglomi] = finalAgglom[patchi][i]; } } } syncTools::swapBoundaryFaceList(mesh, nbrAgglom); - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.coupled() && !refCast(pp).owner()) { forAll(pp, i) { - finalAgglom[patchid][i] = - nbrAgglom[pp.start() - mesh.nInternalFaces() + i]; + const label agglomi = pp.start() - mesh.nInternalFaces() + i + finalAgglom[patchi][i] = nbrAgglom[agglomi]; } } } @@ -179,13 +183,13 @@ int main(int argc, char *argv[]) facesAgglomeration.boundaryFieldRef(); label coarsePatchIndex = 0; - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.size() > 0) { fvPatchScalarField& bFacesAgglomeration = - facesAgglomerationBf[patchid]; + facesAgglomerationBf[patchi]; forAll(bFacesAgglomeration, j) { @@ -193,11 +197,11 @@ int main(int argc, char *argv[]) index.toGlobal ( Pstream::myProcNo(), - finalAgglom[patchid][j] + coarsePatchIndex + finalAgglom[patchi][j] + coarsePatchIndex ); } - coarsePatchIndex += max(finalAgglom[patchid]) + 1; + coarsePatchIndex += max(finalAgglom[patchi]) + 1; } } diff --git a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C index 462a8d4f1d..5414b5eb49 100644 --- a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C +++ b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C @@ -151,7 +151,17 @@ void Foam::functionObjects::extractEulerianParticles::initialiseBins() } } - pairPatchAgglomeration ppa(patch, 10, 50, nLocations, labelMax, 180); + pairPatchAgglomeration ppa + ( + patch.localFaces(), + patch.localPoints(), + 10, + 50, + nLocations, + labelMax, + 180 + ); + ppa.agglomerate(); label nCoarseFaces = 0; @@ -601,11 +611,11 @@ bool Foam::functionObjects::extractEulerianParticles::read { dict.lookup("faceZone") >> faceZoneName_; dict.readIfPresent("nLocations", nInjectorLocations_); - dict.lookup("alphaName") >> alphaName_; + dict.lookup("alpha") >> alphaName_; dict.readIfPresent("alphaThreshold", alphaThreshold_); - dict.lookup("UName") >> UName_; - dict.lookup("rhoName") >> rhoName_; - dict.lookup("phiName") >> phiName_; + dict.lookup("U") >> UName_; + dict.lookup("rho") >> rhoName_; + dict.lookup("phi") >> phiName_; dict.readIfPresent("minDiameter", minDiameter_); dict.readIfPresent("maxDiameter", maxDiameter_); diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C index 362f299cc2..9276992b91 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -195,7 +195,8 @@ void Foam::pairPatchAgglomeration::setEdgeWeights Foam::pairPatchAgglomeration::pairPatchAgglomeration ( - const indirectPrimitivePatch& patch, + const faceList& faces, + const pointField& points, const dictionary& controlDict ) : @@ -218,23 +219,15 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration ), nFaces_(maxLevels_), restrictAddressing_(maxLevels_), - restrictTopBottomAddressing_(identity(patch.size())), + restrictTopBottomAddressing_(identity(faces.size())), patchLevels_(maxLevels_), - facePairWeight_(patch.size()) + facePairWeight_(faces.size()) { // Set base fine patch - patchLevels_.set - ( - 0, - new bPatch - ( - patch.localFaces(), - patch.localPoints() - ) - ); + patchLevels_.set(0, new bPatch(faces, points)); // Set number of faces for the base patch - nFaces_[0] = patch.size(); + nFaces_[0] = faces.size(); // Set edge weights for level 0 setLevel0EdgeWeights(); @@ -243,7 +236,8 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration Foam::pairPatchAgglomeration::pairPatchAgglomeration ( - const indirectPrimitivePatch& patch, + const faceList& faces, + const pointField& points, const label mergeLevels, const label maxLevels, const label nFacesInCoarsestLevel, // local number of cells @@ -258,23 +252,15 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration featureAngle_(featureAngle), nFaces_(maxLevels_), restrictAddressing_(maxLevels_), - restrictTopBottomAddressing_(identity(patch.size())), + restrictTopBottomAddressing_(identity(faces.size())), patchLevels_(maxLevels_), - facePairWeight_(patch.size()) + facePairWeight_(faces.size()) { // Set base fine patch - patchLevels_.set - ( - 0, - new bPatch - ( - patch.localFaces(), - patch.localPoints() - ) - ); + patchLevels_.set(0, new bPatch(faces, points)); // Set number of faces for the base patch - nFaces_[0] = patch.size(); + nFaces_[0] = faces.size(); // Set edge weights for level 0 setLevel0EdgeWeights(); @@ -289,7 +275,8 @@ Foam::pairPatchAgglomeration::~pairPatchAgglomeration() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::bPatch& Foam::pairPatchAgglomeration::patchLevel +const Foam::pairPatchAgglomeration::bPatch& +Foam::pairPatchAgglomeration::patchLevel ( const label i ) const diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H index 2e44d39f00..5b5d51f506 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H @@ -40,11 +40,6 @@ SourceFiles #include "List.H" #include "EdgeMap.H" -namespace Foam -{ - typedef PrimitivePatch bPatch; -} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -58,6 +53,8 @@ class pairPatchAgglomeration { protected: + typedef PrimitivePatch bPatch; + // Protected data //- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc. @@ -144,17 +141,19 @@ public: // Constructors - //- Construct given patch and controls + //- Construct given faces, points and control dictionary pairPatchAgglomeration ( - const indirectPrimitivePatch& patch, + const faceList& faces, + const pointField& points, const dictionary& controlDict ); //- Construct from components pairPatchAgglomeration ( - const indirectPrimitivePatch& patch, + const faceList& faces, + const pointField& points, const label mergeLevels, const label maxLevels, const label nFacesInCoarsestLevel,