diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/refinement/grid2D.h | 4 | ||||
-rw-r--r-- | src/refinement/grid2D.hh | 13 |
2 files changed, 17 insertions, 0 deletions
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 <memory> #include <vector> +#include <string> +#include <functional> #include "core/unitConverter.h" #include "core/superLattice2D.h" @@ -142,6 +144,8 @@ public: RefiningGrid2D<T,DESCRIPTOR>& refine(Vector<T,2> origin, Vector<T,2> extend, bool addCouplers=true); + void forEachGrid(const std::string& id, std::function<void(Grid2D<T,DESCRIPTOR>&,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 @@ -259,6 +259,19 @@ Vector<T,2> Grid2D<T,DESCRIPTOR>::alignExtendToGrid(Vector<T,2> extend) const } template <typename T, template<typename> class DESCRIPTOR> +void Grid2D<T,DESCRIPTOR>::forEachGrid( + const std::string& id, + std::function<void(Grid2D<T,DESCRIPTOR>&,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<decltype(f)>(f)); + + } +} + +template <typename T, template<typename> class DESCRIPTOR> std::size_t Grid2D<T,DESCRIPTOR>::getActiveVoxelN() const { std::size_t n = _geometry->getStatistics().getNvoxel(); |