summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp17
-rw-r--r--apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp14
-rw-r--r--apps/adrian/cylinder2d/playground/cylinder2d.cpp17
-rw-r--r--src/refinement/grid2D.h4
-rw-r--r--src/refinement/grid2D.hh13
5 files changed, 36 insertions, 29 deletions
diff --git a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
index 74ad91b..b01913f 100644
--- a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp
@@ -189,17 +189,15 @@ void setBoundaryValues(Grid2D<T,DESCRIPTOR>& grid, int iT)
}
}
-void getResults(const std::string& prefix,
- Grid2D<T,DESCRIPTOR>& grid,
+void getResults(Grid2D<T,DESCRIPTOR>& grid,
+ const std::string& prefix,
int iT)
{
- OstreamManager clout(std::cout,"getResults");
-
auto& converter = grid.getConverter();
auto& sLattice = grid.getSuperLattice();
auto& sGeometry = grid.getSuperGeometry();
- SuperVTMwriter2D<T> vtmWriter(prefix + "cylinder2d");
+ SuperVTMwriter2D<T> vtmWriter(prefix);
SuperLatticePhysVelocity2D<T,DESCRIPTOR> velocity(sLattice, converter);
SuperLatticePhysPressure2D<T,DESCRIPTOR> pressure(sLattice, converter);
SuperLatticeGeometry2D<T,DESCRIPTOR> geometry(sLattice, sGeometry);
@@ -357,12 +355,9 @@ int main(int argc, char* argv[])
timer.update(iT);
timer.printStep();
- getResults("level0_", coarseGrid, iT);
- getResults("level1_outflow_", fineOutflowGrid, iT);
- getResults("level2_outflow_", fineOutflowGrid2, iT);
- getResults("level1_", fineGrid, iT);
- getResults("level2_", fineGrid2, iT);
- getResults("level3_", fineGrid3, iT);
+ coarseGrid.forEachGrid("cylinder2d", [&](Grid2D<T,DESCRIPTOR>& grid, const std::string& id) {
+ getResults(grid, id, iT);
+ });
takeMeasurements(fineGrid3);
}
diff --git a/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp b/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
index 8b6a49c..7e506c1 100644
--- a/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/outflow_refinement/cylinder2d.cpp
@@ -189,17 +189,15 @@ void setBoundaryValues(Grid2D<T,DESCRIPTOR>& grid, int iT)
}
}
-void getResults(const std::string& prefix,
- Grid2D<T,DESCRIPTOR>& grid,
+void getResults(Grid2D<T,DESCRIPTOR>& grid,
+ const std::string& prefix,
int iT)
{
- OstreamManager clout(std::cout,"getResults");
-
auto& converter = grid.getConverter();
auto& sLattice = grid.getSuperLattice();
auto& sGeometry = grid.getSuperGeometry();
- SuperVTMwriter2D<T> vtmWriter(prefix + "cylinder2d");
+ SuperVTMwriter2D<T> vtmWriter(prefix);
SuperLatticePhysVelocity2D<T,DESCRIPTOR> velocity(sLattice, converter);
SuperLatticePhysPressure2D<T,DESCRIPTOR> pressure(sLattice, converter);
SuperLatticeGeometry2D<T,DESCRIPTOR> geometry(sLattice, sGeometry);
@@ -333,9 +331,9 @@ int main(int argc, char* argv[])
timer.update(iT);
timer.printStep();
- getResults("level0_", coarseGrid, iT);
- getResults("level1_outflow_", fineOutflowGrid, iT);
- getResults("level2_outflow_", fineOutflowGrid2, iT);
+ coarseGrid.forEachGrid("cylinder2d", [&](Grid2D<T,DESCRIPTOR>& grid, const std::string& id) {
+ getResults(grid, id, iT);
+ });
takeMeasurements(coarseGrid);
}
diff --git a/apps/adrian/cylinder2d/playground/cylinder2d.cpp b/apps/adrian/cylinder2d/playground/cylinder2d.cpp
index 5b67408..fdcd5a4 100644
--- a/apps/adrian/cylinder2d/playground/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/playground/cylinder2d.cpp
@@ -188,17 +188,15 @@ void setBoundaryValues(Grid2D<T,DESCRIPTOR>& grid, int iT)
}
}
-void getResults(const std::string& prefix,
- Grid2D<T,DESCRIPTOR>& grid,
+void getResults(Grid2D<T,DESCRIPTOR>& grid,
+ const std::string& prefix,
int iT)
{
- OstreamManager clout(std::cout,"getResults");
-
auto& converter = grid.getConverter();
auto& sLattice = grid.getSuperLattice();
auto& sGeometry = grid.getSuperGeometry();
- SuperVTMwriter2D<T> vtmWriter(prefix + "cylinder2d");
+ SuperVTMwriter2D<T> vtmWriter(prefix);
SuperLatticePhysVelocity2D<T,DESCRIPTOR> velocity(sLattice, converter);
SuperLatticePhysPressure2D<T,DESCRIPTOR> pressure(sLattice, converter);
SuperLatticeGeometry2D<T,DESCRIPTOR> geometry(sLattice, sGeometry);
@@ -265,6 +263,7 @@ int main(int argc, char* argv[])
RelaxationTime<T>(tau),
N,
PhysCharacteristics);
+
const Vector<T,2> domainOrigin = coarseGrid.getSuperGeometry().getStatistics().getMinPhysR(0);
const Vector<T,2> domainExtend = coarseGrid.getSuperGeometry().getStatistics().getPhysExtend(0);
@@ -324,11 +323,9 @@ int main(int argc, char* argv[])
timer.update(iT);
timer.printStep();
- getResults("level0_", coarseGrid, iT);
- getResults("level1_", fineGrid, iT);
- getResults("level2_", fineGrid2, iT);
- getResults("level3_", fineGrid3, iT);
- getResults("level4_", fineGrid4, iT);
+ coarseGrid.forEachGrid("cylinder2d", [&](Grid2D<T,DESCRIPTOR>& grid, const std::string& id) {
+ getResults(grid, id, iT);
+ });
takeMeasurements(fineGrid4);
}
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();