From 2b759f57b7a59fa6171f6e7c7bc05a4bd96d7418 Mon Sep 17 00:00:00 2001
From: Christoph Rettinger <christoph.rettinger@fau.de>
Date: Fri, 1 Dec 2017 10:07:55 +0100
Subject: [PATCH] Added assert msg and log detail output to lbm refinement
 functionality

---
 src/lbm/refinement/PdfFieldPackInfo.h | 36 ++++++-------
 src/lbm/refinement/TimeStep.h         | 75 ++++++++++++++++++++-------
 2 files changed, 75 insertions(+), 36 deletions(-)

diff --git a/src/lbm/refinement/PdfFieldPackInfo.h b/src/lbm/refinement/PdfFieldPackInfo.h
index e993a449d..6fbfb9221 100644
--- a/src/lbm/refinement/PdfFieldPackInfo.h
+++ b/src/lbm/refinement/PdfFieldPackInfo.h
@@ -658,7 +658,7 @@ void PdfFieldPackInfo< LatticeModel_T, BoundaryHandling_T >::communicateLocalCoa
 
 #ifndef NDEBUG
                if( boundaryHandling->isDomain(sx,sy,sz) )
-                  WALBERLA_ASSERT( !math::isnan( sf->get( sx, sy, sz, idx ) ) );
+                  WALBERLA_ASSERT( !math::isnan( sf->get( sx, sy, sz, idx ) ), sx << ", " << sy << ", " << sz << ", " << idx << " coarse sender block = " << coarseSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
 #endif
                }
                rx += cell_idx_t(2);
@@ -697,7 +697,7 @@ void PdfFieldPackInfo< LatticeModel_T, BoundaryHandling_T >::communicateLocalCoa
 
 #ifndef NDEBUG
                if( boundaryHandling->isDomain(sx,sy,sz) )
-                  WALBERLA_ASSERT( !math::isnan( value ) );
+                  WALBERLA_ASSERT( !math::isnan( value ), "value at " << sx << ", " << sy << ", " << sz << ", " << idx << " coarse sender block = " << coarseSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
 #endif
 
                   rf->get( rx,                 ry,                 rz,                 idx ) = value;
@@ -779,16 +779,16 @@ void PdfFieldPackInfo< LatticeModel_T, BoundaryHandling_T >::packDataFineToCoars
 #ifndef NDEBUG
                if( boundaryHandling->isDomain(x,y,z) )
                {
-                  WALBERLA_ASSERT( !math::isnan( field->get( x,                 y,                 z,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y,                 z,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( field->get( x,                 y + cell_idx_t(1), z,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y + cell_idx_t(1), z,                 idx ) ) );
+                  WALBERLA_ASSERT( !math::isnan( field->get( x,                 y,                 z,                 idx ) ), x << ", " << y << ", " << z << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                  WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y,                 z,                 idx ) ), x + cell_idx_t(1) << ", " << y << ", " << z << ", " << idx <<" fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
+                  WALBERLA_ASSERT( !math::isnan( field->get( x,                 y + cell_idx_t(1), z,                 idx ) ), x << ", " << y + cell_idx_t(1) << ", " << z << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
+                  WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y + cell_idx_t(1), z,                 idx ) ), x + cell_idx_t(1) << ", " << y + cell_idx_t(1) << ", " << z << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
                   if( Stencil::D == uint_t(3) )
                   {
-                     WALBERLA_ASSERT( !math::isnan( field->get( x,                 y,                 z + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y,                 z + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( field->get( x,                 y + cell_idx_t(1), z + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y + cell_idx_t(1), z + cell_idx_t(1), idx ) ) );
+                     WALBERLA_ASSERT( !math::isnan( field->get( x,                 y,                 z + cell_idx_t(1), idx ) ), x << ", " << y << ", " << z + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> "  );
+                     WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y,                 z + cell_idx_t(1), idx ) ), x + cell_idx_t(1) << ", " << y << ", " << z + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
+                     WALBERLA_ASSERT( !math::isnan( field->get( x,                 y + cell_idx_t(1), z + cell_idx_t(1), idx ) ), x << ", " << y + cell_idx_t(1) << ", " << z + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
+                     WALBERLA_ASSERT( !math::isnan( field->get( x + cell_idx_t(1), y + cell_idx_t(1), z + cell_idx_t(1), idx ) ), x + cell_idx_t(1) << ", " << y + cell_idx_t(1) << ", " << z + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> " );
                   }
                }
 #endif
@@ -925,16 +925,16 @@ void PdfFieldPackInfo< LatticeModel_T, BoundaryHandling_T >::communicateLocalFin
 #ifndef NDEBUG
                if( boundaryHandling->isDomain(sx,sy,sz) )
                {
-                  WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy,                 sz,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy,                 sz,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy + cell_idx_t(1), sz,                 idx ) ) );
-                  WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy + cell_idx_t(1), sz,                 idx ) ) );
+                  WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy,                 sz,                 idx ) ), sx << ", " << sy << ", " << sz << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                  WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy,                 sz,                 idx ) ), sx + cell_idx_t(1) << ", " << sy << ", " << sz << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                  WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy + cell_idx_t(1), sz,                 idx ) ), sx << ", " << sy + cell_idx_t(1) << ", " << sz << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                  WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy + cell_idx_t(1), sz,                 idx ) ), sx + cell_idx_t(1) << ", " << sy + cell_idx_t(1) << ", " << sz << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
                   if( Stencil::D == uint_t(3) )
                   {
-                     WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy,                 sz + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy,                 sz + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy + cell_idx_t(1), sz + cell_idx_t(1), idx ) ) );
-                     WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy + cell_idx_t(1), sz + cell_idx_t(1), idx ) ) );
+                     WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy,                 sz + cell_idx_t(1), idx ) ), sx << ", " << sy << ", " << sz + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                     WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy,                 sz + cell_idx_t(1), idx ) ), sx + cell_idx_t(1) << ", " << sy << ", " << sz + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                     WALBERLA_ASSERT( !math::isnan( sf->get( sx,                 sy + cell_idx_t(1), sz + cell_idx_t(1), idx ) ), sx << ", " << sy + cell_idx_t(1) << ", " << sz + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
+                     WALBERLA_ASSERT( !math::isnan( sf->get( sx + cell_idx_t(1), sy + cell_idx_t(1), sz + cell_idx_t(1), idx ) ), sx + cell_idx_t(1) << ", " << sy + cell_idx_t(1) << ", " << sz + cell_idx_t(1) << ", " << idx << " fine sender block = " << fineSender->getId() << " in dir <" << stencil::cx[dir] << "," << stencil::cy[dir] << "," << stencil::cz[dir] << "> ");
                   }
                }
 #endif
diff --git a/src/lbm/refinement/TimeStep.h b/src/lbm/refinement/TimeStep.h
index 53f8b355a..f006d0494 100644
--- a/src/lbm/refinement/TimeStep.h
+++ b/src/lbm/refinement/TimeStep.h
@@ -1591,91 +1591,130 @@ void TimeStep< LatticeModel_T, Sweep_T, BoundaryHandling_T >::recursiveStep( con
 
    std::vector< Block * > blocks = selectedBlocks( level );
 
+   WALBERLA_LOG_DETAIL("Starting recursive step with level " << level << " and execution count " << executionCount);
+
    if( asynchronousCommunication_ && level != coarsestLevel )
    {
+      WALBERLA_LOG_DETAIL("Start communication coarse to fine, initiated by fine level " << level );
       startCommunicationCoarseToFine( level ); // [start] explosion (initiated by fine level, involves "level" and "level-1")
    }
 
+   WALBERLA_LOG_DETAIL("Colliding on level " << level);
    collide( blocks, level, executionCount1st );
 
    if( asynchronousCommunication_ )
    {
+      WALBERLA_LOG_DETAIL("Start communication equal level, initiated by level " << level );
       startCommunicationEqualLevel( level ); // [start] equal level communication
    }
 
    if( level != finestLevel )
    {
+      WALBERLA_LOG_DETAIL("Calling recursive step with level " << level + uint_t(1) << " and execution count " << executionCount1st );
       recursiveStep( level + uint_t(1), executionCount1st );
 
-      if( asynchronousCommunication_ )
-         startCommunicationFineToCoarse( level + uint_t(1) ); // [start] coalescence (initiated by coarse level)
+      if( asynchronousCommunication_ ) {
+         WALBERLA_LOG_DETAIL("Start communication fine to coarse, initiated by coarse level " << level );
+         startCommunicationFineToCoarse(level + uint_t(1)); // [start] coalescence (initiated by coarse level)
+      }
    }
 
    if( level != coarsestLevel )
    {
-      if( !asynchronousCommunication_ )
-         startCommunicationCoarseToFine( level ); // [start] explosion (initiated by fine level, involves "level" and "level-1")
+      if( !asynchronousCommunication_ ) {
+         WALBERLA_LOG_DETAIL("Start communication coarse to fine, initiated by fine level " << level );
+         startCommunicationCoarseToFine(level); // [start] explosion (initiated by fine level, involves "level" and "level-1")
+      }
+      WALBERLA_LOG_DETAIL("End communication coarse to fine, initiated by fine level " << level );
       endCommunicationCoarseToFine( level ); // [end] explosion (initiated by fine level, involves "level" and "level-1")
+      WALBERLA_LOG_DETAIL("Perform linear explosion on level " << level );
       performLinearExplosion( blocks, level );
    }
 
-   if( !asynchronousCommunication_ )
-      startCommunicationEqualLevel( level ); // [start] equal level communication
+   if( !asynchronousCommunication_ ) {
+      WALBERLA_LOG_DETAIL("Start communication equal level, initiated by level " << level );
+      startCommunicationEqualLevel(level); // [start] equal level communication
+   }
+   WALBERLA_LOG_DETAIL("End communication equal level, initiated by level " << level );
    endCommunicationEqualLevel( level ); // [end] equal level communication
 
    // performLinearExplosion( blocks, level ); // if equal level neighbor values are needed, linear explosion should be performed here
 
    if( level == finestLevel && level != coarsestLevel )
    {
+      WALBERLA_LOG_DETAIL("Stream + collide on level " << level );
       streamCollide( blocks, level, executionCount1st );
    }
    else
    {
+      WALBERLA_LOG_DETAIL("Stream on level " << level );
       stream( blocks, level, executionCount1st );
 
       if( level != finestLevel )
       {
-         if( !asynchronousCommunication_ )
-            startCommunicationFineToCoarse( level + uint_t(1) ); // [start] coalescence (initiated by coarse level)
+         if( !asynchronousCommunication_ ) {
+            WALBERLA_LOG_DETAIL("Start communication fine to coarse, initiated by coarse level " << level );
+            startCommunicationFineToCoarse(level + uint_t(1)); // [start] coalescence (initiated by coarse level)
+         }
+         WALBERLA_LOG_DETAIL("End communication fine to coarse, initiated by coarse level " << level );
          endCommunicationFineToCoarse( level + uint_t(1) ); // [end] coalescence (initiated by coarse level)
       }
-      
+
+      WALBERLA_LOG_DETAIL("Finish stream on level " << level );
       finishStream( blocks, level, executionCount1st );
 
       if( level == coarsestLevel )
+      {
+         WALBERLA_LOG_DETAIL("End recursive step on level " << level );
          return;
+      }
 
+      WALBERLA_LOG_DETAIL("Colliding on level " << level);
       collide( blocks, level, executionCount2nd );
    }
 
-   if( asynchronousCommunication_ )
-      startCommunicationEqualLevel( level ); // [start] equal level communication
+   if( asynchronousCommunication_ ) {
+      WALBERLA_LOG_DETAIL("Start communication equal level, initiated by level " << level );
+      startCommunicationEqualLevel(level); // [start] equal level communication
+   }
 
    if( level != finestLevel )
    {
+      WALBERLA_LOG_DETAIL("Calling recursive step with level " << level + uint_t(1) << " and execution count " << executionCount2nd );
       recursiveStep( level + uint_t(1), executionCount2nd );
    
-      if( asynchronousCommunication_ )
-         startCommunicationFineToCoarse( level + uint_t(1) ); // [start] coalescence (initiated by coarse level)
+      if( asynchronousCommunication_ ) {
+         WALBERLA_LOG_DETAIL("Start communication fine to coarse, initiated by coarse level " << level );
+         startCommunicationFineToCoarse(level + uint_t(1)); // [start] coalescence (initiated by coarse level)
+      }
    }
 
-   if( !asynchronousCommunication_ )
-      startCommunicationEqualLevel( level ); // [start] equal level communication
+   if( !asynchronousCommunication_ ) {
+      WALBERLA_LOG_DETAIL("Start communication equal level, initiated by level " << level );
+      startCommunicationEqualLevel(level); // [start] equal level communication
+   }
+   WALBERLA_LOG_DETAIL("End communication equal level, initiated by level " << level );
    endCommunicationEqualLevel( level ); // [end] equal level communication
 
+   WALBERLA_LOG_DETAIL("Stream on level " << level );
    stream( blocks, level, executionCount2nd );
 
    if( level != finestLevel )
    {
       if( !asynchronousCommunication_ )
+      {
+         WALBERLA_LOG_DETAIL("Start communication fine to coarse, initiated by coarse level " << level );
          startCommunicationFineToCoarse( level + uint_t(1) ); // [start] coalescence (initiated by coarse level)
+      }
+      WALBERLA_LOG_DETAIL("End communication fine to coarse, initiated by coarse level " << level );
       endCommunicationFineToCoarse( level + uint_t(1) ); // [end] coalescence (initiated by coarse level)
    }
-   
-   finishStream( blocks, level, executionCount2nd );
-}
 
+   WALBERLA_LOG_DETAIL("Finish stream on level " << level );
+   finishStream( blocks, level, executionCount2nd );
 
+   WALBERLA_LOG_DETAIL("End recursive step on level " << level );
+}
 
 
 
-- 
GitLab