Commit 87056a23 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: pairPatchAgglomeration - updated constructors

parent 56071431
......@@ -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<const coupledPolyPatch>(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;
}
}
......
......@@ -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_);
......
......@@ -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
......
......@@ -40,11 +40,6 @@ SourceFiles
#include "List.H"
#include "EdgeMap.H"
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField> bPatch;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -58,6 +53,8 @@ class pairPatchAgglomeration
{
protected:
typedef PrimitivePatch<face, List, const pointField> 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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment