summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-04 22:50:53 +0100
committerAdrian Kummerlaender2019-06-24 15:17:42 +0200
commit27b0c949eda95d0fc97615acee899dd9b67bf781 (patch)
treeb6abaa3a58441c0bb4138155b1a910a23eb0d3d9 /src
parente7b4bdc064da4340f415ac1e7ddcb6e260d61b0f (diff)
downloadgrid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar.gz
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar.bz2
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar.lz
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar.xz
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.tar.zst
grid_refinement_openlb-27b0c949eda95d0fc97615acee899dd9b67bf781.zip
Add support for calling a function for each subgrid of Grid2D
Diffstat (limited to 'src')
-rw-r--r--src/refinement/grid2D.h4
-rw-r--r--src/refinement/grid2D.hh13
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();