Commit ccc823eb authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

removed pe dependency from mesa_pd module

parent db32400a
......@@ -796,7 +796,7 @@ private:
real_t weightEvaluation(BlockForest & forest,
const shared_ptr<pe_coupling::InfoCollection>& couplingInfoCollection,
const shared_ptr<pe::InfoCollection> & peInfoCollection,
const shared_ptr<blockforest::InfoCollection> & peInfoCollection,
real_t peBlockBaseWeight,
const std::string & loadEvaluationStrategy,
uint_t level,
......@@ -1587,7 +1587,7 @@ int main( int argc, char **argv )
bool balanceLevelwise = true;
auto peBlockBaseWeight = real_t(1); //default value, might not be the best
shared_ptr<pe::InfoCollection> peInfoCollection = walberla::make_shared<pe::InfoCollection>();
shared_ptr<blockforest::InfoCollection> peInfoCollection = walberla::make_shared<blockforest::InfoCollection>();
if( loadDistributionStrategy == "Hilbert" || loadDistributionStrategy == "Morton")
{
......
......@@ -58,6 +58,7 @@
#include <blockforest/Initialization.h>
#include <blockforest/loadbalancing/DynamicCurve.h>
#include <blockforest/loadbalancing/DynamicParMetis.h>
#include <blockforest/loadbalancing/InfoCollection.h>
#include <blockforest/loadbalancing/PODPhantomData.h>
#include <core/Abort.h>
#include <core/Environment.h>
......@@ -134,7 +135,7 @@ int main( int argc, char ** argv )
forest->checkForEarlyOutInRefresh( params.checkForEarlyOutInRefresh );
forest->checkForLateOutInRefresh( params.checkForLateOutInRefresh );
auto ic = make_shared<pe::InfoCollection>();
auto ic = make_shared<blockforest::InfoCollection>();
pe::amr::MinMaxLevelDetermination regrid(ic, params.regridMin, params.regridMax);
forest->setRefreshMinTargetLevelDeterminationFunction( regrid );
......
......@@ -56,6 +56,7 @@
#include <blockforest/Initialization.h>
#include <blockforest/loadbalancing/DynamicCurve.h>
#include <blockforest/loadbalancing/DynamicParMetis.h>
#include <blockforest/loadbalancing/InfoCollection.h>
#include <blockforest/loadbalancing/PODPhantomData.h>
#include <core/Abort.h>
#include <core/Environment.h>
......@@ -130,7 +131,7 @@ int main( int argc, char ** argv )
forest->checkForEarlyOutInRefresh( params.checkForEarlyOutInRefresh );
forest->checkForLateOutInRefresh( params.checkForLateOutInRefresh );
auto ic = make_shared<pe::InfoCollection>();
auto ic = make_shared<blockforest::InfoCollection>();
pe::amr::MinMaxLevelDetermination regrid(ic, params.regridMin, params.regridMax);
forest->setRefreshMinTargetLevelDeterminationFunction( regrid );
......
......@@ -130,7 +130,7 @@ int main( int argc, char ** argv )
WALBERLA_LOG_INFO_ON_ROOT("blocks: " << Vector3<uint_t>(forest->getXSize(), forest->getYSize(), forest->getZSize()) );
auto ic = make_shared<pe::InfoCollection>();
auto ic = make_shared<blockforest::InfoCollection>();
pe::amr::MinMaxLevelDetermination regrid(ic, params.regridMin, params.regridMax);
forest->setRefreshMinTargetLevelDeterminationFunction( regrid );
......
......@@ -118,6 +118,7 @@ if __name__ == "__main__":
isFirstFile = True
for r,d,f in os.walk('.'):
for file in f:
print(r, file)
if r != '.' and file.endswith('.sqlite'):
if isFirstFile:
print( 'Copying ' + os.path.join(r,file) )
......
......@@ -26,7 +26,7 @@
#include <ostream>
namespace walberla {
namespace pe {
namespace blockforest {
struct BlockInfo
{
......@@ -43,7 +43,7 @@ struct BlockInfo
, communicationWeight(commWeight)
{}
BlockInfo& operator+=( const BlockInfo& rhs )
BlockInfo& operator+=( const BlockInfo& rhs )
{
computationalWeight += rhs.computationalWeight;
communicationWeight += rhs.communicationWeight;
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file InfoCollection.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#pragma once
#include "../BlockID.h"
#include "BlockInfo.h"
#include <map>
namespace walberla {
namespace blockforest {
using InfoCollection = std::map<BlockID, BlockInfo>;
using InfoCollectionPair = std::pair<InfoCollection::key_type, InfoCollection::mapped_type>;
}
}
......@@ -5,4 +5,4 @@
#
###################################################################################################
waLBerla_add_module( DEPENDS blockforest core pe stencil vtk )
waLBerla_add_module( DEPENDS blockforest core stencil vtk )
......@@ -23,17 +23,19 @@
#include <mesa_pd/data/ParticleStorage.h>
#include <blockforest/BlockForest.h>
#include <blockforest/loadbalancing/BlockInfo.h>
#include <blockforest/loadbalancing/InfoCollection.h>
#include <core/mpi/BufferSystem.h>
#include <pe/amr/BlockInfo.h>
#include <pe/amr/InfoCollection.h>
namespace walberla {
namespace mesa_pd {
namespace domain {
template <typename Accessor>
void createWithNeighborhood(Accessor& ac, const BlockForest& bf, pe::InfoCollection& ic )
void createWithNeighborhood(Accessor& ac, const BlockForest& bf, blockforest::InfoCollection& ic )
{
using namespace walberla::blockforest;
ic.clear();
walberla::mpi::BufferSystem bs( MPIManager::instance()->comm(), 756 );
......@@ -44,7 +46,7 @@ void createWithNeighborhood(Accessor& ac, const BlockForest& bf, pe::InfoCollect
{
const blockforest::Block* block = static_cast<const blockforest::Block*> (&(*blockIt));
pe::BlockInfo& info = ic[block->getId()];
BlockInfo& info = ic[block->getId()];
if (block->getAABB().contains(ac.getPosition(idx)))
{
if (data::particle_flags::isSet( ac.getFlags(idx), data::particle_flags::GHOST))
......@@ -59,7 +61,7 @@ void createWithNeighborhood(Accessor& ac, const BlockForest& bf, pe::InfoCollect
{
const auto childID = BlockID(block->getId(), branchID);
const auto childAABB = bf.getAABBFromBlockId(childID);
pe::BlockInfo& childInfo = ic[childID];
BlockInfo& childInfo = ic[childID];
if (childAABB.contains(ac.getPosition(idx)))
{
if (data::particle_flags::isSet( ac.getFlags(idx), data::particle_flags::GHOST))
......@@ -81,21 +83,21 @@ void createWithNeighborhood(Accessor& ac, const BlockForest& bf, pe::InfoCollect
{
const blockforest::Block* block = static_cast<const blockforest::Block*> (&(*blockIt));
pe::BlockInfo& info = ic[block->getId()];
BlockInfo& info = ic[block->getId()];
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << pe::InfoCollection::value_type(block->getId(), info);
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(block->getId(), info);
}
for (uint_t branchID = 0; branchID < 8; ++branchID)
{
const auto childID = BlockID(block->getId(), branchID);
pe::BlockInfo& childInfo = ic[childID];
BlockInfo& childInfo = ic[childID];
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << pe::InfoCollection::value_type(childID, childInfo);
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(childID, childInfo);
}
}
}
......@@ -108,7 +110,7 @@ void createWithNeighborhood(Accessor& ac, const BlockForest& bf, pe::InfoCollect
{
while( !recvIt.buffer().isEmpty() )
{
pe::InfoCollectionPair val;
InfoCollectionPair val;
recvIt.buffer() >> val;
ic.insert(val);
}
......
......@@ -31,22 +31,23 @@ namespace pe {
void createWithNeighborhoodLocalShadow( const BlockForest& bf,
const BlockDataID storageID,
InfoCollection& ic )
blockforest::InfoCollection& ic )
{
using namespace walberla::blockforest;
ic.clear();
mpi::BufferSystem bs( MPIManager::instance()->comm(), 756 );
for (auto blockIt = bf.begin(); blockIt != bf.end(); ++blockIt)
{
const blockforest::Block* block = static_cast<const blockforest::Block*> (&(*blockIt));
const Block* block = static_cast<const Block*> (&(*blockIt));
Storage const * storage = block->getData< Storage >( storageID );
BodyStorage const & localStorage = (*storage)[StorageType::LOCAL];
BodyStorage const & shadowStorage = (*storage)[StorageType::SHADOW];
ic.insert( InfoCollection::value_type(block->getId(), BlockInfo(localStorage.size(), shadowStorage.size())) );
ic.insert( InfoCollectionPair(block->getId(), BlockInfo(localStorage.size(), shadowStorage.size())) );
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(block->getId(), BlockInfo(localStorage.size(), shadowStorage.size()));
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollectionPair(block->getId(), BlockInfo(localStorage.size(), shadowStorage.size()));
}
for (uint_t branchID = 0; branchID < 8; ++branchID)
......@@ -65,11 +66,11 @@ void createWithNeighborhoodLocalShadow( const BlockForest& bf,
if (childAABB.contains(bodyIt->getPosition()))
++shadow;
}
ic.insert( InfoCollection::value_type(childID, BlockInfo(local, shadow)) );
ic.insert( InfoCollectionPair(childID, BlockInfo(local, shadow)) );
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(childID, BlockInfo(local, shadow));
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollectionPair(childID, BlockInfo(local, shadow));
}
}
}
......@@ -92,22 +93,24 @@ void createWithNeighborhoodLocalShadow( const BlockForest& bf,
void createWithNeighborhoodContactsShadow( BlockForest& bf,
const BlockDataID storageID,
const BlockDataID fcdID,
InfoCollection& ic )
blockforest::InfoCollection& ic )
{
using namespace walberla::blockforest;
ic.clear();
mpi::BufferSystem bs( MPIManager::instance()->comm(), 756 );
for (auto blockIt = bf.begin(); blockIt != bf.end(); ++blockIt)
{
blockforest::Block* block = static_cast<blockforest::Block*> (&(*blockIt));
Block* block = static_cast<Block*> (&(*blockIt));
Storage const * storage = block->getData< Storage >( storageID );
BodyStorage const & shadowStorage = (*storage)[StorageType::SHADOW];
fcd::IFCD * fcd = block->getData< fcd::IFCD >( fcdID );
ic.insert( InfoCollection::value_type(block->getId(), BlockInfo(fcd->getContacts().size(), shadowStorage.size())) );
ic.insert( InfoCollectionPair(block->getId(), BlockInfo(fcd->getContacts().size(), shadowStorage.size())) );
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(block->getId(), BlockInfo(fcd->getContacts().size(), shadowStorage.size()));
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollectionPair(block->getId(), BlockInfo(fcd->getContacts().size(), shadowStorage.size()));
}
for (uint_t branchID = 0; branchID < 8; ++branchID)
......@@ -127,11 +130,11 @@ void createWithNeighborhoodContactsShadow( BlockForest& bf,
if (childAABB.contains(bodyIt->getPosition()))
++shadow;
}
ic.insert( InfoCollection::value_type(childID, BlockInfo(localContacts, shadow)) );
ic.insert( InfoCollectionPair(childID, BlockInfo(localContacts, shadow)) );
for( uint_t nb = uint_t(0); nb < block->getNeighborhoodSize(); ++nb )
{
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollection::value_type(childID, BlockInfo(localContacts, shadow));
bs.sendBuffer( block->getNeighborProcess(nb) ) << InfoCollectionPair(childID, BlockInfo(localContacts, shadow));
}
}
}
......
......@@ -20,18 +20,15 @@
#pragma once
#include "BlockInfo.h"
#include "blockforest/BlockForest.h"
#include "blockforest/loadbalancing/BlockInfo.h"
#include "blockforest/loadbalancing/InfoCollection.h"
#include <map>
namespace walberla {
namespace pe {
typedef std::map<blockforest::BlockID, BlockInfo> InfoCollection;
typedef std::pair<blockforest::BlockID, BlockInfo> InfoCollectionPair;
/**
* @brief Fills \a InfoCollection with up to date information.
*
......@@ -41,7 +38,7 @@ typedef std::pair<blockforest::BlockID, BlockInfo> InfoCollectionPair;
*/
void createWithNeighborhoodLocalShadow( const BlockForest& bf,
const BlockDataID storageID,
InfoCollection& ic );
blockforest::InfoCollection& ic );
/**
* @brief Fills \a InfoCollection with up to date information.
......@@ -53,7 +50,7 @@ void createWithNeighborhoodLocalShadow( const BlockForest& bf,
void createWithNeighborhoodContactsShadow( BlockForest& bf,
const BlockDataID storageID,
const BlockDataID fcdID,
InfoCollection& ic );
blockforest::InfoCollection& ic );
}
}
......@@ -25,7 +25,8 @@ namespace pe {
namespace amr {
void MinMaxLevelDetermination::operator()( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels,
std::vector< const Block * > &, const BlockForest & /*forest*/ )
std::vector< const Block * > &,
const BlockForest & /*forest*/ )
{
for( auto it = minTargetLevels.begin(); it != minTargetLevels.end(); ++it )
{
......@@ -53,13 +54,13 @@ void MinMaxLevelDetermination::operator()( std::vector< std::pair< const Block *
}
}
InfoCollection::const_iterator MinMaxLevelDetermination::getOrCreateCoarseInfo( const blockforest::BlockID& id )
blockforest::InfoCollection::const_iterator MinMaxLevelDetermination::getOrCreateCoarseInfo( const blockforest::BlockID& id )
{
auto fatherId = id.getFatherId();
auto infoIt = ic_->find( fatherId );
if (infoIt != ic_->end()) return infoIt;
BlockInfo newWeight( 0, 0);
blockforest::BlockInfo newWeight( 0, 0);
for (uint_t child = 0; child < 8; ++child)
{
blockforest::BlockID childId(fatherId, child);
......@@ -68,8 +69,8 @@ InfoCollection::const_iterator MinMaxLevelDetermination::getOrCreateCoarseInfo(
//return giant number to prevent coarsening
if (childIt == ic_->end())
{
newWeight = BlockInfo( std::numeric_limits<uint_t>::max(),
std::numeric_limits<uint_t>::max());
newWeight = blockforest::BlockInfo( std::numeric_limits<uint_t>::max(),
std::numeric_limits<uint_t>::max());
break;
} else
{
......
......@@ -36,19 +36,22 @@ class MinMaxLevelDetermination
{
public:
MinMaxLevelDetermination( const shared_ptr<InfoCollection>& ic, const size_t minBodies, const size_t maxBodies) :
MinMaxLevelDetermination( const shared_ptr<blockforest::InfoCollection>& ic,
const size_t minBodies,
const size_t maxBodies) :
ic_( ic ), minBodies_(minBodies), maxBodies_(maxBodies)
{}
void operator()( std::vector< std::pair< const Block *, uint_t > > & minTargetLevels,
std::vector< const Block * > &, const BlockForest & forest );
std::vector< const Block * > &,
const BlockForest & forest );
public:
const shared_ptr<InfoCollection> ic_;
const shared_ptr<blockforest::InfoCollection> ic_;
size_t minBodies_;
size_t maxBodies_;
InfoCollection::const_iterator getOrCreateCoarseInfo( const blockforest::BlockID& id );
blockforest::InfoCollection::const_iterator getOrCreateCoarseInfo( const blockforest::BlockID& id );
};
} // namespace amr
......
......@@ -20,9 +20,10 @@
#pragma once
#include "pe/amr/InfoCollection.h"
#include "blockforest/BlockForest.h"
#include "blockforest/PhantomBlockForest.h"
#include "blockforest/loadbalancing/DynamicParMetis.h"
#include "blockforest/loadbalancing/InfoCollection.h"
#include "domain_decomposition/PeriodicIntersectionVolume.h"
namespace walberla {
......@@ -43,9 +44,10 @@ public:
///Convenience typdef for pack and unpack functions to be used in conjunction with PhantomBlockWeight.
typedef blockforest::DynamicParMetisBlockInfoPackUnpack PhantomBlockWeightPackUnpackFunctor;
MetisAssignmentFunctor( shared_ptr<InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
MetisAssignmentFunctor( shared_ptr<blockforest::InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & forest )
void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData,
const PhantomBlockForest & forest )
{
const std::array< bool, 3 > periodic {{forest.getBlockForest().isPeriodic(0),
forest.getBlockForest().isPeriodic(1),
......@@ -85,7 +87,7 @@ public:
inline double getBaseWeight() const { return baseWeight_; }
private:
shared_ptr< InfoCollection > ic_;
shared_ptr< blockforest::InfoCollection > ic_;
///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process!
double baseWeight_ = 10.0;
......
......@@ -21,9 +21,9 @@
#pragma once
#include "pe/amr/InfoCollection.h"
#include "blockforest/loadbalancing/InfoCollection.h"
#include "blockforest/loadbalancing/PODPhantomData.h"
#include "blockforest/PhantomBlockForest.h"
namespace walberla {
namespace pe {
......@@ -42,7 +42,7 @@ public:
///Convenience typdef for pack and unpack functions to be used in conjunction with PhantomBlockWeight.
typedef walberla::blockforest::PODPhantomWeightPackUnpack<double> PhantomBlockWeightPackUnpackFunctor;
WeightAssignmentFunctor( shared_ptr<InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
WeightAssignmentFunctor( shared_ptr<blockforest::InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & )
{
......@@ -62,7 +62,7 @@ public:
inline double getBaseWeight() const { return baseWeight_; }
private:
shared_ptr<InfoCollection> ic_;
shared_ptr<blockforest::InfoCollection> ic_;
///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process!
double baseWeight_ = real_t(10.0);
......
......@@ -26,9 +26,9 @@
#include <blockforest/Initialization.h>
#include <blockforest/loadbalancing/DynamicCurve.h>
#include <blockforest/loadbalancing/InfoCollection.h>
#include <core/debug/TestSubsystem.h>
#include <core/logging/Logging.h>
#include <pe/amr/InfoCollection.h>
#include <pe/amr/level_determination/MinMaxLevelDetermination.h>
#include <pe/amr/weight_assignment/WeightAssignmentFunctor.h>
......@@ -91,7 +91,7 @@ int main( bool simple )
forest->checkForEarlyOutInRefresh( true );
forest->checkForLateOutInRefresh( true );
auto infoCollection = make_shared<pe::InfoCollection>();
auto infoCollection = make_shared<blockforest::InfoCollection>();
if (simple)
{
......
......@@ -20,6 +20,7 @@
#include "blockforest/all.h"
#include "blockforest/loadbalancing/InfoCollection.h"
#include <blockforest/loadbalancing/PODPhantomData.h>
#include "core/all.h"
#include "domain_decomposition/all.h"
......@@ -28,7 +29,6 @@
#include "pe/basic.h"
#include "pe/amr/InfoCollection.h"
#include "pe/amr/level_determination/MinMaxLevelDetermination.h"
#include "pe/amr/weight_assignment/WeightAssignmentFunctor.h"
#include "pe/ccd/SimpleCCDDataHandling.h"
......@@ -95,7 +95,7 @@ int main( int argc, char ** argv )
blockforest.checkForEarlyOutInRefresh( true );
blockforest.checkForLateOutInRefresh( true );
auto infoCollection = make_shared<InfoCollection>();
auto infoCollection = make_shared<blockforest::InfoCollection>();
amr::MinMaxLevelDetermination levelDetermination(infoCollection, 2, 5);
blockforest.setRefreshMinTargetLevelDeterminationFunction( levelDetermination );
......
......@@ -23,10 +23,10 @@
#include "blockforest/loadbalancing/DynamicCurve.h"
#include "blockforest/loadbalancing/DynamicDiffusive.h"
#include "blockforest/loadbalancing/DynamicParMetis.h"
#include "blockforest/loadbalancing/InfoCollection.h"
#include "blockforest/loadbalancing/PODPhantomData.h"
#include "pe/basic.h"
#include "pe/amr/InfoCollection.h"
#include "pe/amr/level_determination/MinMaxLevelDetermination.h"
#include "pe/amr/weight_assignment/MetisAssignmentFunctor.h"
#include "pe/amr/weight_assignment/WeightAssignmentFunctor.h"
......@@ -77,7 +77,7 @@ int main( int /*argc*/, char ** /*argv*/, const std::string& LBAlgorithm )
blockforest->checkForEarlyOutInRefresh( true );
blockforest->checkForLateOutInRefresh( true );
auto ic = make_shared<InfoCollection>();
auto ic = make_shared<blockforest::InfoCollection>();
blockforest->setRefreshMinTargetLevelDeterminationFunction( amr::MinMaxLevelDetermination(ic, 50, 100) );
......
Markdown is supported
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