From 93fa9dfb72b7a12281ea491d5982f4cef6162206 Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Fri, 29 Dec 2017 14:43:30 +0100
Subject: [PATCH] Test field gathering also in case of multiple blocks per
 process

---
 tests/field/CMakeLists.txt      | 3 ++-
 tests/field/FieldGatherTest.cpp | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/field/CMakeLists.txt b/tests/field/CMakeLists.txt
index 47a1549e2..e22e9fe33 100644
--- a/tests/field/CMakeLists.txt
+++ b/tests/field/CMakeLists.txt
@@ -35,7 +35,8 @@ waLBerla_compile_test( FILES adaptors/AdaptorTest.cpp DEPENDS blockforest gui lb
 waLBerla_execute_test( NAME AdaptorTest )
 
 waLBerla_compile_test( FILES FieldGatherTest.cpp DEPENDS blockforest gui )
-waLBerla_execute_test( NAME FieldGatherTest PROCESSES 3 )
+waLBerla_execute_test( NAME FieldGatherTest3 COMMAND $<TARGET_FILE:FieldGatherTest>  PROCESSES 3 )
+waLBerla_execute_test( NAME FieldGatherTest1 COMMAND $<TARGET_FILE:FieldGatherTest>  PROCESSES 1 )
 
 waLBerla_compile_test( FILES FieldFileIOTest.cpp DEPENDS blockforest )
 waLBerla_execute_test( NAME FieldFileIOTest1Proc  COMMAND $<TARGET_FILE:FieldFileIOTest> PROCESSES 1  )
diff --git a/tests/field/FieldGatherTest.cpp b/tests/field/FieldGatherTest.cpp
index 93743df32..8f6645b03 100644
--- a/tests/field/FieldGatherTest.cpp
+++ b/tests/field/FieldGatherTest.cpp
@@ -36,10 +36,11 @@ int main( int argc, char ** argv )
    debug::enterTestMode();
    walberla::Environment walberlaEnv( argc, argv );
 
+   bool oneBlockPerProcess = MPIManager::instance()->numProcesses() != 1;
    auto  blocks = blockforest::createUniformBlockGrid( 1, 3, 1,       // blocks in x,y,z
                                                        10u, 20u, 1u,  // nr of cells per block
                                                        1.0,           // dx
-                                                       true          // one block per process
+                                                       oneBlockPerProcess
                                                        );
    typedef GhostLayerField<cell_idx_t,3> MyField;
    BlockDataID fieldID = field::addToStorage<MyField>( blocks, "Field" );
@@ -65,9 +66,10 @@ int main( int argc, char ** argv )
    boundingBox.min()[ 1 ] = 10;
    boundingBox.max()[ 1 ] = 29;
 
-   field::gather<MyField>( gatheredField, blocks, fieldID, boundingBox,1 );
+   auto targetRank = MPIManager::instance()->numProcesses() -1;
+   field::gather<MyField>( gatheredField, blocks, fieldID, boundingBox, targetRank );
 
-   WALBERLA_EXCLUSIVE_WORLD_SECTION( 1 )
+   WALBERLA_EXCLUSIVE_WORLD_SECTION( targetRank )
    {
       for( auto cellIt = gatheredField.beginXYZ(); cellIt != gatheredField.end(); ++cellIt )
       {
-- 
GitLab