Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (4)
Showing
with 91 additions and 76 deletions
......@@ -26,6 +26,7 @@ misc-*,
-misc-use-internal-linkage,
-misc-use-anonymous-namespace,
-misc-const-correctness,
-misc-misplaced-const
modernize-*,
-modernize-use-auto,
......
......@@ -344,7 +344,7 @@ public:
internal::BlockDataHandlingAdder addBlockData( const std::string & identifier = std::string() ) { return internal::BlockDataHandlingAdder( *this, identifier ); }
internal::BlockDataHandlingAdder addBlockData( const std::string & identifier = std::string() ) { return { *this, identifier }; }
template< typename T >
inline BlockDataID addBlockData( const shared_ptr< T > & dataHandling,
......@@ -387,7 +387,7 @@ public:
void refresh();
/// Functor that calls refresh with given frequency
RefreshFunctor getRefreshFunctor( const uint_t checkFrequency = uint_t(1) ) { return RefreshFunctor( *this, checkFrequency ); }
RefreshFunctor getRefreshFunctor( const uint_t checkFrequency = uint_t(1) ) { return { *this, checkFrequency }; }
/// Modification stamp is changed when refresh moves a block or refines/coarsens at least one block
/// however, stamp may (in rare cases) also change if block structure was not altered
......@@ -470,7 +470,7 @@ public:
void restoreSnapshot( const SnapshotRestoreFunction & processMapping, const bool rebelance = true );
SnapshotCreationFunctor getSnapshotCreationFunctor( const SnapshotCreationFunction & function,
const uint_t checkFrequency = uint_t(1) ) { return SnapshotCreationFunctor( *this, function, checkFrequency ); }
const uint_t checkFrequency = uint_t(1) ) { return { *this, function, checkFrequency }; }
inline uint_t addCallbackFunctionAfterBlockDataIsRestored( const SnapshotRestoreCallbackFunction & f );
inline void removeCallbackFunctionAfterBlockDataIsRestored( const uint_t handle );
......
......@@ -276,7 +276,7 @@ public:
uint_t getTreeId() const { return id_; }
uint_t getTreeIndex() const { return id_ - uintPow2( getUsedBits() - 1 ); }
BlockID getSuperId() const { WALBERLA_ASSERT_GREATER_EQUAL( getUsedBits(), uint_c(4) ); return BlockID( id_ >> 3 ); }
BlockID getSuperId() const { WALBERLA_ASSERT_GREATER_EQUAL( getUsedBits(), uint_c(4) ); return { id_ >> 3 }; }
BlockID getFatherId() const { return getSuperId(); }
void appendBranchId( const uint_t branchId ) { WALBERLA_ASSERT_LESS_EQUAL( getUsedBits() + 3, math::UINT_BITS ); WALBERLA_ASSERT_LESS( branchId, 8 ); id_ = (id_ << 3) + branchId; }
......
......@@ -631,11 +631,10 @@ createUniformBlockGrid( const AABB& domainAABB,
const memory_t memoryLimit = ( maxBlocksPerProcess == 0 ) ? numeric_cast< memory_t >( sforest.getNumberOfBlocks() ) :
numeric_cast< memory_t >( maxBlocksPerProcess );
GlobalLoadBalancing::MetisConfiguration< SetupBlock > metisConfig( includeMetis, forceMetis,
std::bind( cellWeightedCommunicationCost, std::placeholders::_1, std::placeholders::_2,
numberOfXCellsPerBlock,
numberOfYCellsPerBlock,
numberOfZCellsPerBlock ) );
auto commFunc = [=](const SetupBlock* const a, const SetupBlock* const b) {
return cellWeightedCommunicationCost(a, b, numberOfXCellsPerBlock, numberOfYCellsPerBlock, numberOfZCellsPerBlock);
};
GlobalLoadBalancing::MetisConfiguration< SetupBlock > metisConfig( includeMetis, forceMetis, commFunc );
sforest.calculateProcessDistribution_Default( uint_c( MPIManager::instance()->numProcesses() ), memoryLimit, "hilbert", 10, false, metisConfig );
......
......@@ -183,10 +183,10 @@ public:
uint_t getNumberOfBlocks( const uint_t level ) const;
inline const_iterator begin() const;
inline const_iterator end() const { return const_iterator( this, nullptr ); }
inline const_iterator end() const { return { this, nullptr }; }
inline iterator begin();
inline iterator end() { return iterator( this, nullptr ); }
inline iterator end() { return { this, nullptr }; }
const SetupBlock* getFirstBlock() const;
SetupBlock* getFirstBlock();
......@@ -435,7 +435,7 @@ inline SetupBlockForest::const_iterator SetupBlockForest::begin() const {
if( block == nullptr )
return end();
return SetupBlockForest::const_iterator( this, block );
return { this, block };
}
......@@ -447,7 +447,7 @@ inline SetupBlockForest::iterator SetupBlockForest::begin() {
if( block == nullptr )
return end();
return SetupBlockForest::iterator( this, block );
return { this, block };
}
......
......@@ -205,8 +205,12 @@ inline StructuredBlockForest::StructuredBlockForest( const shared_ptr< BlockFore
blockForest_( blockForest ) {
auto resetCallback = [this]() {
StructuredBlockForest::resetCellDecompositionInStorage(*this);
};
blockForest_->addRefreshCallbackFunctionBeforeBlockDataIsUnpacked(
BlockForest::RefreshCallbackWrappper( std::bind( resetCellDecompositionInStorage, std::ref(*this) ) ) );
BlockForest::RefreshCallbackWrappper( resetCallback ) );
blockCells_[0] = blockXCells;
blockCells_[1] = blockYCells;
......
......@@ -159,7 +159,7 @@ protected:
static void writeHeader( SendBuffer & buffer, const BlockID & sender, const BlockID & receiver, const stencil::Direction & dir );
static void readHeader( RecvBuffer & buffer, BlockID & sender, BlockID & receiver, stencil::Direction & dir );
static void send( SendBuffer & buffer, std::vector< SendBufferFunction > & functions );
static void send( SendBuffer & buffer, const std::vector< SendBufferFunction > & functions );
void receive( RecvBuffer & buffer );
void localBufferPacking( INDEX i, uint_t j, uint_t bufferIndex, const PackInfo & packInfo,
......@@ -709,8 +709,11 @@ void NonUniformBufferedScheme<Stencil>::startCommunicationEqualLevel( const uint
for( auto & sender : sendFunctions)
{
bufferSystem->addSendingFunction ( int_c(sender.first), std::bind( NonUniformBufferedScheme<Stencil>::send, std::placeholders::_1, sender.second ) );
bufferSystem->addReceivingFunction( int_c(sender.first), std::bind( &NonUniformBufferedScheme<Stencil>::receive, this, std::placeholders::_1 ) );
auto sendingFunc = [&sfunc = sender.second](SendBuffer & sbuf) { NonUniformBufferedScheme< Stencil >::send(sbuf, sfunc); };
bufferSystem->addSendingFunction ( int_c(sender.first), sendingFunc );
auto receivingFunc = [this](RecvBuffer & rbuf){ this->receive(rbuf); };
bufferSystem->addReceivingFunction( int_c(sender.first), receivingFunc );
}
setupBeforeNextCommunication = char(0);
......@@ -851,11 +854,15 @@ void NonUniformBufferedScheme<Stencil>::startCommunicationCoarseToFine( const ui
resetBufferSystem( bufferSystem );
for( auto const &sender : sendFunctions )
bufferSystem->addSendingFunction( int_c(sender.first), std::bind( NonUniformBufferedScheme<Stencil>::send, std::placeholders::_1, sender.second ) );
for( auto const &sender : sendFunctions ){
auto sendingFunc = [&sfunc = sender.second](SendBuffer & sbuf) { NonUniformBufferedScheme< Stencil >::send(sbuf, sfunc); };
bufferSystem->addSendingFunction( int_c(sender.first), sendingFunc );
}
for(auto receiver : ranksToReceiveFrom)
bufferSystem->addReceivingFunction( int_c(receiver), std::bind( &NonUniformBufferedScheme<Stencil>::receive, this, std::placeholders::_1 ) );
for(auto receiver : ranksToReceiveFrom){
auto receivingFunc = [this](RecvBuffer & rbuf){ this->receive(rbuf); };
bufferSystem->addReceivingFunction( int_c(receiver), receivingFunc );
}
setupBeforeNextCommunication = char(0);
}
......@@ -996,11 +1003,15 @@ void NonUniformBufferedScheme<Stencil>::startCommunicationFineToCoarse( const ui
resetBufferSystem( bufferSystem );
for( auto const &sender : sendFunctions )
bufferSystem->addSendingFunction( int_c(sender.first), std::bind( NonUniformBufferedScheme<Stencil>::send, std::placeholders::_1, sender.second ) );
for( auto const &sender : sendFunctions ){
auto sendingFunc = [&sfunc = sender.second](SendBuffer & sbuf) { NonUniformBufferedScheme< Stencil >::send(sbuf, sfunc); };
bufferSystem->addSendingFunction( int_c(sender.first), sendingFunc );
}
for(auto receiver : ranksToReceiveFrom)
bufferSystem->addReceivingFunction( int_c(receiver), std::bind( &NonUniformBufferedScheme<Stencil>::receive, this, std::placeholders::_1 ) );
for(auto receiver : ranksToReceiveFrom){
auto receivingFunc = [this](RecvBuffer & rbuf){ this->receive(rbuf); };
bufferSystem->addReceivingFunction( int_c(receiver), receivingFunc );
}
setupBeforeNextCommunication = char(0);
}
......@@ -1141,7 +1152,7 @@ void NonUniformBufferedScheme<Stencil>::readHeader( RecvBuffer & buffer, BlockID
template< typename Stencil >
void NonUniformBufferedScheme<Stencil>::send( SendBuffer & buffer, std::vector< SendBufferFunction > & functions )
void NonUniformBufferedScheme<Stencil>::send( SendBuffer & buffer, const std::vector< SendBufferFunction > & functions )
{
for(auto & function : functions)
function( buffer );
......
......@@ -366,8 +366,11 @@ void UniformBufferedScheme<Stencil>::startCommunication()
for( auto sIt : sendFunctions )
{
bufferSystem_.addSendingFunction ( int_c(sIt.first), std::bind( UniformBufferedScheme<Stencil>::send, std::placeholders::_1, sIt.second ) );
bufferSystem_.addReceivingFunction( int_c(sIt.first), std::bind( &UniformBufferedScheme<Stencil>::receive, this, std::placeholders::_1 ) );
auto sendingFunc = [&sfunc = sIt.second](auto & sbuf) { UniformBufferedScheme< Stencil >::send(sbuf, sfunc); };
bufferSystem_.addSendingFunction (int_c(sIt.first), sendingFunc );
auto receivingFunc = [this](auto & rbuf) { this->receive(rbuf); };
bufferSystem_.addReceivingFunction( int_c(sIt.first), receivingFunc );
}
setupBeforeNextCommunication_ = false;
......
......@@ -58,10 +58,8 @@ public:
DynamicDiffusionBalance( const uint_t maxIterations, const uint_t flowIterations, const bool levelwise = true ) :
mode_( DIFFUSION_PUSHPULL ), maxIterations_( maxIterations ),
defineProcessWeightLimitByMultipleOfMaxBlockWeight_( true ), checkForEarlyAbort_( true ), abortThreshold_( 1.0 ),
adaptOutflowWithGlobalInformation_( true ), adaptInflowWithGlobalInformation_( true ),
flowIterations_( flowIterations ), flowIterationsIncreaseStart_( maxIterations ), flowIterationsIncrease_( 0.0 ),
regardConnectivity_( true ), disregardConnectivityStart_( maxIterations ), outflowExceedFactor_( 1.0 ), inflowExceedFactor_( 1.0 ),
flowIterations_( flowIterations ), flowIterationsIncreaseStart_( maxIterations ),
disregardConnectivityStart_( maxIterations ),
levelwise_(levelwise)
{}
......@@ -124,20 +122,20 @@ private:
uint_t maxIterations_;
bool defineProcessWeightLimitByMultipleOfMaxBlockWeight_; // only evaluated when checkForEarlyAbort_ == true or adaptOutflowWithGlobalInformation_ == true
bool checkForEarlyAbort_;
double abortThreshold_; // only evaluated when checkForEarlyAbort_ == true
bool adaptOutflowWithGlobalInformation_;
bool adaptInflowWithGlobalInformation_;
bool defineProcessWeightLimitByMultipleOfMaxBlockWeight_ { true }; // only evaluated when checkForEarlyAbort_ == true or adaptOutflowWithGlobalInformation_ == true
bool checkForEarlyAbort_{ true };
double abortThreshold_{ 1.0 }; // only evaluated when checkForEarlyAbort_ == true
bool adaptOutflowWithGlobalInformation_{ true };
bool adaptInflowWithGlobalInformation_{ true };
uint_t flowIterations_;
uint_t flowIterationsIncreaseStart_;
double flowIterationsIncrease_;
double flowIterationsIncrease_{ 0.0 };
bool regardConnectivity_;
bool regardConnectivity_{ false };
uint_t disregardConnectivityStart_;
double outflowExceedFactor_;
double inflowExceedFactor_;
double outflowExceedFactor_{ 1.0 };
double inflowExceedFactor_{ 1.0 };
math::IntRandom< uint_t > random_;
......
......@@ -42,24 +42,24 @@ const Set< SUID > None(Set< SUID >::emptySet());
static void refinementSelectionFunction(SetupBlockForest& forest)
{
for (auto block = forest.begin(); block != forest.end(); ++block)
if (block->getAABB().contains(Vector3< real_t >(real_t(75))))
if (!block->hasFather()) block->setMarker(true);
for (auto & block : forest)
if (block.getAABB().contains(Vector3< real_t >(real_t(75))))
if (!block.hasFather()) block.setMarker(true);
}
static void workloadMemorySUIDAssignmentFunction(SetupBlockForest& forest)
{
for (auto block = forest.begin(); block != forest.end(); ++block)
for (auto & block : forest)
{
block->setMemory(memory_t(1));
block->setWorkload(workload_t(1));
if (block->getAABB().contains(Vector3< real_t >(real_t(25)))) block->addState(Empty);
block.setMemory(memory_t(1));
block.setWorkload(workload_t(1));
if (block.getAABB().contains(Vector3< real_t >(real_t(25)))) block.addState(Empty);
}
}
void test()
{
typedef field::GhostLayerField< double, 2 > FieldType;
using FieldType = field::GhostLayerField<double, 2>;
SetupBlockForest sforest;
......
......@@ -89,8 +89,7 @@ static void workloadMemorySUIDAssignmentFunction( SetupBlockForest& forest ) {
suids.emplace_back( oss.str(), false );
}
for( uint_t i = 0; i != blocks.size(); ++i ) {
SetupBlock* block = blocks[i];
for(auto block : blocks) {
block->setMemory( numeric_cast< memory_t >( 1.0 ) );
block->setWorkload( numeric_cast< workload_t >( std::pow( 2.0, numeric_cast<double>(block->getLevel()) ) ) );
if( block->getLevel() > 0 )
......@@ -102,11 +101,11 @@ static void workloadMemorySUIDAssignmentFunction( SetupBlockForest& forest ) {
static memory_t communicationCalculationFunction( const SetupBlock* const a, const SetupBlock* const b ) {
uint_t faces[] = { 4, 10, 12, 13, 15, 21 };
std::array< uint_t, 6 > faces = { 4, 10, 12, 13, 15, 21 };
for( uint_t i = 0; i != 6; ++i ) {
for( uint_t j = 0; j != a->getNeighborhoodSectionSize(faces[i]); ++j )
if( a->getNeighbor(faces[i],j) == b )
for(uint_t face : faces) {
for( uint_t j = 0; j != a->getNeighborhoodSectionSize(face); ++j )
if( a->getNeighbor(face,j) == b )
return 1000.0;
}
......@@ -457,8 +456,8 @@ static void test() {
setupBlockSet.insert( block->getId() );
}
for( auto blockId = blockIds.begin(); blockId != blockIds.end(); ++blockId ) {
const BlockID id = *dynamic_cast< BlockID* >( blockId->get() );
for(auto & blockId : blockIds) {
const BlockID id = *dynamic_cast< BlockID* >( blockId.get() );
WALBERLA_CHECK_EQUAL( forestBlockSet.find( id ), forestBlockSet.end() )
forestBlockSet.insert( id );
}
......
......@@ -39,8 +39,8 @@ static void refinementSelectionFunctionAll( SetupBlockForest& forest ) {
std::vector< SetupBlock* > blocks;
forest.getBlocks( blocks );
for( uint_t i = 0; i != blocks.size(); ++i )
if( blocks[i]->getLevel() < 2 ) blocks[i]->setMarker( true );
for(auto & block : blocks)
if( block->getLevel() < 2 ) block->setMarker( true );
}
......@@ -83,8 +83,8 @@ static void checkCollectorConsistency( SetupBlockForest& forest ) {
WALBERLA_CHECK( blocks[i] == itBlocks[i] )
std::set< SetupBlock* > baseSet;
for( uint_t i = 0; i != blocks.size(); ++i )
baseSet.insert( blocks[i] );
for(auto block : blocks)
baseSet.insert( block );
WALBERLA_CHECK_EQUAL( baseSet.size(), blocks.size() )
std::vector< SetupBlock* > hilbertBlocks;
......@@ -92,8 +92,8 @@ static void checkCollectorConsistency( SetupBlockForest& forest ) {
WALBERLA_CHECK_EQUAL( hilbertBlocks.size(), blocks.size() )
std::set< SetupBlock* > hilbertSet;
for( uint_t i = 0; i != hilbertBlocks.size(); ++i )
hilbertSet.insert( hilbertBlocks[i] );
for(auto hilbertBlock : hilbertBlocks)
hilbertSet.insert( hilbertBlock );
WALBERLA_CHECK_EQUAL( hilbertSet.size(), hilbertBlocks.size() )
std::set< SetupBlock* >::iterator baseIterator = baseSet.begin();
......@@ -110,8 +110,8 @@ static void checkCollectorConsistency( SetupBlockForest& forest ) {
WALBERLA_CHECK_EQUAL( aabbBlocks.size(), blocks.size() )
std::set< SetupBlock* > aabbSet;
for( uint_t i = 0; i != aabbBlocks.size(); ++i )
aabbSet.insert( aabbBlocks[i] );
for(auto aabbBlock : aabbBlocks)
aabbSet.insert( aabbBlock );
WALBERLA_CHECK_EQUAL( aabbSet.size(), aabbBlocks.size() )
baseIterator = baseSet.begin();
......
......@@ -59,9 +59,9 @@ static void workloadMemorySUIDAssignmentFunction( SetupBlockForest& forest ) {
std::vector< SetupBlock* > blocks;
forest.getBlocks( blocks );
for( uint_t i = 0; i != blocks.size(); ++i ) {
blocks[i]->setMemory( 1.0 );
blocks[i]->setWorkload( 1.0 );
for(auto & block : blocks) {
block->setMemory( 1.0 );
block->setWorkload( 1.0 );
}
}
......
......@@ -39,7 +39,7 @@
namespace walberla {
typedef GhostLayerField<real_t,1> ScalarField;
using ScalarField = GhostLayerField<real_t, 1>;
template<bool init_>
class SumSweep
......@@ -88,7 +88,7 @@ class CompareSweep
WALBERLA_ASSERT_NOT_NULLPTR( bf )
const AABB & bb = block->getAABB();
const cell_idx_t offset [3] = { cell_idx_c(bb.min(uint_t(0u))),
const std::array< cell_idx_t, 3 > offset = { cell_idx_c(bb.min(uint_t(0u))),
cell_idx_c(bb.min(uint_t(1u))),
cell_idx_c(bb.min(uint_t(2u))) };
......@@ -113,8 +113,8 @@ int main(int argc, char **argv)
debug::enterTestMode();
mpi::Environment env( argc, argv );
const uint_t cells [] = { uint_t(5u), uint_t(2u), uint_t(7u) };
const uint_t blockCount [] = { uint_t(1u), uint_t(1u), uint_c( MPIManager::instance()->numProcesses() ) };
const std::array< uint_t, 3 > cells = { uint_t(5u), uint_t(2u), uint_t(7u) };
const std::array< uint_t, 3 > blockCount = { uint_t(1u), uint_t(1u), uint_c( MPIManager::instance()->numProcesses() ) };
const uint_t nrOfTimeSteps = uint_t(3u);
bool periodic = false;
const field::Layout layout = field::fzyx;
......
......@@ -43,7 +43,7 @@
namespace walberla {
namespace wlb = walberla;
typedef GhostLayerField<real_t,19> PdfField;
using PdfField = GhostLayerField<real_t, 19>;
template<typename Sten>
......@@ -131,7 +131,7 @@ class CompareSweep
PdfField * bf = block->getData<PdfField>(bigField_);
const AABB & bb = block->getAABB();
const cell_idx_t offset [3] = { wlb::cell_idx_c(bb.min(0)),
const std::array< cell_idx_t, 3 > offset = { wlb::cell_idx_c(bb.min(0)),
wlb::cell_idx_c(bb.min(1)),
wlb::cell_idx_c(bb.min(2)) };
......@@ -187,8 +187,8 @@ int main(int argc, char **argv)
auto mpiManager = MPIManager::instance();
mpiManager->initializeMPI(&argc,&argv);
const uint_t cells [] = { 5,2,7 };
const uint_t blockCount [] = { uint_c( mpiManager->numProcesses() ), 1, 1 };
const std::array< uint_t, 3 > cells = { 5,2,7 };
const std::array< uint_t, 3 > blockCount = { uint_c( mpiManager->numProcesses() ), 1, 1 };
const uint_t nrOfTimeSteps = 30;
bool periodic = true;
const field::Layout layout = field::fzyx;
......