processorPolyPatch, processorCyclicPolyPatch: Rationalized the construction of the patch name

This change ensures that these patches are named consistently so that
they can be looked-up as required in e.g. patchMeanVelocityForce
This commit is contained in:
Henry Weller
2016-02-02 20:07:16 +00:00
parent fd6aed1b6c
commit 644d51b466
13 changed files with 139 additions and 121 deletions

View File

@ -2,7 +2,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -540,24 +540,15 @@ int main(int argc, char *argv[])
{ {
label nbrProcI = patchToNbrProc[patchI]; label nbrProcI = patchToNbrProc[patchI];
word name =
"procBoundary"
+ Foam::name(Pstream::myProcNo())
+ "to"
+ Foam::name(nbrProcI);
Pout<< "Adding patch " << patchI Pout<< "Adding patch " << patchI
<< " name:" << name
<< " between " << Pstream::myProcNo() << " between " << Pstream::myProcNo()
<< " and " << nbrProcI << " and " << nbrProcI
<< endl; << endl;
newPatches.append newPatches.append
( (
new processorPolyPatch new processorPolyPatch
( (
name,
0, // size 0, // size
mesh.nFaces(), // start mesh.nFaces(), // start
patchI, // index patchI, // index

View File

@ -955,13 +955,11 @@ void addCoupledPatches
} }
else else
{ {
// Rrocessor patch // Processor patch
word name
word name = (
"procBoundary" processorPolyPatch::newName(Pstream::myProcNo(), nbrProcI)
+ Foam::name(Pstream::myProcNo()) );
+ "to"
+ Foam::name(nbrProcI);
sidePatchID[edgeI] = findPatchID(newPatches, name); sidePatchID[edgeI] = findPatchID(newPatches, name);

View File

@ -1631,10 +1631,7 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
if (procUsed[pUI]) if (procUsed[pUI])
{ {
patchNames[nNonProcPatches + procAddI] = patchNames[nNonProcPatches + procAddI] =
"procBoundary" processorPolyPatch::newName(Pstream::myProcNo(), pUI);
+ name(Pstream::myProcNo())
+ "to"
+ name(pUI);
patchDicts[nNonProcPatches + procAddI].set patchDicts[nNonProcPatches + procAddI].set
( (

View File

@ -432,7 +432,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
{ {
patches[patchI] = new processorPolyPatch patches[patchI] = new processorPolyPatch
( (
patchNames[patchI],
0, //patchSizes[p], 0, //patchSizes[p],
0, //patchStarts[p], 0, //patchStarts[p],
patchI, patchI,

View File

@ -444,29 +444,12 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
label nInterProcPatches = 0; label nInterProcPatches = 0;
forAll(curSubPatchIDs, procPatchI) forAll(curSubPatchIDs, procPatchI)
{ {
//Info<< "For processor " << procI
// << " have to destination processor "
// << curNeighbourProcessors[procPatchI] << endl;
//
//forAll(curSubPatchIDs[procPatchI], i)
//{
// Info<< " from patch:" << curSubPatchIDs[procPatchI][i]
// << " starting at:" << curSubStarts[procPatchI][i]
// << endl;
//}
nInterProcPatches += curSubPatchIDs[procPatchI].size(); nInterProcPatches += curSubPatchIDs[procPatchI].size();
} }
//Info<< "For processor " << procI
// << " have " << nInterProcPatches
// << " patches to neighbouring processors" << endl;
List<polyPatch*> procPatches List<polyPatch*> procPatches
( (
curPatchSizes.size() curPatchSizes.size() + nInterProcPatches,
+ nInterProcPatches, //curProcessorPatchSizes.size(),
reinterpret_cast<polyPatch*>(0) reinterpret_cast<polyPatch*>(0)
); );
@ -517,22 +500,12 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
: curProcessorPatchSizes[procPatchI] - subStarts[i] : curProcessorPatchSizes[procPatchI] - subStarts[i]
); );
// Info<< "From processor:" << procI << endl
// << " to processor:" << curNeighbourProcessors[procPatchI]
// << endl
// << " via patch:" << subPatchID[i] << endl
// << " start :" << curStart << endl
// << " size :" << size << endl;
if (subPatchID[i] == -1) if (subPatchID[i] == -1)
{ {
// From internal faces // From internal faces
procPatches[nPatches] = procPatches[nPatches] =
new processorPolyPatch new processorPolyPatch
( (
word("procBoundary") + Foam::name(procI)
+ "to"
+ Foam::name(curNeighbourProcessors[procPatchI]),
size, size,
curStart, curStart,
nPatches, nPatches,
@ -549,24 +522,16 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
boundaryMesh()[subPatchID[i]] boundaryMesh()[subPatchID[i]]
); );
// From cyclic
const word& referPatch = pcPatch.name();
procPatches[nPatches] = procPatches[nPatches] =
new processorCyclicPolyPatch new processorCyclicPolyPatch
( (
word("procBoundary") + Foam::name(procI)
+ "to"
+ Foam::name(curNeighbourProcessors[procPatchI])
+ "through"
+ referPatch,
size, size,
curStart, curStart,
nPatches, nPatches,
procMesh.boundaryMesh(), procMesh.boundaryMesh(),
procI, procI,
curNeighbourProcessors[procPatchI], curNeighbourProcessors[procPatchI],
referPatch, pcPatch.name(),
pcPatch.transform() pcPatch.transform()
); );
} }
@ -577,16 +542,6 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
} }
} }
//forAll(procPatches, patchI)
//{
// Pout<< " " << patchI
// << '\t' << "name:" << procPatches[patchI]->name()
// << '\t' << "type:" << procPatches[patchI]->type()
// << '\t' << "size:" << procPatches[patchI]->size()
// << endl;
//}
// Add boundary patches // Add boundary patches
procMesh.addPatches(procPatches); procMesh.addPatches(procPatches);

View File

@ -161,12 +161,9 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
for (label mergedProcI = 0; mergedProcI < procI; mergedProcI++) for (label mergedProcI = 0; mergedProcI < procI; mergedProcI++)
{ {
const string fromProcString const word fromProcString
( (
"procBoundary" processorPolyPatch::newName(procI, mergedProcI)
+ name(procI)
+ "to"
+ name(mergedProcI)
); );
if (pp.name() == fromProcString) if (pp.name() == fromProcString)

View File

@ -2,7 +2,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,6 +69,36 @@ Foam::processorPolyPatch::processorPolyPatch
{} {}
Foam::processorPolyPatch::processorPolyPatch
(
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm,
const int myProcNo,
const int neighbProcNo,
const transformType transform,
const word& patchType
)
:
coupledPolyPatch
(
newName(myProcNo, neighbProcNo),
size,
start,
index,
bm,
patchType,
transform
),
myProcNo_(myProcNo),
neighbProcNo_(neighbProcNo),
neighbFaceCentres_(),
neighbFaceAreas_(),
neighbFaceCellCentres_()
{}
Foam::processorPolyPatch::processorPolyPatch Foam::processorPolyPatch::processorPolyPatch
( (
const word& name, const word& name,
@ -149,6 +179,20 @@ Foam::processorPolyPatch::~processorPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::word Foam::processorPolyPatch::newName
(
const label myProcNo,
const label neighbProcNo
)
{
return
"procBoundary"
+ Foam::name(myProcNo)
+ "to"
+ Foam::name(neighbProcNo);
}
void Foam::processorPolyPatch::initGeometry(PstreamBuffers& pBufs) void Foam::processorPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
if (Pstream::parRun()) if (Pstream::parRun())

View File

@ -2,7 +2,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -81,6 +81,23 @@ class processorPolyPatch
protected: protected:
// Protected constructors
//- Construct from components with specified name
processorPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm,
const int myProcNo,
const int neighbProcNo,
const transformType transform = UNKNOWN, // transformation type
const word& patchType = typeName
);
// Protected Member functions // Protected Member functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
@ -126,10 +143,9 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components with automatically generated standard name
processorPolyPatch processorPolyPatch
( (
const word& name,
const label size, const label size,
const label start, const label start,
const label index, const label index,
@ -270,6 +286,14 @@ public:
return !owner(); return !owner();
} }
//- Return the name of a processorPolyPatch
// constructed from the processor IDs
static word newName
(
const label myProcNo,
const label neighbProcNo
);
//- Return processor-neighbbour patch face centres //- Return processor-neighbbour patch face centres
const vectorField& neighbFaceCentres() const const vectorField& neighbFaceCentres() const
{ {

View File

@ -2,7 +2,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,7 +41,6 @@ namespace Foam
Foam::processorCyclicPolyPatch::processorCyclicPolyPatch Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
( (
const word& name,
const label size, const label size,
const label start, const label start,
const label index, const label index,
@ -55,7 +54,7 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
: :
processorPolyPatch processorPolyPatch
( (
name, newName(referPatchName, myProcNo, neighbProcNo),
size, size,
start, start,
index, index,
@ -157,6 +156,33 @@ Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::word Foam::processorCyclicPolyPatch::newName
(
const word& cyclicPolyPatchName,
const label myProcNo,
const label neighbProcNo
)
{
return
processorPolyPatch::newName(myProcNo, neighbProcNo)
+ "through"
+ cyclicPolyPatchName;
}
Foam::labelList Foam::processorCyclicPolyPatch::patchIDs
(
const word& cyclicPolyPatchName,
const polyBoundaryMesh& bm
)
{
return bm.findIndices
(
string("procBoundary.*to.*through" + cyclicPolyPatchName)
);
}
int Foam::processorCyclicPolyPatch::tag() const int Foam::processorCyclicPolyPatch::tag() const
{ {
if (tag_ == -1) if (tag_ == -1)

View File

@ -2,7 +2,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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -114,7 +114,6 @@ public:
//- Construct from components //- Construct from components
processorCyclicPolyPatch processorCyclicPolyPatch
( (
const word& name,
const label size, const label size,
const label start, const label start,
const label index, const label index,
@ -261,11 +260,29 @@ public:
// Member functions // Member functions
//- Return name of originating cyclicPolyPatch patch
const word& referPatchName() const const word& referPatchName() const
{ {
return referPatchName_; return referPatchName_;
} }
//- Return the name of a processorCyclicPolyPatch
// constructed from cyclicPolyPatch name and the processor IDs
static word newName
(
const word& cyclicPolyPatchName,
const label myProcNo,
const label neighbProcNo
);
//- Return the indices of a processorCyclicPolyPatchs
// constructed from the given cyclicPolyPatch
static labelList patchIDs
(
const word& cyclicPolyPatchName,
const polyBoundaryMesh& bm
);
//- Referring patchID. //- Referring patchID.
label referPatchID() const label referPatchID() const
{ {

View File

@ -45,7 +45,7 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(fvMeshDistribute, 0); defineTypeNameAndDebug(fvMeshDistribute, 0);
} }
@ -929,16 +929,8 @@ void Foam::fvMeshDistribute::addProcPatches
if (referPatchID[bFaceI] == -1) if (referPatchID[bFaceI] == -1)
{ {
// Ordinary processor boundary // Ordinary processor boundary
const word patchName =
"procBoundary"
+ name(Pstream::myProcNo())
+ "to"
+ name(procI);
processorPolyPatch pp processorPolyPatch pp
( (
patchName,
0, // size 0, // size
mesh_.nFaces(), mesh_.nFaces(),
mesh_.boundaryMesh().size(), mesh_.boundaryMesh().size(),
@ -968,27 +960,15 @@ void Foam::fvMeshDistribute::addProcPatches
mesh_.boundaryMesh()[referPatchID[bFaceI]] mesh_.boundaryMesh()[referPatchID[bFaceI]]
); );
// Processor boundary originating from cyclic
const word& cycName = pcPatch.name();
const word patchName =
"procBoundary"
+ name(Pstream::myProcNo())
+ "to"
+ name(procI)
+ "through"
+ cycName;
processorCyclicPolyPatch pp processorCyclicPolyPatch pp
( (
patchName,
0, // size 0, // size
mesh_.nFaces(), mesh_.nFaces(),
mesh_.boundaryMesh().size(), mesh_.boundaryMesh().size(),
mesh_.boundaryMesh(), mesh_.boundaryMesh(),
Pstream::myProcNo(), Pstream::myProcNo(),
nbrProc[bFaceI], nbrProc[bFaceI],
cycName, pcPatch.name(),
pcPatch.transform() pcPatch.transform()
); );

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "patchMeanVelocityForce.H" #include "patchMeanVelocityForce.H"
#include "processorCyclicPolyPatch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -92,14 +93,9 @@ Foam::scalar Foam::fv::patchMeanVelocityForce::magUbarAve
if (Pstream::parRun() && isA<cyclicPolyPatch>(patches[patchi_])) if (Pstream::parRun() && isA<cyclicPolyPatch>(patches[patchi_]))
{ {
const keyType processorCyclicPatchNames
(
string("procBoundary.*to.*through" + patch_)
);
labelList processorCyclicPatches labelList processorCyclicPatches
( (
patches.findIndices(processorCyclicPatchNames) processorCyclicPolyPatch::patchIDs(patch_, patches)
); );
forAll(processorCyclicPatches, pcpi) forAll(processorCyclicPatches, pcpi)

View File

@ -1018,11 +1018,10 @@ void Foam::autoLayerDriver::determineSidePatches
for (label patchI = nOldPatches; patchI < nPatches; patchI++) for (label patchI = nOldPatches; patchI < nPatches; patchI++)
{ {
label nbrProcI = patchToNbrProc[patchI]; label nbrProcI = patchToNbrProc[patchI];
word name = word name
"procBoundary" (
+ Foam::name(Pstream::myProcNo()) processorPolyPatch::newName(Pstream::myProcNo(), nbrProcI)
+ "to" );
+ Foam::name(nbrProcI);
dictionary patchDict; dictionary patchDict;
patchDict.add("type", processorPolyPatch::typeName); patchDict.add("type", processorPolyPatch::typeName);
@ -1031,11 +1030,6 @@ void Foam::autoLayerDriver::determineSidePatches
patchDict.add("nFaces", 0); patchDict.add("nFaces", 0);
patchDict.add("startFace", mesh.nFaces()); patchDict.add("startFace", mesh.nFaces());
//Pout<< "Adding patch " << patchI
// << " name:" << name
// << " between " << Pstream::myProcNo()
// << " and " << nbrProcI << endl;
label procPatchI = meshRefiner_.appendPatch label procPatchI = meshRefiner_.appendPatch
( (
mesh, mesh,