View Issue Details

IDProjectCategoryView StatusLast Update
0000100OpenFOAMBugpublic2010-12-07 17:17
Reporterbgschaid Assigned Touser4 
PrioritynormalSeveritycrashReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformLinuxOSCentOSOS Version5.5
Summary0000100: midPointAndFaceSampleSet and midPointSampleSet crash when size()==0
DescriptionWhen the endpoints are specified in such a way that the whole sample line is outside the mesh (and therefor no sample points are present) these two classes either crash (midPointAndFaceSampleSet) or hang (midPointSampleSet)
Additional InformationFixed by the attached patch
TagsNo tags attached.

Activities

bgschaid

2010-12-05 22:05

reporter  

midPointSampleSet.patch (1,537 bytes)   
# HG changeset patch
# Parent 0c921ec04c5b142030f31823ffc5d823c366cab5

diff --git a/src/sampling/sampledSet/midPoint/midPointSet.C b/src/sampling/sampledSet/midPoint/midPointSet.C
--- a/src/sampling/sampledSet/midPoint/midPointSet.C
+++ b/src/sampling/sampledSet/midPoint/midPointSet.C
@@ -53,7 +53,7 @@
 
     label sampleI = 0;
 
-    while(true)
+    while(true && size()>0)
     {
         // calculate midpoint between sampleI and sampleI+1 (if in same segment)
         while
@@ -98,6 +98,12 @@
         sampleI++;
     }
 
+    if(midI==0) {
+        WarningIn("Foam::midPointSet::genSamples()")
+            << "No sample points for " << name() 
+                <<endl;
+    }
+
     midPoints.setSize(midI);
     midCells.setSize(midI);
     midSegments.setSize(midI);
diff --git a/src/sampling/sampledSet/midPointAndFace/midPointAndFaceSet.C b/src/sampling/sampledSet/midPointAndFace/midPointAndFaceSet.C
--- a/src/sampling/sampledSet/midPointAndFace/midPointAndFaceSet.C
+++ b/src/sampling/sampledSet/midPointAndFace/midPointAndFaceSet.C
@@ -55,7 +55,7 @@
 
     label sampleI = 0;
 
-    while(true)
+    while(true && size()>0)
     {
         // sampleI is start of segment
 
@@ -122,6 +122,12 @@
         sampleI++;
     }
 
+    if(newSampleI==0) {
+        WarningIn("Foam::midPointAndFaceSet::genSamples()")
+            << "No sample points for " << name() 
+                <<endl;
+    }
+
     newSamplePoints.setSize(newSampleI);
     newSampleCells.setSize(newSampleI);
     newSampleFaces.setSize(newSampleI);
midPointSampleSet.patch (1,537 bytes)   

user4

2010-12-07 17:17

  ~0000167

fixed in 4e273f90a12fd24d84892618bcb15460a6eb5fbd.

Thanks for the fix. I've moved the empty set check into sampledSets when the results of all processors have been combined.

Issue History

Date Modified Username Field Change
2010-12-05 22:05 bgschaid New Issue
2010-12-05 22:05 bgschaid File Added: midPointSampleSet.patch
2010-12-07 17:17 user4 Note Added: 0000167
2010-12-07 17:17 user4 Status new => resolved
2010-12-07 17:17 user4 Fixed in Version => 1.7.x
2010-12-07 17:17 user4 Resolution open => fixed
2010-12-07 17:17 user4 Assigned To => user4