From 59cef386cd7e1894b5219dc6c40c68f9958f8f11 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 20 Feb 2014 13:39:56 +0000 Subject: [PATCH] BUG: foamToEnsight: handle empty patches --- .../foamToEnsight/ensightMesh.C | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C index 267b8dc844..bae7d39572 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C @@ -195,41 +195,44 @@ void Foam::ensightMesh::correct() { forAll(mesh_.boundary(), patchi) { - const polyPatch& p = mesh_.boundaryMesh()[patchi]; - - 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) + if (mesh_.boundary()[patchi].size()) { - 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; - } - else if (f.size() == 4) - { - quads[nQuads++] = faceI; - } - else - { - polys[nPolys++] = faceI; + const face& f = p[faceI]; + + if (f.size() == 3) + { + tris[nTris++] = faceI; + } + else if (f.size() == 4) + { + 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)) { - nfp.nTris = boundaryFaceSets_[patchi].tris.size(); - nfp.nQuads = boundaryFaceSets_[patchi].quads.size(); - nfp.nPolys = boundaryFaceSets_[patchi].polys.size(); + if (mesh_.boundary()[patchi].size()) + { + nfp.nTris = boundaryFaceSets_[patchi].tris.size(); + nfp.nQuads = boundaryFaceSets_[patchi].quads.size(); + nfp.nPolys = boundaryFaceSets_[patchi].polys.size(); + } } reduce(nfp.nTris, sumOp