mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: decomposePar: added logic for preserving baffles
This commit is contained in:
@ -33,6 +33,11 @@ numberOfSubdomains 2;
|
|||||||
//singleProcessorFaceSets ((f0 -1));
|
//singleProcessorFaceSets ((f0 -1));
|
||||||
|
|
||||||
|
|
||||||
|
//- Keep owner and neighbour of baffles on same processor (i.e. keep it
|
||||||
|
// detectable as a baffle). Baffles are two boundary face sharing the
|
||||||
|
// same points.
|
||||||
|
//preserveBaffles true;
|
||||||
|
|
||||||
//- Use the volScalarField named here as a weight for each cell in the
|
//- Use the volScalarField named here as a weight for each cell in the
|
||||||
// decomposition. For example, use a particle population field to decompose
|
// decomposition. For example, use a particle population field to decompose
|
||||||
// for a balanced number of particles in a lagrangian simulation.
|
// for a balanced number of particles in a lagrangian simulation.
|
||||||
|
|||||||
@ -1209,18 +1209,19 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
|
|||||||
PtrList<labelList> specifiedProcessorFaces;
|
PtrList<labelList> specifiedProcessorFaces;
|
||||||
labelList specifiedProcessor;
|
labelList specifiedProcessor;
|
||||||
|
|
||||||
|
// Pairs of baffles
|
||||||
|
List<labelPair> couples;
|
||||||
|
|
||||||
// Constraints from decomposeParDict
|
// Constraints from decomposeParDict
|
||||||
decomposer.setConstraints
|
decomposer.setConstraints
|
||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
blockedFace,
|
blockedFace,
|
||||||
specifiedProcessorFaces,
|
specifiedProcessorFaces,
|
||||||
specifiedProcessor
|
specifiedProcessor,
|
||||||
|
couples
|
||||||
);
|
);
|
||||||
|
|
||||||
// Pairs of baffles
|
|
||||||
List<labelPair> couples;
|
|
||||||
|
|
||||||
|
|
||||||
if (keepZoneFaces || keepBaffles)
|
if (keepZoneFaces || keepBaffles)
|
||||||
{
|
{
|
||||||
@ -1314,12 +1315,43 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
|
|||||||
|
|
||||||
if (keepBaffles)
|
if (keepBaffles)
|
||||||
{
|
{
|
||||||
// Get boundary baffles that need to stay together.
|
label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
|
||||||
couples = getDuplicateFaces // all baffles
|
|
||||||
|
labelList coupledFace(mesh_.nFaces(), -1);
|
||||||
|
{
|
||||||
|
// Get boundary baffles that need to stay together
|
||||||
|
List<labelPair> allCouples = getDuplicateFaces
|
||||||
(
|
(
|
||||||
identity(mesh_.nFaces()-mesh_.nInternalFaces())
|
identity(nBnd)
|
||||||
+mesh_.nInternalFaces()
|
+mesh_.nInternalFaces()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Merge with any couples from
|
||||||
|
// decompositionMethod::setConstraints
|
||||||
|
forAll(couples, i)
|
||||||
|
{
|
||||||
|
const labelPair& baffle = couples[i];
|
||||||
|
coupledFace[baffle.first()] = baffle.second();
|
||||||
|
coupledFace[baffle.second()] = baffle.first();
|
||||||
|
}
|
||||||
|
forAll(allCouples, i)
|
||||||
|
{
|
||||||
|
const labelPair& baffle = allCouples[i];
|
||||||
|
coupledFace[baffle.first()] = baffle.second();
|
||||||
|
coupledFace[baffle.second()] = baffle.first();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
couples.setSize(nBnd);
|
||||||
|
label nCpl = 0;
|
||||||
|
forAll(coupledFace, faceI)
|
||||||
|
{
|
||||||
|
if (coupledFace[faceI] != -1 && faceI < coupledFace[faceI])
|
||||||
|
{
|
||||||
|
couples[nCpl++] = labelPair(faceI, coupledFace[faceI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
couples.setSize(nCpl);
|
||||||
}
|
}
|
||||||
label nCouples = returnReduce(couples.size(), sumOp<label>());
|
label nCouples = returnReduce(couples.size(), sumOp<label>());
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||||
|
|
||||||
LIB_LIBS = \
|
LIB_LIBS = \
|
||||||
-lmeshTools \
|
-lmeshTools \
|
||||||
|
-ldynamicMesh \
|
||||||
-lfiniteVolume
|
-lfiniteVolume
|
||||||
|
|||||||
@ -32,6 +32,7 @@ InClass
|
|||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "faceSet.H"
|
#include "faceSet.H"
|
||||||
#include "regionSplit.H"
|
#include "regionSplit.H"
|
||||||
|
#include "localPointRegion.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -984,15 +985,16 @@ void Foam::decompositionMethod::setConstraints
|
|||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
boolList& blockedFace,
|
boolList& blockedFace,
|
||||||
PtrList<labelList>& specifiedProcessorFaces,
|
PtrList<labelList>& specifiedProcessorFaces,
|
||||||
labelList& specifiedProcessor
|
labelList& specifiedProcessor,
|
||||||
|
List<labelPair>& explicitConnections
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
blockedFace.setSize(mesh.nFaces());
|
blockedFace.setSize(mesh.nFaces());
|
||||||
blockedFace = true;
|
blockedFace = true;
|
||||||
label nUnblocked = 0;
|
//label nUnblocked = 0;
|
||||||
|
|
||||||
specifiedProcessorFaces.clear();
|
specifiedProcessorFaces.clear();
|
||||||
specifiedProcessor.setSize(0);
|
explicitConnections.clear();
|
||||||
|
|
||||||
|
|
||||||
if (decompositionDict_.found("preservePatches"))
|
if (decompositionDict_.found("preservePatches"))
|
||||||
@ -1024,7 +1026,7 @@ void Foam::decompositionMethod::setConstraints
|
|||||||
if (blockedFace[pp.start() + i])
|
if (blockedFace[pp.start() + i])
|
||||||
{
|
{
|
||||||
blockedFace[pp.start() + i] = false;
|
blockedFace[pp.start() + i] = false;
|
||||||
nUnblocked++;
|
//nUnblocked++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1058,20 +1060,103 @@ void Foam::decompositionMethod::setConstraints
|
|||||||
if (blockedFace[fz[i]])
|
if (blockedFace[fz[i]])
|
||||||
{
|
{
|
||||||
blockedFace[fz[i]] = false;
|
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
|
if
|
||||||
(
|
(
|
||||||
decompositionDict_.found("preservePatches")
|
decompositionDict_.found("preservePatches")
|
||||||
|| decompositionDict_.found("preserveFaceZones")
|
|| decompositionDict_.found("preserveFaceZones")
|
||||||
|
|| preserveBaffles
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
syncTools::syncFaceList(mesh, blockedFace, andEqOp<bool>());
|
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;
|
boolList blockedFace;
|
||||||
PtrList<labelList> specifiedProcessorFaces;
|
PtrList<labelList> specifiedProcessorFaces;
|
||||||
labelList specifiedProcessor;
|
labelList specifiedProcessor;
|
||||||
|
List<labelPair> explicitConnections;
|
||||||
setConstraints
|
setConstraints
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
blockedFace,
|
blockedFace,
|
||||||
specifiedProcessorFaces,
|
specifiedProcessorFaces,
|
||||||
specifiedProcessor
|
specifiedProcessor,
|
||||||
|
explicitConnections
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -1322,7 +1409,7 @@ Foam::labelList Foam::decompositionMethod::decompose
|
|||||||
blockedFace, // any cells to be combined
|
blockedFace, // any cells to be combined
|
||||||
specifiedProcessorFaces,// any whole cluster of cells to be kept
|
specifiedProcessorFaces,// any whole cluster of cells to be kept
|
||||||
specifiedProcessor,
|
specifiedProcessor,
|
||||||
List<labelPair>() // no baffles
|
explicitConnections // baffles
|
||||||
);
|
);
|
||||||
|
|
||||||
return finalDecomp;
|
return finalDecomp;
|
||||||
|
|||||||
@ -256,13 +256,19 @@ public:
|
|||||||
//);
|
//);
|
||||||
|
|
||||||
|
|
||||||
//- Helper: extract constraints
|
//- Helper: extract constraints:
|
||||||
|
// blockedface: existing faces where owner and neighbour on same
|
||||||
|
// proc
|
||||||
|
// explicitConnections: sets of boundary faces ,, ,,
|
||||||
|
// specifiedProcessorFaces: groups of faces with all cells on
|
||||||
|
// same processor.
|
||||||
void setConstraints
|
void setConstraints
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
boolList& blockedFace,
|
boolList& blockedFace,
|
||||||
PtrList<labelList>& specifiedProcessorFaces,
|
PtrList<labelList>& specifiedProcessorFaces,
|
||||||
labelList& specifiedProcessor
|
labelList& specifiedProcessor,
|
||||||
|
List<labelPair>& explicitConnections
|
||||||
);
|
);
|
||||||
|
|
||||||
// Decompose a mesh with constraints:
|
// Decompose a mesh with constraints:
|
||||||
|
|||||||
Reference in New Issue
Block a user