BUG: corrupt extrudeToRegionMesh boundary patches in parallel (fixes #1295)

- new patches were added to the end of existing patches, which placed
  them _after_ the processor patches. This is incorrect.
This commit is contained in:
mattijs
2019-08-16 01:07:00 +01:00
committed by Andrew Heather
parent c072000dca
commit 9815d37db3

View File

@ -149,7 +149,7 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
label findPatchID(const List<polyPatch*>& newPatches, const word& name) label findPatchID(const UList<polyPatch*>& newPatches, const word& name)
{ {
forAll(newPatches, i) forAll(newPatches, i)
{ {
@ -162,6 +162,20 @@ label findPatchID(const List<polyPatch*>& newPatches, const word& name)
} }
#ifdef FULLDEBUG
void printPatches(Ostream& os, const UList<polyPatch*>& newPatches)
{
for (const polyPatch* ppPtr : newPatches)
{
const polyPatch& pp = *ppPtr;
os << " name:" << pp.name() << " index:" << pp.index()
<< " start:" << pp.start() << " size:" << pp.size()
<< " type:" << pp.type() << nl;
}
}
#endif
template<class PatchType> template<class PatchType>
label addPatch label addPatch
( (
@ -198,6 +212,12 @@ label addPatch
startFacei = pp.start()+pp.size(); startFacei = pp.start()+pp.size();
} }
#ifdef FULLDEBUG
Pout<< "addPatch : starting newPatches:"
<< " patch:" << patchi << " startFace:" << startFacei << nl;
printPatches(Pout, newPatches);
Pout<< "*** end of addPatch:" << endl;
#endif
newPatches.append newPatches.append
( (
@ -253,6 +273,15 @@ label addPatch
startFacei = pp.start()+pp.size(); startFacei = pp.start()+pp.size();
} }
#ifdef FULLDEBUG
Pout<< "addPatch : starting newPatches:"
<< " patch:" << patchi << " startFace:" << startFacei << nl;
printPatches(Pout, newPatches);
Pout<< "*** end of addPatch:" << endl;
#endif
dictionary patchDict(dict); dictionary patchDict(dict);
patchDict.set("type", PatchType::typeName); patchDict.set("type", PatchType::typeName);
patchDict.set("nFaces", 0); patchDict.set("nFaces", 0);
@ -300,7 +329,7 @@ void deleteEmptyPatches(fvMesh& mesh)
if (isA<processorPolyPatch>(patches[patchi])) if (isA<processorPolyPatch>(patches[patchi]))
{ {
// Similar named processor patch? Not 'possible'. // Similar named processor patch? Not 'possible'.
if (patches[patchi].size() == 0) if (patches[patchi].empty())
{ {
Pout<< "Deleting processor patch " << patchi Pout<< "Deleting processor patch " << patchi
<< " name:" << patches[patchi].name() << " name:" << patches[patchi].name()
@ -315,7 +344,7 @@ void deleteEmptyPatches(fvMesh& mesh)
else else
{ {
// Common patch. // Common patch.
if (returnReduce(patches[patchi].size(), sumOp<label>()) == 0) if (returnReduce(patches[patchi].empty(), andOp<bool>()))
{ {
Pout<< "Deleting patch " << patchi Pout<< "Deleting patch " << patchi
<< " name:" << patches[patchi].name() << " name:" << patches[patchi].name()
@ -337,7 +366,7 @@ void deleteEmptyPatches(fvMesh& mesh)
{ {
// Unique to this processor. Note: could check that these are // Unique to this processor. Note: could check that these are
// only processor patches. // only processor patches.
if (patches[patchi].size() == 0) if (patches[patchi].empty())
{ {
Pout<< "Deleting processor patch " << patchi Pout<< "Deleting processor patch " << patchi
<< " name:" << patches[patchi].name() << " name:" << patches[patchi].name()
@ -1125,9 +1154,17 @@ void setCouplingInfo
if (!newPatches[patchi]) if (!newPatches[patchi])
{ {
newPatches[patchi] = patches[patchi].clone(patches).ptr(); newPatches[patchi] = patches[patchi].clone(patches).ptr();
//newPatches[patchi].index() = patchi;
} }
} }
#ifdef FULLDEBUG
Pout<< "*** setCouplingInfo addFvPAtches:" << nl;
printPatches(Pout, newPatches);
Pout<< "*** setCouplingInfo end of addFvPAtches:" << endl;
#endif
mesh.removeFvBoundary(); mesh.removeFvBoundary();
mesh.addFvPatches(newPatches, true); mesh.addFvPatches(newPatches, true);
} }
@ -1921,14 +1958,19 @@ int main(int argc, char *argv[])
{ {
// Add coupling patches to mesh // Add coupling patches to mesh
// Clone existing patches // 1. Clone existing global patches
DynamicList<polyPatch*> newPatches(patches.size()); DynamicList<polyPatch*> newPatches(patches.size());
forAll(patches, patchi) forAll(patches, patchi)
{ {
newPatches.append(patches[patchi].clone(patches).ptr()); if (!isA<processorPolyPatch>(patches[patchi]))
{
autoPtr<polyPatch> clonedPatch(patches[patchi].clone(patches));
clonedPatch->index() = newPatches.size();
newPatches.append(clonedPatch.ptr());
}
} }
// Add new patches // 2. Add new patches
addCouplingPatches addCouplingPatches
( (
mesh, mesh,
@ -1944,6 +1986,25 @@ int main(int argc, char *argv[])
interMeshBottomPatch interMeshBottomPatch
); );
// 3. Clone processor patches
forAll(patches, patchi)
{
if (isA<processorPolyPatch>(patches[patchi]))
{
autoPtr<polyPatch> clonedPatch(patches[patchi].clone(patches));
clonedPatch->index() = newPatches.size();
newPatches.append(clonedPatch.ptr());
}
}
#ifdef FULLDEBUG
Pout<< "*** adaptMesh : addFvPAtches:" << nl;
printPatches(Pout, newPatches);
Pout<< "*** end of adaptMesh : addFvPAtches:" << endl;
#endif
// Add to mesh // Add to mesh
mesh.clearOut(); mesh.clearOut();
mesh.removeFvBoundary(); mesh.removeFvBoundary();
@ -2326,6 +2387,14 @@ int main(int argc, char *argv[])
regionPatches[patchi] = ppPtr->clone(regionMesh.boundaryMesh()).ptr(); regionPatches[patchi] = ppPtr->clone(regionMesh.boundaryMesh()).ptr();
delete ppPtr; delete ppPtr;
} }
#ifdef FULLDEBUG
Pout<< "*** regionPatches : regionPatches:" << nl;
printPatches(Pout, regionPatches);
Pout<< "*** end of regionPatches : regionPatches:" << endl;
#endif
regionMesh.clearOut(); regionMesh.clearOut();
regionMesh.removeFvBoundary(); regionMesh.removeFvBoundary();
regionMesh.addFvPatches(regionPatches, true); regionMesh.addFvPatches(regionPatches, true);