ENH: pairPatchAgglomeration - updated constructors

This commit is contained in:
Andrew Heather
2016-12-07 09:25:42 +00:00
parent 56071431ac
commit 87056a2308
4 changed files with 61 additions and 61 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,7 +69,6 @@ int main(int argc, char *argv[])
bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration")); bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration"));
const polyBoundaryMesh& boundary = mesh.boundaryMesh(); const polyBoundaryMesh& boundary = mesh.boundaryMesh();
labelListIOList finalAgglom labelListIOList finalAgglom
@ -95,15 +94,20 @@ int main(int argc, char *argv[])
{ {
label patchi = patchids[i]; label patchi = patchids[i];
const polyPatch& pp = boundary[patchi]; const polyPatch& pp = boundary[patchi];
if (!pp.coupled()) if (!pp.coupled())
{ {
Info << "\nAgglomerating patch : " << pp.name() << endl; Info << "\nAgglomerating patch : " << pp.name() << endl;
pairPatchAgglomeration agglomObject pairPatchAgglomeration agglomObject
( (
pp, pp.localFaces(),
pp.localPoints(),
agglomDict.subDict(pp.name()) agglomDict.subDict(pp.name())
); );
agglomObject.agglomerate(); agglomObject.agglomerate();
finalAgglom[patchi] = finalAgglom[patchi] =
agglomObject.restrictTopBottomAddressing(); agglomObject.restrictTopBottomAddressing();
@ -116,42 +120,42 @@ int main(int argc, char *argv[])
} }
// - All patches which are not agglomarated are identity for finalAgglom // All patches which are not agglomerated are identity for finalAgglom
forAll(boundary, patchid) 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 // Sync agglomeration across coupled patches
labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1); 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()) if (pp.coupled())
{ {
finalAgglom[patchid] = identity(pp.size()); finalAgglom[patchi] = identity(pp.size());
forAll(pp, i) forAll(pp, i)
{ {
nbrAgglom[pp.start() - mesh.nInternalFaces() + i] = const label agglomi = pp.start() - mesh.nInternalFaces() + i;
finalAgglom[patchid][i]; nbrAgglom[agglomi] = finalAgglom[patchi][i];
} }
} }
} }
syncTools::swapBoundaryFaceList(mesh, nbrAgglom); syncTools::swapBoundaryFaceList(mesh, nbrAgglom);
forAll(boundary, patchid) forAll(boundary, patchi)
{ {
const polyPatch& pp = boundary[patchid]; const polyPatch& pp = boundary[patchi];
if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner()) if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner())
{ {
forAll(pp, i) forAll(pp, i)
{ {
finalAgglom[patchid][i] = const label agglomi = pp.start() - mesh.nInternalFaces() + i
nbrAgglom[pp.start() - mesh.nInternalFaces() + i]; finalAgglom[patchi][i] = nbrAgglom[agglomi];
} }
} }
} }
@ -179,13 +183,13 @@ int main(int argc, char *argv[])
facesAgglomeration.boundaryFieldRef(); facesAgglomeration.boundaryFieldRef();
label coarsePatchIndex = 0; label coarsePatchIndex = 0;
forAll(boundary, patchid) forAll(boundary, patchi)
{ {
const polyPatch& pp = boundary[patchid]; const polyPatch& pp = boundary[patchi];
if (pp.size() > 0) if (pp.size() > 0)
{ {
fvPatchScalarField& bFacesAgglomeration = fvPatchScalarField& bFacesAgglomeration =
facesAgglomerationBf[patchid]; facesAgglomerationBf[patchi];
forAll(bFacesAgglomeration, j) forAll(bFacesAgglomeration, j)
{ {
@ -193,11 +197,11 @@ int main(int argc, char *argv[])
index.toGlobal index.toGlobal
( (
Pstream::myProcNo(), Pstream::myProcNo(),
finalAgglom[patchid][j] + coarsePatchIndex finalAgglom[patchi][j] + coarsePatchIndex
); );
} }
coarsePatchIndex += max(finalAgglom[patchid]) + 1; coarsePatchIndex += max(finalAgglom[patchi]) + 1;
} }
} }

View File

@ -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(); ppa.agglomerate();
label nCoarseFaces = 0; label nCoarseFaces = 0;
@ -601,11 +611,11 @@ bool Foam::functionObjects::extractEulerianParticles::read
{ {
dict.lookup("faceZone") >> faceZoneName_; dict.lookup("faceZone") >> faceZoneName_;
dict.readIfPresent("nLocations", nInjectorLocations_); dict.readIfPresent("nLocations", nInjectorLocations_);
dict.lookup("alphaName") >> alphaName_; dict.lookup("alpha") >> alphaName_;
dict.readIfPresent("alphaThreshold", alphaThreshold_); dict.readIfPresent("alphaThreshold", alphaThreshold_);
dict.lookup("UName") >> UName_; dict.lookup("U") >> UName_;
dict.lookup("rhoName") >> rhoName_; dict.lookup("rho") >> rhoName_;
dict.lookup("phiName") >> phiName_; dict.lookup("phi") >> phiName_;
dict.readIfPresent("minDiameter", minDiameter_); dict.readIfPresent("minDiameter", minDiameter_);
dict.readIfPresent("maxDiameter", maxDiameter_); dict.readIfPresent("maxDiameter", maxDiameter_);

View File

@ -195,7 +195,8 @@ void Foam::pairPatchAgglomeration::setEdgeWeights
Foam::pairPatchAgglomeration::pairPatchAgglomeration Foam::pairPatchAgglomeration::pairPatchAgglomeration
( (
const indirectPrimitivePatch& patch, const faceList& faces,
const pointField& points,
const dictionary& controlDict const dictionary& controlDict
) )
: :
@ -218,23 +219,15 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration
), ),
nFaces_(maxLevels_), nFaces_(maxLevels_),
restrictAddressing_(maxLevels_), restrictAddressing_(maxLevels_),
restrictTopBottomAddressing_(identity(patch.size())), restrictTopBottomAddressing_(identity(faces.size())),
patchLevels_(maxLevels_), patchLevels_(maxLevels_),
facePairWeight_(patch.size()) facePairWeight_(faces.size())
{ {
// Set base fine patch // Set base fine patch
patchLevels_.set patchLevels_.set(0, new bPatch(faces, points));
(
0,
new bPatch
(
patch.localFaces(),
patch.localPoints()
)
);
// Set number of faces for the base patch // Set number of faces for the base patch
nFaces_[0] = patch.size(); nFaces_[0] = faces.size();
// Set edge weights for level 0 // Set edge weights for level 0
setLevel0EdgeWeights(); setLevel0EdgeWeights();
@ -243,7 +236,8 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration
Foam::pairPatchAgglomeration::pairPatchAgglomeration Foam::pairPatchAgglomeration::pairPatchAgglomeration
( (
const indirectPrimitivePatch& patch, const faceList& faces,
const pointField& points,
const label mergeLevels, const label mergeLevels,
const label maxLevels, const label maxLevels,
const label nFacesInCoarsestLevel, // local number of cells const label nFacesInCoarsestLevel, // local number of cells
@ -258,23 +252,15 @@ Foam::pairPatchAgglomeration::pairPatchAgglomeration
featureAngle_(featureAngle), featureAngle_(featureAngle),
nFaces_(maxLevels_), nFaces_(maxLevels_),
restrictAddressing_(maxLevels_), restrictAddressing_(maxLevels_),
restrictTopBottomAddressing_(identity(patch.size())), restrictTopBottomAddressing_(identity(faces.size())),
patchLevels_(maxLevels_), patchLevels_(maxLevels_),
facePairWeight_(patch.size()) facePairWeight_(faces.size())
{ {
// Set base fine patch // Set base fine patch
patchLevels_.set patchLevels_.set(0, new bPatch(faces, points));
(
0,
new bPatch
(
patch.localFaces(),
patch.localPoints()
)
);
// Set number of faces for the base patch // Set number of faces for the base patch
nFaces_[0] = patch.size(); nFaces_[0] = faces.size();
// Set edge weights for level 0 // Set edge weights for level 0
setLevel0EdgeWeights(); setLevel0EdgeWeights();
@ -289,7 +275,8 @@ Foam::pairPatchAgglomeration::~pairPatchAgglomeration()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::bPatch& Foam::pairPatchAgglomeration::patchLevel const Foam::pairPatchAgglomeration::bPatch&
Foam::pairPatchAgglomeration::patchLevel
( (
const label i const label i
) const ) const

View File

@ -40,11 +40,6 @@ SourceFiles
#include "List.H" #include "List.H"
#include "EdgeMap.H" #include "EdgeMap.H"
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField> bPatch;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -58,6 +53,8 @@ class pairPatchAgglomeration
{ {
protected: protected:
typedef PrimitivePatch<face, List, const pointField> bPatch;
// Protected data // Protected data
//- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc. //- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
@ -144,17 +141,19 @@ public:
// Constructors // Constructors
//- Construct given patch and controls //- Construct given faces, points and control dictionary
pairPatchAgglomeration pairPatchAgglomeration
( (
const indirectPrimitivePatch& patch, const faceList& faces,
const pointField& points,
const dictionary& controlDict const dictionary& controlDict
); );
//- Construct from components //- Construct from components
pairPatchAgglomeration pairPatchAgglomeration
( (
const indirectPrimitivePatch& patch, const faceList& faces,
const pointField& points,
const label mergeLevels, const label mergeLevels,
const label maxLevels, const label maxLevels,
const label nFacesInCoarsestLevel, const label nFacesInCoarsestLevel,