diff --git a/src/lbm/refinement/RefinementFunctorWrapper.h b/src/lbm/refinement/RefinementFunctorWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..a44dfd301f3a3f770868a3bebdfa0cb2dc446af1 --- /dev/null +++ b/src/lbm/refinement/RefinementFunctorWrapper.h @@ -0,0 +1,66 @@ +//====================================================================================================================== +// +// 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 RefinementFunctorWrapper.h +//! \ingroup lbm +//! \author Christoph Rettinger <christoph.rettinger@fau.de> +// +//====================================================================================================================== + +#pragma once + +#include "domain_decomposition/BlockStorage.h" + +#include <boost/function.hpp> + +namespace walberla { +namespace lbm { +namespace refinement { + +class FunctorWrapper { +public: + FunctorWrapper(boost::function<void()> fct) + : fct_(fct) { + } + + void operator()(const uint_t /*level*/, const uint_t /*executionCounter*/) { + fct_(); + } + +private: + boost::function<void(void)> fct_; +}; + +class SweepAsFunctorWrapper { +public: + SweepAsFunctorWrapper( boost::function<void(IBlock * )> fct, const shared_ptr <StructuredBlockStorage> &blockStorage ) + : fct_(fct), blockStorage_(blockStorage) { + } + + void operator()(const uint_t level, const uint_t /*executionCounter*/) { + for (auto blockIt = blockStorage_->begin(); blockIt != blockStorage_->end(); ++blockIt) { + if (blockStorage_->getLevel(*blockIt) != level) continue; + fct_(blockIt.get()); + } + } + +private: + boost::function<void(IBlock * )> fct_; + shared_ptr <StructuredBlockStorage> blockStorage_; +}; + +} // namespace refinement +} // namespace lbm +} // namespace walberla diff --git a/src/lbm/refinement/all.h b/src/lbm/refinement/all.h index 02846718f6b2ea122c7a301f214188549acc6458..a3a353488c9529dab22749a5735954a4551b0d1b 100644 --- a/src/lbm/refinement/all.h +++ b/src/lbm/refinement/all.h @@ -25,6 +25,7 @@ #include "BoundarySetup.h" #include "PdfFieldPackInfo.h" #include "PdfFieldSyncPackInfo.h" +#include "RefinementFunctorWrapper.h" #include "TimeStep.h" #include "TimeStepPdfPackInfo.h" #include "TimeTracker.h"