summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-30 20:12:31 +0100
committerAdrian Kummerlaender2019-06-24 15:17:09 +0200
commit5e888fc13f38c94777963d72fc9e391cd4fa477a (patch)
tree75a018f2ec897879de28d4cc31aae16f48ae658e
parent860919a818e792185dc902b5be6754c0ff1e2dcb (diff)
downloadgrid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar.gz
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar.bz2
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar.lz
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar.xz
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.tar.zst
grid_refinement_openlb-5e888fc13f38c94777963d72fc9e391cd4fa477a.zip
Manage dynamics, boundary condition memory in Grid2D
Mainly to further declutter simulation and refinement setup
-rw-r--r--apps/adrian/cylinder2d/cylinder2d.cpp51
-rw-r--r--apps/adrian/poiseuille2d/poiseuille2d.cpp31
-rw-r--r--src/refinement/grid2D.h6
-rw-r--r--src/refinement/grid2D.hh17
4 files changed, 49 insertions, 56 deletions
diff --git a/apps/adrian/cylinder2d/cylinder2d.cpp b/apps/adrian/cylinder2d/cylinder2d.cpp
index bf25417..0893928 100644
--- a/apps/adrian/cylinder2d/cylinder2d.cpp
+++ b/apps/adrian/cylinder2d/cylinder2d.cpp
@@ -108,9 +108,7 @@ void disableRefinedArea(Grid2D<T,DESCRIPTOR>& coarseGrid,
sGeometry.rename(5,0,*refinedOverlap);
}
-void prepareLattice(Grid2D<T,DESCRIPTOR>& grid,
- Dynamics<T, DESCRIPTOR>& bulkDynamics,
- sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition)
+void prepareLattice(Grid2D<T,DESCRIPTOR>& grid)
{
OstreamManager clout(std::cout,"prepareLattice");
clout << "Prepare lattice ..." << std::endl;
@@ -119,6 +117,15 @@ void prepareLattice(Grid2D<T,DESCRIPTOR>& grid,
auto& sGeometry = grid.getSuperGeometry();
auto& sLattice = grid.getSuperLattice();
+ Dynamics<T,DESCRIPTOR>& bulkDynamics = grid.addDynamics(
+ std::unique_ptr<Dynamics<T,DESCRIPTOR>>(
+ new BGKdynamics<T,DESCRIPTOR>(
+ grid.getConverter().getLatticeRelaxationFrequency(),
+ instances::getBulkMomenta<T,DESCRIPTOR>())));
+
+ sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition = grid.getOnLatticeBoundaryCondition();
+ createLocalBoundaryCondition2D<T,DESCRIPTOR>(sBoundaryCondition);
+
const T omega = converter.getLatticeRelaxationFrequency();
sLattice.defineDynamics(sGeometry, 0, &instances::getNoDynamics<T,DESCRIPTOR>());
@@ -212,13 +219,6 @@ int main(int argc, char* argv[])
Grid2D<T,DESCRIPTOR> coarseGrid(coarseCuboid, N, LatticeVelocity<T>(uLat), Re);
prepareGeometry(coarseGrid);
- BGKdynamics<T, DESCRIPTOR> coarseBulkDynamics(
- coarseGrid.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T, DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> coarseBoundaryCondition(coarseGrid.getSuperLattice());
- createLocalBoundaryCondition2D<T, DESCRIPTOR>(coarseBoundaryCondition);
-
const auto coarseDeltaX = coarseGrid.getConverter().getPhysDeltaX();
const Vector<T,2> fineExtend {8*cylinderD, ly-2*coarseDeltaX};
@@ -251,22 +251,6 @@ int main(int argc, char* argv[])
disableRefinedArea(coarseGrid, fineGrid);
- BGKdynamics<T, DESCRIPTOR> fineBulkDynamics(
- fineGrid.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T, DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineBoundaryCondition(fineGrid.getSuperLattice());
- createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineBoundaryCondition);
-
- BGKdynamics<T, DESCRIPTOR> fineOutflowBulkDynamics(
- fineOutflowGrid.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T, DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineOutflowBoundaryCondition(fineOutflowGrid.getSuperLattice());
- createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineOutflowBoundaryCondition);
-
- prepareLattice(coarseGrid, coarseBulkDynamics, coarseBoundaryCondition);
-
const Vector<T,2> fineExtend2 {4*cylinderD, 2*cylinderD};
const Vector<T,2> fineOrigin2 {1*cylinderD, 2*cylinderD-fineExtend2[1]/2};
@@ -275,17 +259,10 @@ int main(int argc, char* argv[])
disableRefinedArea(fineGrid, fineGrid2);
- BGKdynamics<T, DESCRIPTOR> fineBulkDynamics2(
- fineGrid2.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T, DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineBoundaryCondition2(fineGrid2.getSuperLattice());
- createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineBoundaryCondition2);
-
- prepareLattice(fineGrid, fineBulkDynamics, fineBoundaryCondition);
- prepareLattice(fineOutflowGrid, fineOutflowBulkDynamics, fineOutflowBoundaryCondition);
-
- prepareLattice(fineGrid2, fineBulkDynamics2, fineBoundaryCondition2);
+ prepareLattice(coarseGrid);
+ prepareLattice(fineGrid);
+ prepareLattice(fineOutflowGrid);
+ prepareLattice(fineGrid2);
clout << "Starting simulation..." << endl;
Timer<T> timer(
diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp
index 034fb08..4091905 100644
--- a/apps/adrian/poiseuille2d/poiseuille2d.cpp
+++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp
@@ -90,9 +90,7 @@ void prepareGeometry(Grid2D<T,DESCRIPTOR>& grid)
clout << "Prepare Geometry ... OK" << std::endl;
}
-void prepareLattice(Grid2D<T,DESCRIPTOR>& grid,
- Dynamics<T,DESCRIPTOR>& bulkDynamics,
- sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition)
+void prepareLattice(Grid2D<T,DESCRIPTOR>& grid)
{
OstreamManager clout(std::cout,"prepareLattice");
clout << "Prepare lattice ..." << std::endl;
@@ -101,6 +99,15 @@ void prepareLattice(Grid2D<T,DESCRIPTOR>& grid,
auto& sGeometry = grid.getSuperGeometry();
auto& sLattice = grid.getSuperLattice();
+ Dynamics<T,DESCRIPTOR>& bulkDynamics = grid.addDynamics(
+ std::unique_ptr<Dynamics<T,DESCRIPTOR>>(
+ new BGKdynamics<T,DESCRIPTOR>(
+ grid.getConverter().getLatticeRelaxationFrequency(),
+ instances::getBulkMomenta<T,DESCRIPTOR>())));
+
+ sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition = grid.getOnLatticeBoundaryCondition();
+ createInterpBoundaryCondition2D<T,DESCRIPTOR>(sBoundaryCondition);
+
const T omega = converter.getLatticeRelaxationFrequency();
sLattice.defineDynamics(sGeometry, 0, &instances::getNoDynamics<T,DESCRIPTOR>());
@@ -237,23 +244,9 @@ int main(int argc, char* argv[])
prepareGeometry(fineGrid);
- BGKdynamics<T,DESCRIPTOR> coarseBulkDynamics(
- coarseGrid.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T,DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T,DESCRIPTOR> coarseSBoundaryCondition(coarseGrid.getSuperLattice());
- createInterpBoundaryCondition2D<T,DESCRIPTOR>(coarseSBoundaryCondition);
-
- prepareLattice(coarseGrid, coarseBulkDynamics, coarseSBoundaryCondition);
-
- BGKdynamics<T,DESCRIPTOR> fineBulkDynamics(
- fineGrid.getConverter().getLatticeRelaxationFrequency(),
- instances::getBulkMomenta<T,DESCRIPTOR>());
-
- sOnLatticeBoundaryCondition2D<T,DESCRIPTOR> fineSBoundaryCondition(fineGrid.getSuperLattice());
- createInterpBoundaryCondition2D<T,DESCRIPTOR>(fineSBoundaryCondition);
+ prepareLattice(coarseGrid);
- prepareLattice(fineGrid, fineBulkDynamics, fineSBoundaryCondition);
+ prepareLattice(fineGrid);
clout << "starting simulation..." << endl;
Timer<T> timer(
diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h
index f58a4ea..37e764a 100644
--- a/src/refinement/grid2D.h
+++ b/src/refinement/grid2D.h
@@ -77,6 +77,9 @@ protected:
std::unique_ptr<SuperGeometry2D<T>> _geometry;
std::unique_ptr<SuperLattice2D<T,DESCRIPTOR>> _lattice;
+ std::vector<std::unique_ptr<Dynamics<T,DESCRIPTOR>>> _dynamics;
+ std::vector<std::unique_ptr<sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>>> _onLatticeBoundaryConditions;
+
std::vector<std::unique_ptr<RefiningGrid2D<T,DESCRIPTOR>>> _fineGrids;
std::vector<std::unique_ptr<FineCoupler2D<T,DESCRIPTOR>>> _fineCouplers;
@@ -92,6 +95,9 @@ public:
SuperGeometry2D<T>& getSuperGeometry();
SuperLattice2D<T,DESCRIPTOR>& getSuperLattice();
+ Dynamics<T,DESCRIPTOR>& addDynamics(std::unique_ptr<Dynamics<T,DESCRIPTOR>>&& dynamics);
+ sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& getOnLatticeBoundaryCondition();
+
void collideAndStream();
FineCoupler2D<T,DESCRIPTOR>& addFineCoupling(
diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh
index f1caf84..941bff7 100644
--- a/src/refinement/grid2D.hh
+++ b/src/refinement/grid2D.hh
@@ -134,6 +134,23 @@ SuperLattice2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::getSuperLattice()
}
template <typename T, template<typename> class DESCRIPTOR>
+Dynamics<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::addDynamics(
+ std::unique_ptr<Dynamics<T,DESCRIPTOR>>&& dynamics)
+{
+ Dynamics<T,DESCRIPTOR>& ref = *dynamics;
+ _dynamics.emplace_back(std::move(dynamics));
+ return ref;
+}
+
+template <typename T, template<typename> class DESCRIPTOR>
+sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::getOnLatticeBoundaryCondition()
+{
+ _onLatticeBoundaryConditions.emplace_back(
+ new sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>(getSuperLattice()));
+ return *_onLatticeBoundaryConditions.back();
+}
+
+template <typename T, template<typename> class DESCRIPTOR>
void Grid2D<T,DESCRIPTOR>::collideAndStream()
{
for ( auto& fineCoupler : _fineCouplers ) {