Commit e8e0cfb4 authored by mattijs's avatar mattijs
Browse files

ENH: mergeMeshes: in parallel make sure to put processor patches last. Fixes #239

parent ac49daaf
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -30,6 +30,7 @@ License
#include "polyAddPoint.H"
#include "polyAddCell.H"
#include "polyAddFace.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -104,11 +105,11 @@ Foam::label Foam::mergePolyMesh::zoneIndex
const word& curName
)
{
forAll(names, zoneI)
forAll(names, zonei)
{
if (names[zoneI] == curName)
if (names[zonei] == curName)
{
return zoneI;
return zonei;
}
}
......@@ -119,6 +120,84 @@ Foam::label Foam::mergePolyMesh::zoneIndex
}
void Foam::mergePolyMesh::sortProcessorPatches()
{
Info<< "Reordering processor patches last" << endl;
// Updates boundaryMesh() and meshMod_ to guarantee processor patches
// are last. This could be done inside the merge() but it is far easier
// to do separately.
// 1. Shuffle the patches in the boundaryMesh
const polyBoundaryMesh& oldPatches = boundaryMesh();
DynamicList<polyPatch*> newPatches(oldPatches.size());
labelList oldToSorted(oldPatches.size());
forAll(oldPatches, patchi)
{
const polyPatch& pp = oldPatches[patchi];
if (!isA<processorPolyPatch>(pp))
{
oldToSorted[patchi] = newPatches.size();
newPatches.append
(
pp.clone
(
oldPatches,
oldToSorted[patchi],
0,
nInternalFaces()
).ptr()
);
}
}
forAll(oldPatches, patchi)
{
const polyPatch& pp = oldPatches[patchi];
if (isA<processorPolyPatch>(pp))
{
oldToSorted[patchi] = newPatches.size();
newPatches.append
(
pp.clone
(
oldPatches,
oldToSorted[patchi],
0,
nInternalFaces()
).ptr()
);
}
}
removeBoundary();
addPatches(newPatches);
// Update the polyTopoChange
DynamicList<label>& patchID = const_cast<DynamicList<label>&>
(
meshMod_.region()
);
forAll(patchID, facei)
{
label patchi = patchID[facei];
if (patchi != -1)
{
patchID[facei] = oldToSorted[patchID[facei]];
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
......@@ -183,9 +262,6 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mergePolyMesh::addMesh(const polyMesh& m)
......@@ -506,6 +582,10 @@ void Foam::mergePolyMesh::merge()
}
}
// Shuffle the processor patches to be last
sortProcessorPatches();
// Change mesh. No inflation
meshMod_.changeMesh(*this, false);
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -89,6 +89,9 @@ class mergePolyMesh
//- Return zone index given a list of active zones and a name
label zoneIndex(DynamicList<word>&, const word&);
//- Shuffle processor patches to be last
void sortProcessorPatches();
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment