View Issue Details

IDProjectCategoryView StatusLast Update
0000330OpenFOAMBugpublic2011-11-03 17:06
Reporteruser19Assigned Touser4 
PrioritynormalSeveritymajorReproducibilityN/A
Status resolvedResolutionfixed 
Summary0000330: uniqueOrder() drops largest item
DescriptionThe uniqueOrder() function in src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C is broken because it always drops the item with the largest value.
Steps To ReproduceCompile the test program in applications/test/sort and run Test-sortList. Observe the results. The first "unique:" output should return a list that is 6 elements long, however, it only returns an ordering that has 5 elements. It is missing the entry "1" which corresponds to the item with the highest value (9) in the unsorted list.
TagsNo tags attached.

Activities

user19

2011-10-31 09:44

  ~0000779

Attached patch fixes the issue.

user19

2011-10-31 09:45

 

0001-BUG-Fix-uniqueOrder-to-not-drop-largest-item.patch (948 bytes)   
From 1595f900feb4f9fce4c6b7278dd399c8c96a56f6 Mon Sep 17 00:00:00 2001
From: Michael Wild <themiwi@users.sourceforge.net>
Date: Mon, 31 Oct 2011 10:42:35 +0100
Subject: [PATCH] BUG: Fix uniqueOrder() to not drop largest item

Fixes http://www.openfoam.com/mantisbt/view.php?id=330.

Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
---
 .../containers/Lists/ListOps/ListOpsTemplates.C    |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
index 1f308ed..41e28c3 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
@@ -243,6 +243,7 @@ void Foam::uniqueOrder
                 order[n++] = order[i];
             }
         }
+        order[n++] = order[order.size()-1];
         order.setSize(n);
     }
 }
-- 
1.7.5.4

user4

2011-11-03 17:06

  ~0000782

Thanks. Pushed in 7b86d6b513c81009a78070796bf87c794ad791b5

Issue History

Date Modified Username Field Change
2011-10-31 09:42 user19 New Issue
2011-10-31 09:44 user19 Note Added: 0000779
2011-10-31 09:45 user19 File Added: 0001-BUG-Fix-uniqueOrder-to-not-drop-largest-item.patch
2011-11-03 17:06 user4 Note Added: 0000782
2011-11-03 17:06 user4 Status new => resolved
2011-11-03 17:06 user4 Fixed in Version => 2.0.x
2011-11-03 17:06 user4 Resolution open => fixed
2011-11-03 17:06 user4 Assigned To => user4