ENH: decomposePar: added logic for preserving baffles

This commit is contained in:
mattijs
2013-08-07 11:03:01 +01:00
parent 431fea9844
commit f9139aa031
5 changed files with 152 additions and 20 deletions

View File

@ -32,6 +32,7 @@ InClass
#include "Tuple2.H"
#include "faceSet.H"
#include "regionSplit.H"
#include "localPointRegion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -984,15 +985,16 @@ void Foam::decompositionMethod::setConstraints
const polyMesh& mesh,
boolList& blockedFace,
PtrList<labelList>& specifiedProcessorFaces,
labelList& specifiedProcessor
labelList& specifiedProcessor,
List<labelPair>& explicitConnections
)
{
blockedFace.setSize(mesh.nFaces());
blockedFace = true;
label nUnblocked = 0;
//label nUnblocked = 0;
specifiedProcessorFaces.clear();
specifiedProcessor.setSize(0);
explicitConnections.clear();
if (decompositionDict_.found("preservePatches"))
@ -1024,7 +1026,7 @@ void Foam::decompositionMethod::setConstraints
if (blockedFace[pp.start() + i])
{
blockedFace[pp.start() + i] = false;
nUnblocked++;
//nUnblocked++;
}
}
}
@ -1058,20 +1060,103 @@ void Foam::decompositionMethod::setConstraints
if (blockedFace[fz[i]])
{
blockedFace[fz[i]] = false;
nUnblocked++;
//nUnblocked++;
}
}
}
}
bool preserveBaffles = decompositionDict_.lookupOrDefault
(
"preserveBaffles",
false
);
if (preserveBaffles)
{
Info<< nl
<< "Keeping owner of faces in baffles "
<< " on same processor." << endl;
// Faces to test: all boundary faces
labelList testFaces
(
identity(mesh.nFaces()-mesh.nInternalFaces())
+ mesh.nInternalFaces()
);
// Find correspondencing baffle face (or -1)
labelList duplicateFace
(
localPointRegion::findDuplicateFaces
(
mesh,
testFaces
)
);
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Convert into list of coupled face pairs (mesh face labels).
explicitConnections.setSize(testFaces.size());
label dupI = 0;
forAll(duplicateFace, i)
{
label otherFaceI = duplicateFace[i];
if (otherFaceI != -1 && i < otherFaceI)
{
label meshFace0 = testFaces[i];
label patch0 = patches.whichPatch(meshFace0);
label meshFace1 = testFaces[otherFaceI];
label patch1 = patches.whichPatch(meshFace1);
// Check for illegal topology. Should normally not happen!
if
(
(patch0 != -1 && isA<processorPolyPatch>(patches[patch0]))
|| (patch1 != -1 && isA<processorPolyPatch>(patches[patch1]))
)
{
FatalErrorIn
(
"decompositionMethod::decompose(const polyMesh&)"
) << "One of two duplicate faces is on"
<< " processorPolyPatch."
<< "This is not allowed." << nl
<< "Face:" << meshFace0
<< " is on patch:" << patches[patch0].name()
<< nl
<< "Face:" << meshFace1
<< " is on patch:" << patches[patch1].name()
<< abort(FatalError);
}
explicitConnections[dupI++] = labelPair(meshFace0, meshFace1);
if (blockedFace[meshFace0])
{
blockedFace[meshFace0] = false;
//nUnblocked++;
}
if (blockedFace[meshFace1])
{
blockedFace[meshFace1] = false;
//nUnblocked++;
}
}
}
explicitConnections.setSize(dupI);
}
if
(
decompositionDict_.found("preservePatches")
|| decompositionDict_.found("preserveFaceZones")
|| preserveBaffles
)
{
syncTools::syncFaceList(mesh, blockedFace, andEqOp<bool>());
reduce(nUnblocked, sumOp<label>());
//reduce(nUnblocked, sumOp<label>());
}
@ -1303,12 +1388,14 @@ Foam::labelList Foam::decompositionMethod::decompose
boolList blockedFace;
PtrList<labelList> specifiedProcessorFaces;
labelList specifiedProcessor;
List<labelPair> explicitConnections;
setConstraints
(
mesh,
blockedFace,
specifiedProcessorFaces,
specifiedProcessor
specifiedProcessor,
explicitConnections
);
@ -1322,7 +1409,7 @@ Foam::labelList Foam::decompositionMethod::decompose
blockedFace, // any cells to be combined
specifiedProcessorFaces,// any whole cluster of cells to be kept
specifiedProcessor,
List<labelPair>() // no baffles
explicitConnections // baffles
);
return finalDecomp;