diff --git a/python/mesa_pd/templates/mpi/SyncGhostOwners.templ.cpp b/python/mesa_pd/templates/mpi/SyncGhostOwners.templ.cpp index 24c4928f3545dcb9c6bc4944f6eaefe6030d5562..ce0475880157e7de39dc696d5b48b805c85aec7a 100644 --- a/python/mesa_pd/templates/mpi/SyncGhostOwners.templ.cpp +++ b/python/mesa_pd/templates/mpi/SyncGhostOwners.templ.cpp @@ -181,6 +181,7 @@ void SyncGhostOwners::updateAndMigrate( data::ParticleStorage& ps, // Receiving the updates for the remote rigid bodies from the connected processes WALBERLA_LOG_DETAIL( "Parsing of Update&Migrate starts..." ); ParseMessage parseMessage; + parseMessage.allowMultipleGhostCopyNotifications(true); for( auto it = bs1.begin(); it != bs1.end(); ++it ) { walberla::uint8_t tmp; @@ -338,6 +339,7 @@ void SyncGhostOwners::checkAndResolveOverlap( data::ParticleStorage& ps, // Receiving the updates for the remote rigid bodies from the connected processes WALBERLA_LOG_DETAIL( "Parsing of Check&Resolve starts..." ); ParseMessage parseMessage; + parseMessage.allowMultipleGhostCopyNotifications(true); for( auto it = bs2.begin(); it != bs2.end(); ++it ) { walberla::uint8_t tmp; diff --git a/python/mesa_pd/templates/mpi/notifications/ParseMessage.templ.h b/python/mesa_pd/templates/mpi/notifications/ParseMessage.templ.h index 77af0197c9e88b355faafb5600cc4f396d911167..8da120f08e06ae5301577d9b5e4df03fe892890e 100644 --- a/python/mesa_pd/templates/mpi/notifications/ParseMessage.templ.h +++ b/python/mesa_pd/templates/mpi/notifications/ParseMessage.templ.h @@ -52,8 +52,11 @@ public: walberla::mpi::RecvBuffer& rb, data::ParticleStorage& ps, const domain::IDomain& domain); + void allowMultipleGhostCopyNotifications(bool val) {allowMultipleGhostCopyNotifications_ = val;} private: int receiver_ = int_c( walberla::mpi::MPIManager::instance()->rank() ); + + bool allowMultipleGhostCopyNotifications_ = false; }; inline @@ -82,7 +85,14 @@ void ParseMessage::operator()(int sender, data::particle_flags::set(pIt->getFlagsRef(), data::particle_flags::GHOST); } else { - WALBERLA_LOG_DETAIL("Ghost particle with id " << objparam.uid << " already existend."); + if (allowMultipleGhostCopyNotifications_) + { + //superfluous ghost creation messages might be send during ghost owner sync + WALBERLA_LOG_DETAIL("Ghost particle with id " << objparam.uid << " already existend."); + } else + { + WALBERLA_ABORT("Ghost particle with id " << objparam.uid << " already existend."); + } } WALBERLA_LOG_DETAIL( "Processed PARTICLE_GHOST_COPY_NOTIFICATION for particle " << objparam.uid << "." ); diff --git a/src/mesa_pd/domain/BlockForestDataHandling.cpp b/src/mesa_pd/domain/BlockForestDataHandling.cpp index 9ff515cc4bc57f684e9649e35c6f05eb8c66c0b5..1a75c13849263038235113f8500dc17c698fd361 100644 --- a/src/mesa_pd/domain/BlockForestDataHandling.cpp +++ b/src/mesa_pd/domain/BlockForestDataHandling.cpp @@ -97,7 +97,6 @@ void BlockForestDataHandling::serialize( IBlock * const block, //skip globals if (data::particle_flags::isSet( pIt->getFlags(), data::particle_flags::GLOBAL)) continue; - pIt->getGhostOwnersRef().clear(); buffer << ParticleCopyNotification( *pIt ); ++numOfParticles; } @@ -141,7 +140,6 @@ void BlockForestDataHandling::serializeCoarseToFine( Block * const block, const if( childAABB.contains( pIt->getPosition()) ) { - pIt->getGhostOwnersRef().clear(); buffer << ParticleCopyNotification( *pIt ); ++numOfParticles; } @@ -166,7 +164,6 @@ void BlockForestDataHandling::serializeFineToCoarse( Block * const block, const //skip globals if (data::particle_flags::isSet( pIt->getFlags(), data::particle_flags::GLOBAL)) continue; - pIt->getGhostOwnersRef().clear(); buffer << ParticleCopyNotification( *pIt ); ++numOfParticles; } diff --git a/src/mesa_pd/mpi/SyncGhostOwners.cpp b/src/mesa_pd/mpi/SyncGhostOwners.cpp index 887244bd5dc7ce864db2de935b8c5a2fbbeec34d..7f115fdb214350ef0c3b4cc9714a1a71c6d4be9f 100644 --- a/src/mesa_pd/mpi/SyncGhostOwners.cpp +++ b/src/mesa_pd/mpi/SyncGhostOwners.cpp @@ -181,6 +181,7 @@ void SyncGhostOwners::updateAndMigrate( data::ParticleStorage& ps, // Receiving the updates for the remote rigid bodies from the connected processes WALBERLA_LOG_DETAIL( "Parsing of Update&Migrate starts..." ); ParseMessage parseMessage; + parseMessage.allowMultipleGhostCopyNotifications(true); for( auto it = bs1.begin(); it != bs1.end(); ++it ) { walberla::uint8_t tmp; @@ -338,6 +339,7 @@ void SyncGhostOwners::checkAndResolveOverlap( data::ParticleStorage& ps, // Receiving the updates for the remote rigid bodies from the connected processes WALBERLA_LOG_DETAIL( "Parsing of Check&Resolve starts..." ); ParseMessage parseMessage; + parseMessage.allowMultipleGhostCopyNotifications(true); for( auto it = bs2.begin(); it != bs2.end(); ++it ) { walberla::uint8_t tmp; diff --git a/src/mesa_pd/mpi/notifications/ParseMessage.h b/src/mesa_pd/mpi/notifications/ParseMessage.h index 741f1950e94b6b971dee05adc3b85240e8642715..b865c131e322b50f9d747ba5ddb6ba8ac14c87ab 100644 --- a/src/mesa_pd/mpi/notifications/ParseMessage.h +++ b/src/mesa_pd/mpi/notifications/ParseMessage.h @@ -52,8 +52,11 @@ public: walberla::mpi::RecvBuffer& rb, data::ParticleStorage& ps, const domain::IDomain& domain); + void allowMultipleGhostCopyNotifications(bool val) {allowMultipleGhostCopyNotifications_ = val;} private: int receiver_ = int_c( walberla::mpi::MPIManager::instance()->rank() ); + + bool allowMultipleGhostCopyNotifications_ = false; }; inline @@ -82,7 +85,14 @@ void ParseMessage::operator()(int sender, data::particle_flags::set(pIt->getFlagsRef(), data::particle_flags::GHOST); } else { - WALBERLA_LOG_DETAIL("Ghost particle with id " << objparam.uid << " already existend."); + if (allowMultipleGhostCopyNotifications_) + { + //superfluous ghost creation messages might be send during ghost owner sync + WALBERLA_LOG_DETAIL("Ghost particle with id " << objparam.uid << " already existend."); + } else + { + WALBERLA_ABORT("Ghost particle with id " << objparam.uid << " already existend."); + } } WALBERLA_LOG_DETAIL( "Processed PARTICLE_GHOST_COPY_NOTIFICATION for particle " << objparam.uid << "." ); diff --git a/tests/mesa_pd/domain/SerializeDeserialize.cpp b/tests/mesa_pd/domain/SerializeDeserialize.cpp index 76a8bfe86e26be902ec50a05995eac93dc81b1fd..49517852b46279e26e24a5e09d03dff0cbcd604f 100644 --- a/tests/mesa_pd/domain/SerializeDeserialize.cpp +++ b/tests/mesa_pd/domain/SerializeDeserialize.cpp @@ -21,8 +21,10 @@ #include <mesa_pd/data/DataTypes.h> #include <mesa_pd/domain/BlockForestDataHandling.h> #include <mesa_pd/domain/BlockForestDomain.h> +#include <mesa_pd/data/ParticleAccessor.h> #include <mesa_pd/data/ParticleStorage.h> #include <mesa_pd/data/ShapeStorage.h> +#include <mesa_pd/mpi/ClearNextNeighborSync.h> #include <mesa_pd/mpi/SyncNextNeighbors.h> #include <blockforest/Initialization.h> @@ -31,6 +33,7 @@ #include <core/grid_generator/SCIterator.h> #include <core/mpi/Reduce.h> #include <core/logging/Logging.h> +#include <mesa_pd/kernel/ParticleSelector.h> namespace walberla { namespace mesa_pd { @@ -42,6 +45,7 @@ void createDump() WALBERLA_LOG_INFO_ON_ROOT("*** MESA_PD ***"); auto ps = std::make_shared<data::ParticleStorage>(100); + auto ac = data::ParticleAccessor(ps); auto ss = std::make_shared<data::ShapeStorage>(); auto smallSphere = ss->create<data::Sphere>(radius); @@ -98,11 +102,14 @@ void createDump() WALBERLA_CHECK_EQUAL(ps->size(), 28); + mesa_pd::mpi::ClearNextNeighborSync CSNN; mesa_pd::mpi::SyncNextNeighbors SNN; SNN(*ps, domain); + CSNN(ac); WALBERLA_LOG_DEVEL_ON_ROOT("dumping simulation"); forest->saveBlockData("SerializeDeserialize.dump", bfDataHandlingID); + SNN(*ps, domain); } void checkDump()