Skip to content
Snippets Groups Projects
Commit 5faf8752 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

reworked best practise for serialize / deserialize

parent 26ef8fed
No related merge requests found
......@@ -91,7 +91,7 @@ inline void StorageDataHandling<BodyTuple>::deserialize( IBlock * const block, c
if ( !block->getAABB().contains( bd->getPosition()) )
{
WALBERLA_ABORT("Loaded body not contained within block!" );
WALBERLA_ABORT("Loaded body not contained within block!\n" << block->getAABB() << "\n" << bd );
}
WALBERLA_ASSERT_EQUAL(localBodyStorage.find( bd->getSystemID() ), localBodyStorage.end());
localBodyStorage.add(bd);
......
......@@ -38,7 +38,10 @@ shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain,
const Vector3<bool> isPeriodic,
const uint_t numberOfProcesses)
{
MPIManager::instance()->useWorldComm();
WALBERLA_MPI_SECTION()
{
MPIManager::instance()->useWorldComm();
}
if (isPeriodic[0] && blocks[0]<2)
{
......@@ -73,7 +76,10 @@ shared_ptr<BlockForest> createBlockForest(const math::AABB simulationDomain,
const std::string sbffile,
const uint_t numberOfProcesses)
{
MPIManager::instance()->useWorldComm();
WALBERLA_MPI_SECTION()
{
MPIManager::instance()->useWorldComm();
}
if (isPeriodic[0] && blocks[0]<2)
{
......
......@@ -64,7 +64,15 @@ waLBerla_compile_test( NAME PE_RIGIDBODY FILES RigidBody.cpp DEPENDS core )
waLBerla_execute_test( NAME PE_RIGIDBODY )
waLBerla_compile_test( NAME PE_SERIALIZEDESERIALIZE FILES SerializeDeserialize.cpp DEPENDS core blockforest )
waLBerla_execute_test( NAME PE_SERIALIZEDESERIALIZE PROCESSES 8 )
waLBerla_execute_test( NAME PE_SERIALIZEDESERIALIZE01 COMMAND $<TARGET_FILE:PE_SERIALIZEDESERIALIZE> PROCESSES 1 )
waLBerla_execute_test( NAME PE_SERIALIZEDESERIALIZE02 COMMAND $<TARGET_FILE:PE_SERIALIZEDESERIALIZE> PROCESSES 2 )
waLBerla_execute_test( NAME PE_SERIALIZEDESERIALIZE04 COMMAND $<TARGET_FILE:PE_SERIALIZEDESERIALIZE> PROCESSES 4 )
waLBerla_execute_test( NAME PE_SERIALIZEDESERIALIZE08 COMMAND $<TARGET_FILE:PE_SERIALIZEDESERIALIZE> PROCESSES 8 )
if( WALBERLA_BUILD_WITH_MPI )
set_property( TEST PE_SERIALIZEDESERIALIZE02 PROPERTY DEPENDS PE_SERIALIZEDESERIALIZE01 ) #serialize runs of tets to avoid i/o conflicts when running ctest with -jN
set_property( TEST PE_SERIALIZEDESERIALIZE04 PROPERTY DEPENDS PE_SERIALIZEDESERIALIZE02 ) #serialize runs of tets to avoid i/o conflicts when running ctest with -jN
set_property( TEST PE_SERIALIZEDESERIALIZE08 PROPERTY DEPENDS PE_SERIALIZEDESERIALIZE04 ) #serialize runs of tets to avoid i/o conflicts when running ctest with -jN
endif()
waLBerla_compile_test( NAME PE_SHADOWCOPY FILES ShadowCopy.cpp DEPENDS core blockforest )
waLBerla_execute_test( NAME PE_SHADOWCOPY )
......
......@@ -46,7 +46,10 @@ void createDump()
shared_ptr<BodyStorage> globalBodyStorage = make_shared<BodyStorage>();
// create blocks
auto forest = shared_ptr< BlockForest >( new BlockForest( uint_c( MPIManager::instance()->rank() ), "SerializeDeserialize.sbf", true, false ) );
auto forest = createBlockForest( math::AABB(0,0,0,60,60,60),
Vector3<uint_t>(2,2,2), // number of blocks
Vector3<bool>(false, false, false)); // periodicity
forest->saveToFile("SerializeDeserialize.sbf");
auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage");
auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling( globalBodyStorage, storageID ), "CCD");
......@@ -57,7 +60,7 @@ void createDump()
}
WALBERLA_LOG_DEVEL_ON_ROOT("dumping body storage");
forest->saveBlockData("BodyStorageDump.dump", storageID);
forest->saveBlockData("SerializeDeserialize.dump", storageID);
for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt)
{
......@@ -79,7 +82,7 @@ void checkDump()
// create blocks
auto forest = shared_ptr< BlockForest >( new BlockForest( uint_c( MPIManager::instance()->rank() ), "SerializeDeserialize.sbf", true, false ) );
auto storageID = forest->loadBlockData("BodyStorageDump.dump", createStorageDataHandling<BodyTuple>(), "Storage");
auto storageID = forest->loadBlockData("SerializeDeserialize.dump", createStorageDataHandling<BodyTuple>(), "Storage");
auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling( globalBodyStorage, storageID ), "CCD");
for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt)
......@@ -112,21 +115,19 @@ int main( int argc, char ** argv )
{
walberla::debug::enterTestMode();
walberla::MPIManager::instance()->initializeMPI( &argc, &argv );
MPIManager::instance()->useWorldComm();
WALBERLA_MPI_SECTION()
{
walberla::MPIManager::instance()->initializeMPI( &argc, &argv );
}
SetBodyTypeIDs<BodyTuple>::execute();
// save SetupBlockForest, if you want to do that run with only one process
createBlockForest( math::AABB(0,0,0,60,60,60),
Vector3<uint_t>(2,2,2), // number of blocks
Vector3<bool>(false, false, false), // periodicity
true, // setup run?
"SerializeDeserialize.sbf" ); // sbf filename
WALBERLA_LOG_DEVEL_ON_ROOT("*** DUMPING ***");
createDump();
WALBERLA_MPI_BARRIER();
WALBERLA_MPI_SECTION()
{
WALBERLA_MPI_BARRIER();
}
WALBERLA_LOG_DEVEL_ON_ROOT("*** CHECKING ***");
checkDump();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment