From b560d5b2a530654ee7ae02279d1e0a98e02cf0ff Mon Sep 17 00:00:00 2001
From: Sebastian Eibl <sebastian.eibl@fau.de>
Date: Fri, 8 Dec 2017 17:15:26 +0100
Subject: [PATCH] made velocity sync buffersystem local

---
 src/pe/cr/HCSITS.h      |  3 ---
 src/pe/cr/HCSITS.impl.h | 18 +++++++++---------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/pe/cr/HCSITS.h b/src/pe/cr/HCSITS.h
index d5fc5075f..896f35808 100644
--- a/src/pe/cr/HCSITS.h
+++ b/src/pe/cr/HCSITS.h
@@ -228,8 +228,6 @@ private:
    domain_decomposition::BlockDataID fcdID_;
    WcTimingTree*                     tt_;
 
-   mpi::BufferSystem                 syncVelBS_;
-
 
    real_t erp_;                       //!< The error reduction parameter (0 <= erp_ <= 1).
    size_t maxIterations_;             //!< Maximum number of iterations.
@@ -263,7 +261,6 @@ private:
    };
    /*! \endcond */
    //**********************************************************************************************
-   std::vector<real_t> reductionBuffer_;                    //!< Buffer for the reduction of forces and torques acting on global non-fixed bodies.
    bool requireSync_;         //!< Flag indicating whether this process requires a synchronization prior to the next time step.
    //@}
    //**********************************************************************************************
diff --git a/src/pe/cr/HCSITS.impl.h b/src/pe/cr/HCSITS.impl.h
index 75dbab023..f36ba3e3e 100644
--- a/src/pe/cr/HCSITS.impl.h
+++ b/src/pe/cr/HCSITS.impl.h
@@ -91,7 +91,6 @@ inline HardContactSemiImplicitTimesteppingSolvers::HardContactSemiImplicitTimest
    , ccdID_(ccdID)
    , fcdID_(fcdID)
    , tt_(tt)
-   , syncVelBS_( mpi::MPIManager::instance()->comm(),  256)
    , erp_              ( real_c(0.8) )
    , maxIterations_    ( 10 )
    , iteration_        ( 0 )
@@ -1480,6 +1479,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
    // STEP1: Send velocities of shadow copies to owner
    //==========================================================
 
+   mpi::BufferSystem syncVelBS( mpi::MPIManager::instance()->comm(),  256);
    std::set<mpi::MPIRank> recvRanks; // potential message senders
    for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt)
    {
@@ -1497,7 +1497,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
       {
          i = body->index_;
 
-         mpi::SendBuffer& sb = syncVelBS_.sendBuffer( body->MPITrait.getOwner().rank_ );
+         mpi::SendBuffer& sb = syncVelBS.sendBuffer( body->MPITrait.getOwner().rank_ );
          if (sb.isEmpty()) sb << walberla::uint8_c(0);
 
          if( bodyCache.dv_[i] == Vec3() && bodyCache.dw_[i] == Vec3() ) {
@@ -1532,8 +1532,8 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
    //   size_t sum = bs.size();
    //   mpi::reduceInplace(sum, mpi::SUM);
    //   WALBERLA_LOG_DEVEL_ON_ROOT("communication size: " << sum);
-   syncVelBS_.setReceiverInfo(recvRanks, true);
-   syncVelBS_.sendAll();
+   syncVelBS.setReceiverInfo(recvRanks, true);
+   syncVelBS.sendAll();
 
    if (tt_ != NULL) tt_->stop("Velocity Sync Correction Communicate");
 
@@ -1545,7 +1545,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
    // Receiving force and torque contributions
    WALBERLA_LOG_DETAIL( "Parsing of velocity correction message starts...");
 
-   for( auto it = syncVelBS_.begin(); it != syncVelBS_.end(); ++it )
+   for( auto it = syncVelBS.begin(); it != syncVelBS.end(); ++it )
    {
       //      if (tt_ != NULL) tt_->start("Inside Loop");
       walberla::uint8_t tmp;
@@ -1604,7 +1604,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
 
          for( auto shadow = body->MPITrait.beginShadowOwners(); shadow != body->MPITrait.endShadowOwners(); ++shadow ) {
 
-            mpi::SendBuffer& sb = syncVelBS_.sendBuffer( shadow->rank_ );
+            mpi::SendBuffer& sb = syncVelBS.sendBuffer( shadow->rank_ );
             if (sb.isEmpty()) sb << walberla::uint8_c(0);
             packNotificationWithoutSender(*shadow, sb, RigidBodyVelocityCorrectionNotification( *(*body), bodyCache.v_[i], bodyCache.w_[i] ));
 
@@ -1628,8 +1628,8 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
 
    WALBERLA_LOG_DETAIL( "Communication of velocity update message starts...");
 
-   syncVelBS_.setReceiverInfo(recvRanks, true);
-   syncVelBS_.sendAll();
+   syncVelBS.setReceiverInfo(recvRanks, true);
+   syncVelBS.sendAll();
 
    if (tt_ != NULL) tt_->stop("Velocity Sync Update Communincate");
 
@@ -1641,7 +1641,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::synchronizeVelocities( )
    // Receiving velocity updates
    WALBERLA_LOG_DETAIL( "Parsing of velocity update message starts...");
 
-   for( auto it = syncVelBS_.begin(); it != syncVelBS_.end(); ++it )
+   for( auto it = syncVelBS.begin(); it != syncVelBS.end(); ++it )
    {
       //      if (tt_ != NULL) tt_->start("Inside Loop");
       walberla::uint8_t tmp;
-- 
GitLab