From c462d48196cca20ede416bd46c85f1d5c0abffbd Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Wed, 21 Jun 2017 14:05:26 +0100
Subject: [PATCH] ENH: wallBoundedStreamline: handle patches with zero faces.
 See #502.

---
 .../field/streamLine/streamLineBase.C         |  4 +-
 .../wallBoundedStreamLine.C                   | 62 ++++++++++---------
 2 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C
index 305ab37636e..9eaae07a822 100644
--- a/src/functionObjects/field/streamLine/streamLineBase.C
+++ b/src/functionObjects/field/streamLine/streamLineBase.C
@@ -767,7 +767,7 @@ bool Foam::functionObjects::streamLineBase::write()
 
         // Convert scalar values
 
-        if (allScalars_.size() > 0)
+        if (allScalars_.size() > 0 && tracks.size() > 0)
         {
             List<List<scalarField>> scalarValues(allScalars_.size());
 
@@ -811,7 +811,7 @@ bool Foam::functionObjects::streamLineBase::write()
 
         // Convert vector values
 
-        if (allVectors_.size() > 0)
+        if (allVectors_.size() > 0 && tracks.size() > 0)
         {
             List<List<vectorField>> vectorValues(allVectors_.size());
 
diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
index 0799254290c..66ff518d127 100644
--- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
+++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
@@ -139,39 +139,43 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
 
         forAll(seedPoints, i)
         {
-            const point& seedPt = seedPoints[i];
             label celli = seedPoints.cells()[i];
 
-            tetIndices ids(findNearestTet(isWallPatch, seedPt, celli));
-
-            if (ids.face() != -1 && isWallPatch[ids.face()])
+            if (celli != -1)
             {
-                //Pout<< "Seeding particle :" << nl
-                //    << "     seedPt:" << seedPt << nl
-                //    << "     face  :" << ids.face() << nl
-                //    << "     at    :" << mesh_.faceCentres()[ids.face()] << nl
-                //    << "     cell  :" << mesh_.cellCentres()[ids.cell()] << nl
-                //    << endl;
-
-                particles.addParticle
-                (
-                    new wallBoundedStreamLineParticle
+                const point& seedPt = seedPoints[i];
+                tetIndices ids(findNearestTet(isWallPatch, seedPt, celli));
+
+                if (ids.face() != -1 && isWallPatch[ids.face()])
+                {
+                    //Pout<< "Seeding particle :" << nl
+                    //    << "     seedPt:" << seedPt << nl
+                    //    << "     face  :" << ids.face() << nl
+                    //    << "     at    :" << mesh_.faceCentres()[ids.face()]
+                    //    << nl
+                    //    << "     cell  :" << mesh_.cellCentres()[ids.cell()]
+                    //    << nl << endl;
+
+                    particles.addParticle
                     (
-                        mesh_,
-                        ids.faceTri(mesh_).centre(),
-                        ids.cell(),
-                        ids.face(),     // tetFace
-                        ids.tetPt(),
-                        -1,             // not on a mesh edge
-                        -1,             // not on a diagonal edge
-                        lifeTime_       // lifetime
-                    )
-                );
-            }
-            else
-            {
-                Pout<< type() << " : ignoring seed " << seedPt
-                    << " since not in wall cell." << endl;
+                        new wallBoundedStreamLineParticle
+                        (
+                            mesh_,
+                            ids.faceTri(mesh_).centre(),
+                            ids.cell(),
+                            ids.face(),     // tetFace
+                            ids.tetPt(),
+                            -1,             // not on a mesh edge
+                            -1,             // not on a diagonal edge
+                            lifeTime_       // lifetime
+                        )
+                    );
+                }
+                else
+                {
+                    Pout<< type() << " : ignoring seed " << seedPt
+                        << " since not in wall cell." << endl;
+                }
             }
         }
     }
-- 
GitLab