Commit 9815d37d authored by mattijs's avatar mattijs Committed by Andrew Heather
Browse files

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.
parent c072000d
......@@ -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)
{
......@@ -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>
label addPatch
(
......@@ -198,6 +212,12 @@ label addPatch
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
(
......@@ -253,6 +273,15 @@ label addPatch
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);
patchDict.set("type", PatchType::typeName);
patchDict.set("nFaces", 0);
......@@ -300,7 +329,7 @@ void deleteEmptyPatches(fvMesh& mesh)
if (isA<processorPolyPatch>(patches[patchi]))
{
// Similar named processor patch? Not 'possible'.
if (patches[patchi].size() == 0)
if (patches[patchi].empty())
{
Pout<< "Deleting processor patch " << patchi
<< " name:" << patches[patchi].name()
......@@ -315,7 +344,7 @@ void deleteEmptyPatches(fvMesh& mesh)
else
{
// Common patch.
if (returnReduce(patches[patchi].size(), sumOp<label>()) == 0)
if (returnReduce(patches[patchi].empty(), andOp<bool>()))
{
Pout<< "Deleting patch " << patchi
<< " name:" << patches[patchi].name()
......@@ -337,7 +366,7 @@ void deleteEmptyPatches(fvMesh& mesh)
{
// Unique to this processor. Note: could check that these are
// only processor patches.
if (patches[patchi].size() == 0)
if (patches[patchi].empty())
{
Pout<< "Deleting processor patch " << patchi
<< " name:" << patches[patchi].name()
......@@ -1125,9 +1154,17 @@ void setCouplingInfo
if (!newPatches[patchi])
{
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.addFvPatches(newPatches, true);
}
......@@ -1921,14 +1958,19 @@ int main(int argc, char *argv[])
{
// Add coupling patches to mesh
// Clone existing patches
// 1. Clone existing global patches
DynamicList<polyPatch*> newPatches(patches.size());
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
(
mesh,
......@@ -1944,6 +1986,25 @@ int main(int argc, char *argv[])
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
mesh.clearOut();
mesh.removeFvBoundary();
......@@ -2326,6 +2387,14 @@ int main(int argc, char *argv[])
regionPatches[patchi] = ppPtr->clone(regionMesh.boundaryMesh()).ptr();
delete ppPtr;
}
#ifdef FULLDEBUG
Pout<< "*** regionPatches : regionPatches:" << nl;
printPatches(Pout, regionPatches);
Pout<< "*** end of regionPatches : regionPatches:" << endl;
#endif
regionMesh.clearOut();
regionMesh.removeFvBoundary();
regionMesh.addFvPatches(regionPatches, true);
......
Supports Markdown
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