From e8af5d62d5db104aedf495f99d25176fea78442c Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Wed, 9 Dec 2009 17:42:30 +0000
Subject: [PATCH] Filter out zero-sized patches; add generic capability

---
 .../foamToTecplot360/Make/options             |   1 +
 .../foamToTecplot360/foamToTecplot360.C       | 183 +++++++++---------
 2 files changed, 97 insertions(+), 87 deletions(-)

diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options
index 0c2c8b72160..c3569ababfb 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options
+++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options
@@ -9,4 +9,5 @@ EXE_LIBS = \
     -ltecio \
     -llagrangian \
     -lfiniteVolume \
+    -lgenericPatchFields \
     -lmeshTools
diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
index b5ab1e34d75..6c1065a489b 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
@@ -909,106 +909,115 @@ int main(int argc, char *argv[])
             const polyPatch& pp = patches[patchID];
             //INTEGER4 strandID = 1 + i;
 
-            Info<< "    Writing patch " << patchID << "\t" << pp.name()
-                << "\tstrand:" << strandID << nl << endl;
+            if (pp.size() > 0)
+            {
+                Info<< "    Writing patch " << patchID << "\t" << pp.name()
+                    << "\tstrand:" << strandID << nl << endl;
 
-            const indirectPrimitivePatch ipp
-            (
-                IndirectList<face>(pp, identity(pp.size())),
-                pp.points()
-            );
+                const indirectPrimitivePatch ipp
+                (
+                    IndirectList<face>(pp, identity(pp.size())),
+                    pp.points()
+                );
 
-            writer.writePolygonalZone
-            (
-                pp.name(),
-                strandID++,     //strandID,
-                ipp,
-                allVarLocation
-            );
+                writer.writePolygonalZone
+                (
+                    pp.name(),
+                    strandID++,     //strandID,
+                    ipp,
+                    allVarLocation
+                );
 
-            // Write coordinates
-            writer.writeField(ipp.localPoints().component(0)());
-            writer.writeField(ipp.localPoints().component(1)());
-            writer.writeField(ipp.localPoints().component(2)());
+                // Write coordinates
+                writer.writeField(ipp.localPoints().component(0)());
+                writer.writeField(ipp.localPoints().component(1)());
+                writer.writeField(ipp.localPoints().component(2)());
 
-            // Write all fields
-            forAll(vsf, i)
-            {
-                writer.writeField
-                (
-                    writer.getPatchField
+                // Write all fields
+                forAll(vsf, i)
+                {
+                    writer.writeField
                     (
-                        nearCellValue,
-                        vsf[i],
-                        patchID
-                    )()
-                );
-            }
-            forAll(vvf, i)
-            {
-                writer.writeField
-                (
-                    writer.getPatchField
+                        writer.getPatchField
+                        (
+                            nearCellValue,
+                            vsf[i],
+                            patchID
+                        )()
+                    );
+                }
+                forAll(vvf, i)
+                {
+                    writer.writeField
                     (
-                        nearCellValue,
-                        vvf[i],
-                        patchID
-                    )()
-                );
-            }
-            forAll(vSpheretf, i)
-            {
-                writer.writeField
-                (
-                    writer.getPatchField
+                        writer.getPatchField
+                        (
+                            nearCellValue,
+                            vvf[i],
+                            patchID
+                        )()
+                    );
+                }
+                forAll(vSpheretf, i)
+                {
+                    writer.writeField
                     (
-                        nearCellValue,
-                        vSpheretf[i],
-                        patchID
-                    )()
-                );
-            }
-            forAll(vSymmtf, i)
-            {
-                writer.writeField
-                (
-                    writer.getPatchField
+                        writer.getPatchField
+                        (
+                            nearCellValue,
+                            vSpheretf[i],
+                            patchID
+                        )()
+                    );
+                }
+                forAll(vSymmtf, i)
+                {
+                    writer.writeField
                     (
-                        nearCellValue,
-                        vSymmtf[i],
-                        patchID
-                    )()
-                );
-            }
-            forAll(vtf, i)
-            {
-                writer.writeField
-                (
-                    writer.getPatchField
+                        writer.getPatchField
+                        (
+                            nearCellValue,
+                            vSymmtf[i],
+                            patchID
+                        )()
+                    );
+                }
+                forAll(vtf, i)
+                {
+                    writer.writeField
                     (
-                        nearCellValue,
-                        vtf[i],
-                        patchID
-                    )()
-                );
-            }
+                        writer.getPatchField
+                        (
+                            nearCellValue,
+                            vtf[i],
+                            patchID
+                        )()
+                    );
+                }
 
-            forAll(psf, i)
-            {
-                writer.writeField
-                (
-                    psf[i].boundaryField()[patchID].patchInternalField()()
-                );
+                forAll(psf, i)
+                {
+                    writer.writeField
+                    (
+                        psf[i].boundaryField()[patchID].patchInternalField()()
+                    );
+                }
+                forAll(pvf, i)
+                {
+                    writer.writeField
+                    (
+                        pvf[i].boundaryField()[patchID].patchInternalField()()
+                    );
+                }
+
+                writer.writeConnectivity(ipp);
             }
-            forAll(pvf, i)
+            else
             {
-                writer.writeField
-                (
-                    pvf[i].boundaryField()[patchID].patchInternalField()()
-                );
+                Info<< "    Skipping zero sized patch " << patchID
+                    << "\t" << pp.name()
+                    << nl << endl;
             }
-
-            writer.writeConnectivity(ipp);
         }
         writer.writeEnd();
 
-- 
GitLab