From f364d10d6080a5138f9b6619da41fcdd3fb4e88f Mon Sep 17 00:00:00 2001 From: Christoph Rettinger <christoph.rettinger@fau.de> Date: Fri, 17 Nov 2017 13:55:37 +0100 Subject: [PATCH] Added functor wrappers for refinement --- src/lbm/refinement/RefinementFunctorWrapper.h | 66 +++++++++++++++++++ src/lbm/refinement/all.h | 1 + 2 files changed, 67 insertions(+) create mode 100644 src/lbm/refinement/RefinementFunctorWrapper.h diff --git a/src/lbm/refinement/RefinementFunctorWrapper.h b/src/lbm/refinement/RefinementFunctorWrapper.h new file mode 100644 index 000000000..a44dfd301 --- /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 02846718f..a3a353488 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" -- GitLab