BUG: foamToEnsight: handle empty patches

This commit is contained in:
mattijs 2014-02-20 13:39:56 +00:00 committed by Andrew Heather
parent ee2e7e87d3
commit 59cef386cd

View File

@ -195,41 +195,44 @@ void Foam::ensightMesh::correct()
{ {
forAll(mesh_.boundary(), patchi) forAll(mesh_.boundary(), patchi)
{ {
const polyPatch& p = mesh_.boundaryMesh()[patchi]; if (mesh_.boundary()[patchi].size())
labelList& tris = boundaryFaceSets_[patchi].tris;
labelList& quads = boundaryFaceSets_[patchi].quads;
labelList& polys = boundaryFaceSets_[patchi].polys;
tris.setSize(p.size());
quads.setSize(p.size());
polys.setSize(p.size());
label nTris = 0;
label nQuads = 0;
label nPolys = 0;
forAll(p, faceI)
{ {
const face& f = p[faceI]; const polyPatch& p = mesh_.boundaryMesh()[patchi];
if (f.size() == 3) labelList& tris = boundaryFaceSets_[patchi].tris;
labelList& quads = boundaryFaceSets_[patchi].quads;
labelList& polys = boundaryFaceSets_[patchi].polys;
tris.setSize(p.size());
quads.setSize(p.size());
polys.setSize(p.size());
label nTris = 0;
label nQuads = 0;
label nPolys = 0;
forAll(p, faceI)
{ {
tris[nTris++] = faceI; const face& f = p[faceI];
}
else if (f.size() == 4) if (f.size() == 3)
{ {
quads[nQuads++] = faceI; tris[nTris++] = faceI;
} }
else else if (f.size() == 4)
{ {
polys[nPolys++] = faceI; quads[nQuads++] = faceI;
}
else
{
polys[nPolys++] = faceI;
}
} }
tris.setSize(nTris);
quads.setSize(nQuads);
polys.setSize(nPolys);
} }
tris.setSize(nTris);
quads.setSize(nQuads);
polys.setSize(nPolys);
} }
} }
@ -240,9 +243,12 @@ void Foam::ensightMesh::correct()
if (patchNames_.empty() || patchNames_.found(patchName)) if (patchNames_.empty() || patchNames_.found(patchName))
{ {
nfp.nTris = boundaryFaceSets_[patchi].tris.size(); if (mesh_.boundary()[patchi].size())
nfp.nQuads = boundaryFaceSets_[patchi].quads.size(); {
nfp.nPolys = boundaryFaceSets_[patchi].polys.size(); nfp.nTris = boundaryFaceSets_[patchi].tris.size();
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
}
} }
reduce(nfp.nTris, sumOp<label>()); reduce(nfp.nTris, sumOp<label>());