From 5e888fc13f38c94777963d72fc9e391cd4fa477a Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 30 Jan 2019 20:12:31 +0100 Subject: Manage dynamics, boundary condition memory in Grid2D Mainly to further declutter simulation and refinement setup --- apps/adrian/cylinder2d/cylinder2d.cpp | 51 ++++++++++------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) (limited to 'apps/adrian/cylinder2d') 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& coarseGrid, sGeometry.rename(5,0,*refinedOverlap); } -void prepareLattice(Grid2D& grid, - Dynamics& bulkDynamics, - sOnLatticeBoundaryCondition2D& sBoundaryCondition) +void prepareLattice(Grid2D& grid) { OstreamManager clout(std::cout,"prepareLattice"); clout << "Prepare lattice ..." << std::endl; @@ -119,6 +117,15 @@ void prepareLattice(Grid2D& grid, auto& sGeometry = grid.getSuperGeometry(); auto& sLattice = grid.getSuperLattice(); + Dynamics& bulkDynamics = grid.addDynamics( + std::unique_ptr>( + new BGKdynamics( + grid.getConverter().getLatticeRelaxationFrequency(), + instances::getBulkMomenta()))); + + sOnLatticeBoundaryCondition2D& sBoundaryCondition = grid.getOnLatticeBoundaryCondition(); + createLocalBoundaryCondition2D(sBoundaryCondition); + const T omega = converter.getLatticeRelaxationFrequency(); sLattice.defineDynamics(sGeometry, 0, &instances::getNoDynamics()); @@ -212,13 +219,6 @@ int main(int argc, char* argv[]) Grid2D coarseGrid(coarseCuboid, N, LatticeVelocity(uLat), Re); prepareGeometry(coarseGrid); - BGKdynamics coarseBulkDynamics( - coarseGrid.getConverter().getLatticeRelaxationFrequency(), - instances::getBulkMomenta()); - - sOnLatticeBoundaryCondition2D coarseBoundaryCondition(coarseGrid.getSuperLattice()); - createLocalBoundaryCondition2D(coarseBoundaryCondition); - const auto coarseDeltaX = coarseGrid.getConverter().getPhysDeltaX(); const Vector fineExtend {8*cylinderD, ly-2*coarseDeltaX}; @@ -251,22 +251,6 @@ int main(int argc, char* argv[]) disableRefinedArea(coarseGrid, fineGrid); - BGKdynamics fineBulkDynamics( - fineGrid.getConverter().getLatticeRelaxationFrequency(), - instances::getBulkMomenta()); - - sOnLatticeBoundaryCondition2D fineBoundaryCondition(fineGrid.getSuperLattice()); - createLocalBoundaryCondition2D(fineBoundaryCondition); - - BGKdynamics fineOutflowBulkDynamics( - fineOutflowGrid.getConverter().getLatticeRelaxationFrequency(), - instances::getBulkMomenta()); - - sOnLatticeBoundaryCondition2D fineOutflowBoundaryCondition(fineOutflowGrid.getSuperLattice()); - createLocalBoundaryCondition2D(fineOutflowBoundaryCondition); - - prepareLattice(coarseGrid, coarseBulkDynamics, coarseBoundaryCondition); - const Vector fineExtend2 {4*cylinderD, 2*cylinderD}; const Vector fineOrigin2 {1*cylinderD, 2*cylinderD-fineExtend2[1]/2}; @@ -275,17 +259,10 @@ int main(int argc, char* argv[]) disableRefinedArea(fineGrid, fineGrid2); - BGKdynamics fineBulkDynamics2( - fineGrid2.getConverter().getLatticeRelaxationFrequency(), - instances::getBulkMomenta()); - - sOnLatticeBoundaryCondition2D fineBoundaryCondition2(fineGrid2.getSuperLattice()); - createLocalBoundaryCondition2D(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 timer( -- cgit v1.2.3