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

made minimum block weight changeable

parent 71eff542
No related merge requests found
//======================================================================================================================
//
// 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 WeightAssignmentFunctor.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "WeightAssignmentFunctor.h"
namespace walberla {
namespace pe {
namespace amr {
const double WeightAssignmentFunctor::baseWeight = real_t(10.0);
}
}
}
......@@ -35,10 +35,7 @@ public:
typedef walberla::blockforest::PODPhantomWeight<double> PhantomBlockWeight;
typedef walberla::blockforest::PODPhantomWeightPackUnpack<double> PhantomBlockWeightPackUnpackFunctor;
///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process!
static const double baseWeight;
WeightAssignmentFunctor( shared_ptr<InfoCollection>& ic ) : ic_(ic) {}
WeightAssignmentFunctor( shared_ptr<InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
void operator()( std::vector< std::pair< const PhantomBlock *, boost::any > > & blockData, const PhantomBlockForest & )
{
......@@ -52,7 +49,7 @@ public:
{
auto infoIt = ic_->find( block->getId()/*.getFatherId()*/ );
WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() );
it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight );
it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ );
continue;
}
......@@ -60,7 +57,7 @@ public:
{
auto infoIt = ic_->find( block->getId() );
WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() );
it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight );
it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ );
continue;
}
......@@ -74,14 +71,20 @@ public:
WALBERLA_ASSERT_UNEQUAL( childIt, ic_->end() );
weight += double_c(childIt->second.numberOfLocalBodies);
}
it->second = PhantomBlockWeight( weight + baseWeight );
it->second = PhantomBlockWeight( weight + baseWeight_ );
continue;
}
}
}
inline void setBaseWeight( const real_t weight) { baseWeight_ = weight;}
inline real_t getBaseWeight() const { return baseWeight_; }
private:
shared_ptr<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);
};
}
......
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