CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   label/scalar mixup in hierarchGeomDecomp.C (https://www.cfd-online.com/Forums/openfoam-bugs/79521-label-scalar-mixup-hierarchgeomdecomp-c.html)

mwild August 26, 2010 04:13

label/scalar mixup in hierarchGeomDecomp.C
 
The bug is in src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C:

Code:

279        label weightedSize = returnReduce
280        (
281            sortedWeightedSizes[mid] - sortedWeightedSizes[minIndex],
282            sumOp<label>()
283        );

where sortedWeightedSizes is a List<scalar>. It probably should be fixed by

Code:

--- a/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C
+++ b/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C
@@ -276,10 +276,10 @@ void Foam::hierarchGeomDecomp::findBinary
 
    while (true)
    {
-        label weightedSize = returnReduce
+        scalar weightedSize = returnReduce
        (
            sortedWeightedSizes[mid] - sortedWeightedSizes[minIndex],
-            sumOp<label>()
+            sumOp<scalar>()
        );
 
        if (debug)

Michael

mwild August 26, 2010 05:31

Similarly for src/dynamicMesh/slidingInterface/slidingInterface.C:

Code:

--- a/src/dynamicMesh/slidingInterface/slidingInterface.C
+++ b/src/dynamicMesh/slidingInterface/slidingInterface.C
@@ -706,12 +706,12 @@ void Foam::slidingInterface::setTolerances(const dictionary&dict, bool report)
        "edgeMergeTol",
        edgeMergeTol_
    );
-    nFacesPerSlaveEdge_ = dict.lookupOrDefault<scalar>
+    nFacesPerSlaveEdge_ = dict.lookupOrDefault<label>
    (
        "nFacesPerSlaveEdge",
        nFacesPerSlaveEdge_
    );
-    edgeFaceEscapeLimit_ = dict.lookupOrDefault<scalar>
+    edgeFaceEscapeLimit_ = dict.lookupOrDefault<label>
    (
        "edgeFaceEscapeLimit",
        edgeFaceEscapeLimit_


mattijs August 27, 2010 06:28

Thanks, I've pushed them into 1.7.x. By the way, how did you find these - gcc4.4 does not seem to warn about them.

We've finally got a proper bug reporting system :-)
Please report any future bugs on http://www.openfoam.com/bugs.

mwild August 27, 2010 08:53

gcc4.1.2 does ;-) probably 4.4 would too with proper warning flags.

Kudos for the Mantis bug tracker! At last, I'd say :-)

niqbal February 16, 2012 11:33

Hi Michael,
It would be very nice if you might explain a little bit about this function call returnReduce(. ,. ). I have find its definition "PstreamReduceOps.H" but could not understand what this will return.
Your short description about this function would help me a lot.
Thanks in Advance


mwild February 16, 2012 14:18

returnReduce() is a reduction operation (e.g. sum, min, max, cumulative sum, product, cumulative product, etc) across all processors for parallel runs. The first argument is the value on the local processor and the second argument is the binary operator performing the reduction operation between two arguments. This can be a functor or a function pointer.

The problem in the reported issue is that the functor objects where created for label type (i.e. int), while the value argument was a scalar (i.e. double or float).

HTH

Michael

niqbal February 17, 2012 03:43

Hi Michael,
Thanks for the prompt reply. It clarifies the things I am looking at.


All times are GMT -4. The time now is 07:50.