summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-04 22:56:00 +0100
committerAdrian Kummerlaender2019-06-24 15:17:42 +0200
commit9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e (patch)
treead3d9379994185d569679d6586ed17aaf841c074
parent27b0c949eda95d0fc97615acee899dd9b67bf781 (diff)
downloadgrid_refinement_openlb-9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e.tar
grid_refinement_openlb-9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e.tar.gz
grid_refinement_openlb-9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e.tar.bz2
grid_refinement_openlb-9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e.tar.xz
grid_refinement_openlb-9d547d2dc7d2e96c16ee5cbf9ebf2f73a7a5233e.zip
Automatically apply prepareLattice for all grids
-rw-r--r--apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp7
-rw-r--r--apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp4
-rw-r--r--apps/adrian/cylinder2d/playground/cylinder2d.cpp6
-rw-r--r--src/refinement/grid2D.h1
-rw-r--r--src/refinement/grid2D.hh9
5 files changed, 13 insertions, 14 deletions
diff --git a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
index b01913f..34294ee 100644
--- a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
@@ -330,12 +330,7 @@ int main(int argc, char* argv[])
prepareGeometry(fineGrid3, domainOrigin, domainExtend);
disableRefinedArea(fineGrid2, fineGrid3);
- prepareLattice(coarseGrid);
- prepareLattice(fineOutflowGrid);
- prepareLattice(fineOutflowGrid2);
- prepareLattice(fineGrid);
- prepareLattice(fineGrid2);
- prepareLattice(fineGrid3);
+ coarseGrid.forEachGrid(prepareLattice);
clout << "Total number of active cells: " << coarseGrid.getActiveVoxelN() << endl;
clout << "Starting simulation..." << endl;
diff --git a/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp b/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
index 7e506c1..f1e6fa9 100644
--- a/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
@@ -309,9 +309,7 @@ int main(int argc, char* argv[])
fineOutflowGrid.getSuperGeometry().reset(refined);
}
- prepareLattice(coarseGrid);
- prepareLattice(fineOutflowGrid);
- prepareLattice(fineOutflowGrid2);
+ coarseGrid.forEachGrid(prepareLattice);
clout << "Total number of active cells: " << coarseGrid.getActiveVoxelN() << endl;
clout << "Starting simulation..." << endl;
diff --git a/apps/adrian/cylinder2d/playground/cylinder2d.cpp b/apps/adrian/cylinder2d/playground/cylinder2d.cpp
index fdcd5a4..c3c5c1b 100644
--- a/apps/adrian/cylinder2d/playground/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/playground/cylinder2d.cpp
@@ -299,11 +299,7 @@ int main(int argc, char* argv[])
prepareGeometry(fineGrid4, domainOrigin, domainExtend);
disableRefinedArea(fineGrid3, fineGrid4);
- prepareLattice(coarseGrid);
- prepareLattice(fineGrid);
- prepareLattice(fineGrid2);
- prepareLattice(fineGrid3);
- prepareLattice(fineGrid4);
+ coarseGrid.forEachGrid(prepareLattice);
clout << "Total number of active cells: " << coarseGrid.getActiveVoxelN() << endl;
clout << "Starting simulation..." << endl;
diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h
index adfcd55..6cbbf6f 100644
--- a/src/refinement/grid2D.h
+++ b/src/refinement/grid2D.h
@@ -144,6 +144,7 @@ public:
RefiningGrid2D<T,DESCRIPTOR>& refine(Vector<T,2> origin, Vector<T,2> extend, bool addCouplers=true);
+ void forEachGrid(std::function<void(Grid2D<T,DESCRIPTOR>&)>&& f);
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 6d16648..fdf6461 100644
--- a/src/refinement/grid2D.hh
+++ b/src/refinement/grid2D.hh
@@ -259,6 +259,15 @@ Vector<T,2> Grid2D<T,DESCRIPTOR>::alignExtendToGrid(Vector<T,2> extend) const
}
template <typename T, template<typename> class DESCRIPTOR>
+void Grid2D<T,DESCRIPTOR>::forEachGrid(std::function<void(Grid2D<T,DESCRIPTOR>&)>&& f)
+{
+ f(*this);
+ for (auto& grid : _fineGrids) {
+ grid->forEachGrid(std::forward<decltype(f)>(f));
+ }
+}
+
+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)