From 30dd35aa0db6d6d8f9110961ea022eea8e25ca2b Mon Sep 17 00:00:00 2001
From: Soeren Peters <peters.soeren@gmx.net>
Date: Fri, 12 Feb 2021 13:27:17 +0100
Subject: [PATCH] Fix unsigned misused in node numbering.

---
 .../CoProcessors/AverageValuesCoProcessor.cpp          |  9 +++++----
 .../CoProcessors/QCriterionCoProcessor.cpp             |  9 ++++++---
 .../CoProcessors/TimeAveragedValuesCoProcessor.cpp     |  9 +++++----
 .../CoProcessors/TurbulenceIntensityCoProcessor.cpp    | 10 ++++++----
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp
index 3684a5791..6912d4bb9 100644
--- a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp
+++ b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp
@@ -243,9 +243,6 @@ void AverageValuesCoProcessor::addData(const SPtr<Block3D> block)
     SPtr<AverageValuesArray3D> av           = kernel->getDataSet()->getAverageValues();
     // int ghostLayerWidth = kernel->getGhostLayerWidth();
 
-    // knotennummerierung faengt immer bei 0 an!
-    unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
-
     int minX1 = 0;
     int minX2 = 0;
     int minX3 = 0;
@@ -313,6 +310,8 @@ void AverageValuesCoProcessor::addData(const SPtr<Block3D> block)
     maxX2 -= 1;
     maxX3 -= 1;
 
+    int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
+
     // cell vector erstellen
     for (int ix3 = minX3; ix3 <= maxX3; ix3++) {
         for (int ix2 = minX2; ix2 <= maxX2; ix2++) {
@@ -322,7 +321,9 @@ void AverageValuesCoProcessor::addData(const SPtr<Block3D> block)
                     (SWT = nodeNumbers(ix1, ix2, ix3 + 1)) >= 0 && (SET = nodeNumbers(ix1 + 1, ix2, ix3 + 1)) >= 0 &&
                     (NET = nodeNumbers(ix1 + 1, ix2 + 1, ix3 + 1)) >= 0 &&
                     (NWT = nodeNumbers(ix1, ix2 + 1, ix3 + 1)) >= 0) {
-                    cells.push_back(makeUbTuple(SWB, SEB, NEB, NWB, SWT, SET, NET, NWT));
+                    cells.push_back(makeUbTuple((unsigned int)SWB, (unsigned int)SEB, (unsigned int)NEB,
+                                                (unsigned int)NWB, (unsigned int)SWT, (unsigned int)SET,
+                                                (unsigned int)NET, (unsigned int)NWT));
                 }
             }
         }
diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp
index 964db4235..28652870f 100644
--- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp
+++ b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp
@@ -104,8 +104,6 @@ void QCriterionCoProcessor::addData(const SPtr<Block3D> block)
     SPtr<BCArray3D> bcArray                 = kernel->getBCProcessor()->getBCArray();
     SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
 
-    unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
-
     int minX1 = 0;
     int minX2 = 0;
     int minX3 = 0;
@@ -179,6 +177,9 @@ void QCriterionCoProcessor::addData(const SPtr<Block3D> block)
     maxX1 -= 1;
     maxX2 -= 1;
     maxX3 -= 1;
+
+    int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
+
     // cell vector erstellen
     for (int ix3 = minX3; ix3 <= maxX3; ix3++) {
         for (int ix2 = minX2; ix2 <= maxX2; ix2++) {
@@ -189,7 +190,9 @@ void QCriterionCoProcessor::addData(const SPtr<Block3D> block)
                     (NET = nodeNumbers(ix1 + 1, ix2 + 1, ix3 + 1)) >= 0 &&
                     (NWT = nodeNumbers(ix1, ix2 + 1, ix3 + 1)) >= 0) {
                     // for valid points: neighbors are added to cells-vector
-                    cells.push_back(makeUbTuple(SWB, SEB, NEB, NWB, SWT, SET, NET, NWT));
+                    cells.push_back(makeUbTuple((unsigned int)SWB, (unsigned int)SEB, (unsigned int)NEB,
+                                                (unsigned int)NWB, (unsigned int)SWT, (unsigned int)SET,
+                                                (unsigned int)NET, (unsigned int)NWT));
                 }
             }
         }
diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp
index a7d16877f..27f25fbfe 100644
--- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp
+++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp
@@ -252,9 +252,6 @@ void TimeAveragedValuesCoProcessor::addData(const SPtr<Block3D> block)
     SPtr<AverageValuesArray3D> at           = kernel->getDataSet()->getAverageTriplecorrelations();
     // int ghostLayerWidth = kernel->getGhostLayerWidth();
 
-    // knotennummerierung faengt immer bei 0 an!
-    unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
-
     int minX1 = iMinC;
     int minX2 = iMinC;
     int minX3 = iMinC;
@@ -335,6 +332,8 @@ void TimeAveragedValuesCoProcessor::addData(const SPtr<Block3D> block)
     maxX2 -= 1;
     maxX3 -= 1;
 
+    int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
+
     // cell vector erstellen
     for (int ix3 = minX3; ix3 <= maxX3; ix3++) {
         for (int ix2 = minX2; ix2 <= maxX2; ix2++) {
@@ -344,7 +343,9 @@ void TimeAveragedValuesCoProcessor::addData(const SPtr<Block3D> block)
                     (SWT = nodeNumbers(ix1, ix2, ix3 + 1)) >= 0 && (SET = nodeNumbers(ix1 + 1, ix2, ix3 + 1)) >= 0 &&
                     (NET = nodeNumbers(ix1 + 1, ix2 + 1, ix3 + 1)) >= 0 &&
                     (NWT = nodeNumbers(ix1, ix2 + 1, ix3 + 1)) >= 0) {
-                    cells.push_back(makeUbTuple(SWB, SEB, NEB, NWB, SWT, SET, NET, NWT));
+                    cells.push_back(makeUbTuple((unsigned int)SWB, (unsigned int)SEB, (unsigned int)NEB,
+                                                (unsigned int)NWB, (unsigned int)SWT, (unsigned int)SET,
+                                                (unsigned int)NET, (unsigned int)NWT));
                 }
             }
         }
diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp
index 864918f03..b292d40bf 100644
--- a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp
+++ b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp
@@ -114,9 +114,6 @@ void TurbulenceIntensityCoProcessor::addData(const SPtr<Block3D> block)
     SPtr<AverageValuesArray3D> av           = kernel->getDataSet()->getAverageValues();
     // int ghostLayerWidth = kernel->getGhostLayerWidth();
 
-    // knotennummerierung faengt immer bei 0 an!
-    unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
-
     int minX1 = 0;
     int minX2 = 0;
     int minX3 = 0;
@@ -161,6 +158,9 @@ void TurbulenceIntensityCoProcessor::addData(const SPtr<Block3D> block)
             }
         }
     }
+
+    int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT;
+
     // cell std::vector erstellen
     for (int ix3 = minX3; ix3 < maxX3 - 1; ix3++) {
         for (int ix2 = minX2; ix2 < maxX2 - 1; ix2++) {
@@ -170,7 +170,9 @@ void TurbulenceIntensityCoProcessor::addData(const SPtr<Block3D> block)
                     (SWT = nodeNumbers(ix1, ix2, ix3 + 1)) >= 0 && (SET = nodeNumbers(ix1 + 1, ix2, ix3 + 1)) >= 0 &&
                     (NET = nodeNumbers(ix1 + 1, ix2 + 1, ix3 + 1)) >= 0 &&
                     (NWT = nodeNumbers(ix1, ix2 + 1, ix3 + 1)) >= 0) {
-                    cells.push_back(makeUbTuple(SWB, SEB, NEB, NWB, SWT, SET, NET, NWT));
+                    cells.push_back(makeUbTuple((unsigned int)SWB, (unsigned int)SEB, (unsigned int)NEB,
+                                                (unsigned int)NWB, (unsigned int)SWT, (unsigned int)SET,
+                                                (unsigned int)NET, (unsigned int)NWT));
                 }
             }
         }
-- 
GitLab