From 96d208201b3f1f0411915bf57f1821f7cf20ee8c Mon Sep 17 00:00:00 2001
From: Rahil Doshi <rahil.doshi@fau.de>
Date: Thu, 20 Jun 2024 14:27:05 +0200
Subject: [PATCH] add print statements for debugging

---
 .gitignore                                      |  2 +-
 .../lbm_unitconversion/pint_unit_converter.py   | 17 ++++++++++++++---
 src/lbm/srt/AdvectionDiffusionSweep.impl.h      |  7 +++++++
 src/lbm/sweeps/CellwiseSweep.h                  |  6 +++++-
 src/lbm/sweeps/Streaming.h                      |  6 ++++++
 src/lbm/sweeps/SweepBase.h                      |  2 ++
 src/timeloop/Timeloop.cpp                       |  3 ++-
 7 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3b5e42021..dda09f671 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,4 +65,4 @@ cmake_install.cmake
 CMakeDefs.h
 /moduleStatistics.json
 /walberla-config.cmake
-cmake-build-*
\ No newline at end of file
+/cmake-build-*
\ No newline at end of file
diff --git a/python/waLBerla/tools/lbm_unitconversion/pint_unit_converter.py b/python/waLBerla/tools/lbm_unitconversion/pint_unit_converter.py
index 83b6ab0f9..c7eb51733 100644
--- a/python/waLBerla/tools/lbm_unitconversion/pint_unit_converter.py
+++ b/python/waLBerla/tools/lbm_unitconversion/pint_unit_converter.py
@@ -88,15 +88,26 @@ class PintUnitConverter:
     def conv_config(self, config):
         result = {}
 
+        def round10(f):
+            s = '%.10g' % f
+            try:
+                return int(s)
+            except ValueError:
+                return float(s)
+            #if int(f) == f:
+            #    print("convert f to int")
+            #    return int(f)
+            #return f
+
         for key,value in config.items():
             if type(value) is dict:
                 result[key] = self.conv_config( value )
             elif type(value) is self.ureg.Quantity:
-                result[key] = self.to_sl_units_mag( value )
+                result[key] = round10(self.to_sl_units_mag( value ))
             elif type(value) is tuple:
-                result[key] = tuple( [ self.to_sl_units_mag(e) for e in value ] )
+                result[key] = tuple( [ round10(self.to_sl_units_mag(e)) for e in value ] )
             elif type(value) is list:
-                result[key] = [ self.to_sl_units_mag(e) for e in value ]
+                result[key] = [ round10(self.to_sl_units_mag(e)) for e in value ]
             else:
                 result[key] = value
 
diff --git a/src/lbm/srt/AdvectionDiffusionSweep.impl.h b/src/lbm/srt/AdvectionDiffusionSweep.impl.h
index c5e37dd84..11a80bd78 100644
--- a/src/lbm/srt/AdvectionDiffusionSweep.impl.h
+++ b/src/lbm/srt/AdvectionDiffusionSweep.impl.h
@@ -1214,13 +1214,18 @@ void AdvectionDiffusionSweep< LM_AdvDiff, VelocityAdapter_T, FlagField_T, Vector
                                  LM_AdvDiff::equilibriumAccuracyOrder == 1
                               >::type > ::stream( IBlock * const block, const uint_t numberOfGhostLayersToInclude )
 {
+    std::cout << "Entering AdvectionDiffusionSweep::stream\n";
    AdvDiffPdfField_T * src( NULL );
    AdvDiffPdfField_T * dst( NULL );
    const FlagField_T * flagField( NULL );
 
    auto lbm = this->getLbmMaskAndFields( block, src, dst, flagField );
+    std::cout << "AdvectionDiffusionSweep::stream::getLbmMaskAndFields src:" << src <<std::endl;
+    std::cout << "AdvectionDiffusionSweep::stream::getLbmMaskAndFields dst:" << dst <<std::endl;
 
    Stream< LM_AdvDiff, FlagField_T >::execute( src, dst, flagField, lbm, numberOfGhostLayersToInclude );
+    std::cout << "AdvectionDiffusionSweep::stream::execute src:" << src <<std::endl;
+    std::cout << "AdvectionDiffusionSweep::stream::execute dst:" << dst <<std::endl;
 }
 
 template< typename LM_AdvDiff, typename VelocityAdapter_T, typename FlagField_T, typename VectorField_T >
@@ -1233,10 +1238,12 @@ void AdvectionDiffusionSweep< LM_AdvDiff, VelocityAdapter_T, FlagField_T, Vector
                                  LM_AdvDiff::equilibriumAccuracyOrder == 1
                               >::type > ::collide( IBlock * const block, const uint_t numberOfGhostLayersToInclude )
 {
+    std::cout << "AdvectionDiffusionSweep::collide\n";
    AdvDiffPdfField_T * src( NULL );
    const FlagField_T * flagField( NULL );
 
    auto lbm = this->getLbmMaskAndFields( block, src, flagField );
+    std::cout << "AdvectionDiffusionSweep::collide::getLbmMaskAndFields src:" << src <<std::endl;
 
    WALBERLA_ASSERT_NOT_NULLPTR( src );
    WALBERLA_ASSERT_NOT_NULLPTR( flagField );
diff --git a/src/lbm/sweeps/CellwiseSweep.h b/src/lbm/sweeps/CellwiseSweep.h
index 2879f19ae..8cb649d36 100644
--- a/src/lbm/sweeps/CellwiseSweep.h
+++ b/src/lbm/sweeps/CellwiseSweep.h
@@ -152,22 +152,26 @@ class CellwiseSweep
    void CellwiseSweep< LatticeModel_T, Filter_T, DensityVelocityIn_T, DensityVelocityOut_T, typename std::enable_if< specialization >::type \
       >::streamCollide( IBlock * const block, const uint_t numberOfGhostLayersToInclude ) \
    { \
+      std::cout << "-----Entering CellwiseSweep::streamCollide-----" << std::endl;                                                                   \
       PdfField_T * src( NULL ); \
       PdfField_T * dst( NULL ); \
       \
       this->getFields( block, src, dst ); \
+        std::cout << "CellwiseSweep::streamCollide src: " << src << std::endl; \
+        std::cout << "CellwiseSweep::streamCollide dst: " << dst << std::endl;                                                                          \
       \
       WALBERLA_ASSERT_GREATER( src->nrOfGhostLayers(), numberOfGhostLayersToInclude ); \
       WALBERLA_ASSERT_GREATER_EQUAL( dst->nrOfGhostLayers(), numberOfGhostLayersToInclude ); \
       \
       const auto & lm = src->latticeModel(); \
       dst->resetLatticeModel( lm ); /* required so that member functions for getting density and equilibrium velocity can be called for dst! */ \
+        std::cout << "CellwiseSweep::streamCollide::resetLatticeModel dst: " << dst << std::endl;                                                                   \
       \
       this->filter( *block ); \
       this->densityVelocityIn( *block ); \
       this->densityVelocityOut( *block );
 
-#define WALBERLA_LBM_CELLWISE_SWEEP_STREAM_COLLIDE_FOOT() src->swapDataPointers( dst ); }
+#define WALBERLA_LBM_CELLWISE_SWEEP_STREAM_COLLIDE_FOOT() src->swapDataPointers( dst ); std::cout << "Data Pointers Swapped in CellwiseSweep!\nCellwiseSweep::streamCollide src: " << src << "\nCellwiseSweep::streamCollide dst: " << dst << std::endl; }
 
 
 
diff --git a/src/lbm/sweeps/Streaming.h b/src/lbm/sweeps/Streaming.h
index f4d87fe4a..42d6ef3a4 100644
--- a/src/lbm/sweeps/Streaming.h
+++ b/src/lbm/sweeps/Streaming.h
@@ -112,6 +112,8 @@ void Stream< LatticeModel_T, FlagField_T, typename std::enable_if< std::is_same<
    >::execute( PdfField_T * src, PdfField_T * dst, const FlagField_T * flagField, const typename FlagField_T::flag_t lbm,
                const uint_t numberOfGhostLayersToInclude )
 {
+    std::cout << "Stream::execute src:" << src << std::endl;
+    std::cout << "Stream::execute dst:" << dst << std::endl;
    WALBERLA_ASSERT_NOT_NULLPTR( src );
    WALBERLA_ASSERT_NOT_NULLPTR( dst );
    WALBERLA_ASSERT_NOT_NULLPTR( flagField );
@@ -149,7 +151,11 @@ void Stream< LatticeModel_T, FlagField_T, typename std::enable_if< std::is_same<
 
    ) // WALBERLA_FOR_ALL_CELLS_INCLUDING_GHOST_LAYER_XYZ
 
+    std::cout << "Stream::execute before swapDataPointers src:" << src << std::endl;
+    std::cout << "Stream::execute before swapDataPointers dst:" << dst << std::endl;
    src->swapDataPointers( dst );
+    std::cout << "Stream::execute after swapDataPointers src:" << src << std::endl;
+    std::cout << "Stream::execute after swapDataPointers dst:" << dst << std::endl;
 }
 
 
diff --git a/src/lbm/sweeps/SweepBase.h b/src/lbm/sweeps/SweepBase.h
index d3389cc60..39015e3d8 100644
--- a/src/lbm/sweeps/SweepBase.h
+++ b/src/lbm/sweeps/SweepBase.h
@@ -113,6 +113,7 @@ SweepBase< LatticeModel_T, Filter_T, DensityVelocityIn_T, DensityVelocityOut_T >
    WALBERLA_ASSERT_NOT_NULLPTR( block );
 
    PdfField_T * src = block->getData<PdfField_T>( src_ );
+    std::cout << "SweepBase::getSrcField src: " << src << std::endl;
    
    WALBERLA_ASSERT_NOT_NULLPTR( src );
    
@@ -146,6 +147,7 @@ SweepBase< LatticeModel_T, Filter_T, DensityVelocityIn_T, DensityVelocityOut_T >
    }
 
    PdfField_T * dst = src->cloneUninitialized();
+    std::cout << "SweepBase::getDstField dst: " << dst << std::endl;
    WALBERLA_ASSERT_NOT_NULLPTR( dst );
    
    // take care of proper thread<->memory assignment (first-touch allocation policy !)
diff --git a/src/timeloop/Timeloop.cpp b/src/timeloop/Timeloop.cpp
index 6b2f548d5..05986bdd7 100644
--- a/src/timeloop/Timeloop.cpp
+++ b/src/timeloop/Timeloop.cpp
@@ -54,8 +54,9 @@ void Timeloop::run( const bool logTimeStep )
 void Timeloop::run( WcTimingPool & tp, const bool logTimeStep )
 {
    WALBERLA_LOG_PROGRESS( "Running timeloop for " << nrOfTimeSteps_ << " time steps" );
-
+   std::cout << "-----Executing Timeloop-----\n";
    while(curTimeStep_ < nrOfTimeSteps_) {
+      std::cout << "\nTimestep: " << curTimeStep_ << std::endl;
       singleStep( tp, logTimeStep );
       if ( stop_ ) {
          stop_ = false;
-- 
GitLab