From 8712b8276e1729ff69b4aba6e73312d2bf50b273 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Fri, 18 Oct 2013 16:19:33 +0100
Subject: [PATCH] BUG: foamToEnsight: reset facePrimitives

---
 .../dataConversion/foamToEnsight/cellSets.H   | 22 +++++-
 .../foamToEnsight/ensightMesh.C               | 72 +++++++++----------
 2 files changed, 55 insertions(+), 39 deletions(-)

diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
index 1f66fa276e8..54887f662a2 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -78,6 +78,26 @@ public:
             hexes(nCells),
             polys(nCells)
         {}
+
+
+    // Member Functions
+
+        void setSize(const label nCells)
+        {
+            nTets = 0;
+            nPyrs = 0;
+            nPrisms = 0;
+            nHexesWedges = 0;
+            nPolys = 0;
+
+            tets.setSize(nCells);
+            pyrs.setSize(nCells);
+            prisms.setSize(nCells);
+            wedges.setSize(nCells);
+            hexes.setSize(nCells);
+            polys.setSize(nCells);
+        }
+
 };
 
 
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
index 0332572eeb0..267b8dc8442 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
@@ -47,7 +47,8 @@ License
 void Foam::ensightMesh::correct()
 {
     patchPartOffset_ = 2;
-    meshCellSets_ = mesh_.nCells();
+    meshCellSets_.setSize(mesh_.nCells());
+
     boundaryFaceSets_.setSize(mesh_.boundary().size());
     allPatchNames_.clear();
     patchNames_.clear();
@@ -194,44 +195,41 @@ void Foam::ensightMesh::correct()
     {
         forAll(mesh_.boundary(), patchi)
         {
-            if (mesh_.boundary()[patchi].size())
-            {
-                const polyPatch& p = mesh_.boundaryMesh()[patchi];
+            const polyPatch& p = mesh_.boundaryMesh()[patchi];
 
-                labelList& tris = boundaryFaceSets_[patchi].tris;
-                labelList& quads = boundaryFaceSets_[patchi].quads;
-                labelList& polys = boundaryFaceSets_[patchi].polys;
+            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());
+            tris.setSize(p.size());
+            quads.setSize(p.size());
+            polys.setSize(p.size());
 
-                label nTris = 0;
-                label nQuads = 0;
-                label nPolys = 0;
+            label nTris = 0;
+            label nQuads = 0;
+            label nPolys = 0;
 
-                forAll(p, faceI)
-                {
-                    const face& f = p[faceI];
+            forAll(p, 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;
-                    }
+                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);
         }
     }
 
@@ -242,12 +240,9 @@ void Foam::ensightMesh::correct()
 
         if (patchNames_.empty() || patchNames_.found(patchName))
         {
-            if (mesh_.boundary()[patchi].size())
-            {
-                nfp.nTris   = boundaryFaceSets_[patchi].tris.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>());
@@ -1148,6 +1143,7 @@ void Foam::ensightMesh::write
             if (nfp.nTris || nfp.nQuads || nfp.nPolys)
             {
                 const polyPatch& p = mesh_.boundaryMesh()[patchi];
+
                 const labelList& tris = boundaryFaceSets_[patchi].tris;
                 const labelList& quads = boundaryFaceSets_[patchi].quads;
                 const labelList& polys = boundaryFaceSets_[patchi].polys;
-- 
GitLab