From 17f42335a956f7e8b8083df5c22c73199a3200bd Mon Sep 17 00:00:00 2001
From: Hkorb <henry.korb@geo.uu.se>
Date: Tue, 21 Sep 2021 12:23:40 +0200
Subject: [PATCH] some more minor cleanup

---
 src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h |  2 +-
 .../Visitor/Probes/PlaneProbe.cu              |  7 ++--
 .../Visitor/Probes/PlaneProbe.h               |  6 ++--
 .../Visitor/Probes/PointProbe.h               |  6 ++--
 .../VirtualFluids_GPU/Visitor/Probes/Probe.cu |  2 ++
 .../VirtualFluids_GPU/Visitor/Probes/Probe.h  | 14 ++++----
 src/gpu/VirtualFluids_GPU/Visitor/Visitor.h   | 36 +++++--------------
 7 files changed, 28 insertions(+), 45 deletions(-)

diff --git a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h
index 0cf4c0ddf..63473780c 100644
--- a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h
+++ b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h
@@ -180,7 +180,7 @@ __inline__ __host__ __device__ uint findNearestCellBSW(uint index,
                                               real posX, real posY, real posZ, 
                                               uint* neighborsX, uint* neighborsY, uint* neighborsZ, uint* neighborsWSB)
 {
-        uint new_index = index;
+    uint new_index = index;
 
     while(coordsX[new_index] > posX && coordsY[new_index] > posY && coordsZ[new_index] > posZ ){ new_index = max(1, neighborsWSB[new_index]);}
 
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.cu b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.cu
index ef7b8cfd4..440f60d81 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.cu
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.cu
@@ -11,9 +11,9 @@
 #include "GPU/CudaMemoryManager.h"
 
 void PlaneProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level,
-                       std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
-                       std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
-                       int level)
+                            std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
+                            std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
+                            int level)
 {
     real dx = abs(para->getParH(level)->coordX_SP[1]-para->getParH(level)->coordX_SP[para->getParH(level)->neighborX_SP[1]]);
     for(uint j=1; j<para->getParH(level)->size_Mat_SP; j++ )
@@ -38,6 +38,7 @@ void PlaneProbe::findPoints(Parameter* para, GridProvider* gridProvider, std::ve
         }
     }
 }
+
 void PlaneProbe::calculateQuantities(ProbeStruct* probeStruct, Parameter* para, int level)
 {
     vf::gpu::CudaGrid grid = vf::gpu::CudaGrid(128, probeStruct->nPoints);
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.h b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.h
index d0ce3aee1..52f8d2808 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.h
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PlaneProbe.h
@@ -29,9 +29,9 @@ public:
 
 private:
     void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level,
-                       std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
-                       std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
-                       int level) override;
+                    std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
+                    std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
+                    int level) override;
     void calculateQuantities(ProbeStruct* probeStruct, Parameter* para, int level) override;
 
 private:
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PointProbe.h b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PointProbe.h
index ac3d46cc3..73b7bdfc8 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Probes/PointProbe.h
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Probes/PointProbe.h
@@ -22,9 +22,9 @@ public:
     
 private:
     void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level,
-                       std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
-                       std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
-                       int level) override;
+                    std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
+                    std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level,
+                    int level) override;
 
     void calculateQuantities(ProbeStruct* probeStruct, Parameter* para, int level) override;
 
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.cu b/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.cu
index f9ffc5e82..063792712 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.cu
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.cu
@@ -12,6 +12,7 @@
 #include "DataStructureInitializer/GridProvider.h"
 #include "GPU/CudaMemoryManager.h"
 
+
 std::vector<std::string> getPostProcessingVariableNames(PostProcessingVariable variable)
 {
     std::vector<std::string> varNames;
@@ -43,6 +44,7 @@ __device__ void calculateQuantities(uint n, real* quantityArray, bool* quantitie
 
     if(quantities[int(PostProcessingVariable::Means)])
     {
+        
         uint arrOff = quantityArrayOffsets[int(PostProcessingVariable::Means)];
         real vx_m_old  = quantityArray[(arrOff+0)*nPoints+node];
         real vy_m_old  = quantityArray[(arrOff+1)*nPoints+node];
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.h b/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.h
index 0ae5dddc0..abb924d9b 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.h
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Probes/Probe.h
@@ -36,6 +36,7 @@ __global__ void interpQuantities(   uint* pointIndices,
                                     bool interpolate
                                 );
 
+
 class Probe : public Visitor 
 {
 public:
@@ -52,21 +53,13 @@ public:
     {
         assert("Output starts before averaging!" && tStartOut>=tStartAvg);
     }
-
     void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager);
     void visit(Parameter* para, CudaMemoryManager* cudaManager, int level, uint t);
     void free(Parameter* para, CudaMemoryManager* cudaManager);
 
-    ProbeStruct* getProbeStruct(int level){ return this->probeParams[level]; }
     
-
     void addPostProcessingVariable(PostProcessingVariable _variable);
 
-    void write(Parameter* para, int level, int t);
-    void writeCollectionFile(Parameter* para, int t);
-    void writeGridFiles(Parameter* para, int level, std::vector<std::string >& fnames, int t);
-    std::vector<std::string> getVarNames();
-
 private:
     virtual void findPoints(Parameter* para, GridProvider* gridProvider, std::vector<int>& probeIndices_level,
                        std::vector<real>& distX_level, std::vector<real>& distY_level, std::vector<real>& distZ_level,      
@@ -78,7 +71,12 @@ private:
                         int level);
     virtual void calculateQuantities(ProbeStruct* probeStruct, Parameter* para, int level) = 0;
 
+    ProbeStruct* getProbeStruct(int level){ return this->probeParams[level]; }
 
+    void write(Parameter* para, int level, int t);
+    void writeCollectionFile(Parameter* para, int t);
+    void writeGridFiles(Parameter* para, int level, std::vector<std::string >& fnames, int t);
+    std::vector<std::string> getVarNames();
     
 private:
     const std::string probeName;
diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Visitor.h b/src/gpu/VirtualFluids_GPU/Visitor/Visitor.h
index 46b4f8dc7..41265ea8f 100644
--- a/src/gpu/VirtualFluids_GPU/Visitor/Visitor.h
+++ b/src/gpu/VirtualFluids_GPU/Visitor/Visitor.h
@@ -1,11 +1,11 @@
 #ifndef Visitor_H
 #define Visitor_H
 
-#include <vector>
 #include <string>
+#include <vector>
 
-#include "PointerDefinitions.h"
 #include "Core/DataTypes.h"
+#include "PointerDefinitions.h"
 #include "VirtualFluids_GPU_export.h"
 
 #include <cassert>
@@ -14,12 +14,10 @@ class Parameter;
 class GridProvider;
 class CudaMemoryManager;
 
-
 class VIRTUALFLUIDS_GPU_EXPORT Visitor
 {
-private: 
-	SPtr<Parameter> para;
-
+private:
+    SPtr<Parameter> para;
 
 protected:
     Visitor()
@@ -28,32 +26,16 @@ protected:
     }
 
 public:
-    virtual ~Visitor() {}
-
-    virtual void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager)=0;
-    virtual void visit(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t)=0;
-    virtual void free(Parameter* para, CudaMemoryManager* cudaManager)=0;
-
-    ////////////////////////////////////////////////////////////////////////////
-    /// \brief setUpdateInterval
-    /// \param _updateInterval
-    /// \note usage: setUpdateInterval(this->tout);
-    /// \note usage: setUpdateInterval(div_ru(this->tout,10U));
-    ///
-    void setUpdateInterval(const uint &_updateInterval)
+    virtual ~Visitor()
     {
-        assert(_updateInterval>0);
-        this->updateInterval = _updateInterval;
     }
 
-    bool isDue(const uint &tLB) const
-    {
-        return (tLB%this->updateInterval==0);
-    }
+    virtual void init(Parameter *para, GridProvider *gridProvider, CudaMemoryManager *cudaManager) = 0;
+    virtual void visit(Parameter *para, CudaMemoryManager *cudaManager, int level, uint t) = 0;
+    virtual void free(Parameter *para, CudaMemoryManager *cudaManager) = 0;
 
 protected:
-    uint updateInterval;                                                        ///< update interval in number of timesteps of the coarse patch (1 = each time step)
-
+    uint updateInterval;
 };
 
 #endif
\ No newline at end of file
-- 
GitLab