mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Allow a weightField volScalarField to be specified in decomposeParDict.
Weights the cells in the decomposition.
This commit is contained in:
@ -19,15 +19,17 @@ FoamFile
|
||||
|
||||
numberOfSubdomains 8;
|
||||
|
||||
|
||||
//- Keep owner and neighbour on same processor for faces in zones:
|
||||
// preserveFaceZones (heater solid1 solid3);
|
||||
|
||||
|
||||
//- Keep owner and neighbour on same processor for faces in patches:
|
||||
// (makes sense only for cyclic patches)
|
||||
//preservePatches (cyclic_half0 cyclic_half1);
|
||||
|
||||
//- Use the volScalarField named here as a weight for each cell in the
|
||||
// decomposition. For example, use a particle population field to decompose
|
||||
// for a balanced number of particles in a lagrangian simulation.
|
||||
// weightField dsmcRhoNMean;
|
||||
|
||||
method scotch;
|
||||
// method hierarchical;
|
||||
@ -59,11 +61,8 @@ multiLevelCoeffs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Desired output
|
||||
|
||||
|
||||
|
||||
simpleCoeffs
|
||||
{
|
||||
n (2 1 1);
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "domainDecomposition.H"
|
||||
#include "Time.H"
|
||||
#include "dictionary.H"
|
||||
#include "labelIOList.H"
|
||||
#include "processorPolyPatch.H"
|
||||
|
||||
@ -41,6 +41,9 @@ SourceFiles
|
||||
#include "SLList.H"
|
||||
#include "PtrList.H"
|
||||
#include "point.H"
|
||||
#include "Time.H"
|
||||
#include "volFields.H"
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
@ -113,9 +113,37 @@ void Foam::domainDecomposition::distributeCells()
|
||||
);
|
||||
|
||||
if (sameProcFaces.empty())
|
||||
{
|
||||
if (decompositionDict_.found("weightField"))
|
||||
{
|
||||
word weightName = decompositionDict_.lookup("weightField");
|
||||
|
||||
volScalarField weights
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
weightName,
|
||||
time().timeName(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
*this
|
||||
);
|
||||
|
||||
cellToProc_ = decomposePtr().decompose
|
||||
(
|
||||
*this,
|
||||
cellCentres(),
|
||||
weights.internalField()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellToProc_ = decomposePtr().decompose(*this, cellCentres());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Selected " << sameProcFaces.size()
|
||||
@ -173,6 +201,42 @@ void Foam::domainDecomposition::distributeCells()
|
||||
|
||||
// Do decomposition on agglomeration
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (decompositionDict_.found("weightField"))
|
||||
{
|
||||
scalarField regionWeights(globalRegion.nRegions(), 0);
|
||||
|
||||
word weightName = decompositionDict_.lookup("weightField");
|
||||
|
||||
volScalarField weights
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
weightName,
|
||||
time().timeName(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
*this
|
||||
);
|
||||
|
||||
forAll(globalRegion, cellI)
|
||||
{
|
||||
label regionI = globalRegion[cellI];
|
||||
|
||||
regionWeights[regionI] += weights.internalField()[cellI];
|
||||
}
|
||||
|
||||
cellToProc_ = decomposePtr().decompose
|
||||
(
|
||||
*this,
|
||||
globalRegion,
|
||||
regionCentres,
|
||||
regionWeights
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellToProc_ = decomposePtr().decompose
|
||||
(
|
||||
*this,
|
||||
@ -180,6 +244,7 @@ void Foam::domainDecomposition::distributeCells()
|
||||
regionCentres
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nFinished decomposition in "
|
||||
<< decompositionTime.elapsedCpuTime()
|
||||
|
||||
Reference in New Issue
Block a user