From 27b0c949eda95d0fc97615acee899dd9b67bf781 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 4 Feb 2019 22:50:53 +0100 Subject: Add support for calling a function for each subgrid of Grid2D --- src/refinement/grid2D.h | 4 ++++ src/refinement/grid2D.hh | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/refinement') diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h index c90078b..adfcd55 100644 --- a/src/refinement/grid2D.h +++ b/src/refinement/grid2D.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include "core/unitConverter.h" #include "core/superLattice2D.h" @@ -142,6 +144,8 @@ public: RefiningGrid2D& refine(Vector origin, Vector extend, bool addCouplers=true); + void forEachGrid(const std::string& id, std::function&,const std::string&)>&& f); + std::size_t getActiveVoxelN() const; }; diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh index 6e9405e..6d16648 100644 --- a/src/refinement/grid2D.hh +++ b/src/refinement/grid2D.hh @@ -258,6 +258,19 @@ Vector Grid2D::alignExtendToGrid(Vector extend) const }; } +template class DESCRIPTOR> +void Grid2D::forEachGrid( + const std::string& id, + std::function&,const std::string&)>&& f) +{ + f(*this, id); + for (std::size_t i = 0; i < _fineGrids.size(); ++i) { + _fineGrids[i]->forEachGrid(id + "_" + std::to_string(i), + std::forward(f)); + + } +} + template class DESCRIPTOR> std::size_t Grid2D::getActiveVoxelN() const { -- cgit v1.2.3