mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: redistributePar: preserve zone ordering. Fixes #2120
This commit is contained in:
@ -172,6 +172,12 @@ public:
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return the index of this zone in zone list
|
||||
label& index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return a reference to the look-up map
|
||||
const Map<label>& lookupMap() const;
|
||||
|
||||
|
||||
@ -201,14 +201,24 @@ Foam::wordList Foam::fvMeshDistribute::mergeWordList(const wordList& procNames)
|
||||
List<wordList> allNames(Pstream::nProcs());
|
||||
allNames[Pstream::myProcNo()] = procNames;
|
||||
Pstream::gatherList(allNames);
|
||||
Pstream::scatterList(allNames);
|
||||
|
||||
wordHashSet mergedNames;
|
||||
forAll(allNames, proci)
|
||||
// Assume there are few zone names to merge. Use HashSet otherwise (but
|
||||
// maintain ordering)
|
||||
DynamicList<word> mergedNames;
|
||||
if (Pstream::master())
|
||||
{
|
||||
mergedNames.insert(allNames[proci]);
|
||||
mergedNames = procNames;
|
||||
for (const wordList& names : allNames)
|
||||
{
|
||||
for (const word& name : names)
|
||||
{
|
||||
mergedNames.appendUniq(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mergedNames.sortedToc();
|
||||
Pstream::scatter(mergedNames);
|
||||
|
||||
return mergedNames;
|
||||
}
|
||||
|
||||
|
||||
@ -1932,11 +1942,17 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
||||
}
|
||||
|
||||
|
||||
// Collect any zone names
|
||||
// Collect any zone names over all processors and shuffle zones accordingly
|
||||
// Note that this is not necessary for redistributePar since that already
|
||||
// checks for it. However other use (e.g. mesh generators) might not.
|
||||
const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
|
||||
const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
|
||||
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
|
||||
reorderZones<pointZone>(pointZoneNames, mesh_.pointZones());
|
||||
|
||||
const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
|
||||
reorderZones<faceZone>(faceZoneNames, mesh_.faceZones());
|
||||
|
||||
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
|
||||
reorderZones<cellZone>(cellZoneNames, mesh_.cellZones());
|
||||
|
||||
|
||||
// Local environment of all boundary faces
|
||||
|
||||
@ -97,6 +97,14 @@ class fvMeshDistribute
|
||||
//- Merge wordlists over all processors
|
||||
static wordList mergeWordList(const wordList&);
|
||||
|
||||
//- Reorder zones according to names
|
||||
template<class ZoneType, class ZoneMesh>
|
||||
void reorderZones
|
||||
(
|
||||
const wordList& zoneNames,
|
||||
ZoneMesh& zones
|
||||
);
|
||||
|
||||
|
||||
// Patch handling
|
||||
|
||||
|
||||
@ -30,6 +30,53 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class ZoneType, class ZoneMesh>
|
||||
void Foam::fvMeshDistribute::reorderZones
|
||||
(
|
||||
const wordList& zoneNames,
|
||||
ZoneMesh& zones
|
||||
)
|
||||
{
|
||||
zones.clearAddressing();
|
||||
|
||||
// Shift old ones to new position
|
||||
UPtrList<ZoneType> newZonePtrs(zoneNames.size());
|
||||
forAll(zones, zonei)
|
||||
{
|
||||
auto* zonePtr = zones.get(zonei);
|
||||
if (!zonePtr)
|
||||
{
|
||||
FatalErrorInFunction << "Problem with zones " << zones.names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
const label newIndex = zoneNames.find(zonePtr->name());
|
||||
zonePtr->index() = newIndex;
|
||||
newZonePtrs.set(newIndex, zonePtr);
|
||||
}
|
||||
|
||||
// Add empty zones for unknown ones
|
||||
forAll(newZonePtrs, i)
|
||||
{
|
||||
if (!newZonePtrs.get(i))
|
||||
{
|
||||
newZonePtrs.set
|
||||
(
|
||||
i,
|
||||
new ZoneType
|
||||
(
|
||||
zoneNames[i],
|
||||
i,
|
||||
zones
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer
|
||||
zones.swap(newZonePtrs);
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshDistribute::printIntFieldInfo(const fvMesh& mesh)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user