From 860919a818e792185dc902b5be6754c0ff1e2dcb Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 30 Jan 2019 16:39:08 +0100 Subject: Refine cylinder2d to stay stable even at very low resolutions Somewhat fiddled together but works as expected. Refinement areas are informed by Knudsen metric results. The key is to refine the outflow. Sadly this requires refinement-overlap-crossing boundary conditions. Interface for detailed (i.e. cell-relative) grid refinement control still has room for improvement. Mixing physical indicators and cell alignment requirements is problematic. --- apps/adrian/cylinder2d/cylinder2d.cpp | 83 +++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 34 deletions(-) (limited to 'apps/adrian/cylinder2d') diff --git a/apps/adrian/cylinder2d/cylinder2d.cpp b/apps/adrian/cylinder2d/cylinder2d.cpp index ffab6a0..bf25417 100644 --- a/apps/adrian/cylinder2d/cylinder2d.cpp +++ b/apps/adrian/cylinder2d/cylinder2d.cpp @@ -39,11 +39,11 @@ typedef double T; /// Setup geometry relative to cylinder diameter as defined by [SchaeferTurek96] const T cylinderD = 1.0; -const int N = 20; // resolution of the model +const int N = 5; // resolution of the model const T lx = 22 * cylinderD; // length of the channel const T ly = 4.1 * cylinderD; // height of the channel const T Re = 100.; // Reynolds number -const T uLat = 0.1; // lattice velocity +const T uLat = 0.05; // lattice velocity const T maxPhysT = 60.; // max. simulation time in s, SI unit @@ -67,13 +67,13 @@ void prepareGeometry(Grid2D& grid) IndicatorCuboid2D lowerWall(wallExtend, wallOrigin); sGeometry.rename(1,2,lowerWall); - IndicatorCuboid2D upperWall(wallExtend, wallOrigin + Vector {0,ly}); + IndicatorCuboid2D upperWall(wallExtend, wallOrigin + Vector {0,ly-physSpacing/2}); sGeometry.rename(1,2,upperWall); } // Set material number for inflow and outflow { - const Vector extend { physSpacing/2, ly}; + const Vector extend { physSpacing/2, ly-physSpacing/2}; const Vector origin {-physSpacing/4, -physSpacing/4}; IndicatorCuboid2D inflow(extend, origin); @@ -216,27 +216,58 @@ int main(int argc, char* argv[]) coarseGrid.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta()); - sOnLatticeBoundaryCondition2D coarseSBoundaryCondition(coarseGrid.getSuperLattice()); - createLocalBoundaryCondition2D(coarseSBoundaryCondition); + sOnLatticeBoundaryCondition2D coarseBoundaryCondition(coarseGrid.getSuperLattice()); + createLocalBoundaryCondition2D(coarseBoundaryCondition); - const Vector fineExtend {16*cylinderD, 3.75*cylinderD}; - const Vector fineOrigin {0.75*cylinderD, (ly-fineExtend[1])/2}; + const auto coarseDeltaX = coarseGrid.getConverter().getPhysDeltaX(); + + const Vector fineExtend {8*cylinderD, ly-2*coarseDeltaX}; + const Vector fineOrigin {0.75*cylinderD, coarseDeltaX}; auto& fineGrid = coarseGrid.refine(fineOrigin, fineExtend); prepareGeometry(fineGrid); + const Vector fineExtendB {10*coarseDeltaX, ly}; + const Vector fineOriginB {lx-10*coarseDeltaX, 0}; + + auto& fineOutflowGrid = coarseGrid.refine(fineOriginB, fineExtendB, false); + prepareGeometry(fineOutflowGrid); + + { + const Vector origin = fineOutflowGrid.getOrigin(); + const Vector extend = fineOutflowGrid.getExtend(); + + const Vector extendY = {0,extend[1]}; + + coarseGrid.addFineCoupling(fineOutflowGrid, origin, extendY); + coarseGrid.addCoarseCoupling(fineOutflowGrid, origin + Vector {coarseDeltaX,0}, extendY); + + IndicatorCuboid2D refined(extend, origin + Vector {2*coarseDeltaX,0}); + + coarseGrid.getSuperGeometry().rename(1,0,refined); + coarseGrid.getSuperGeometry().rename(2,0,refined); + coarseGrid.getSuperGeometry().rename(4,0,refined); + } + disableRefinedArea(coarseGrid, fineGrid); BGKdynamics fineBulkDynamics( fineGrid.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta()); - sOnLatticeBoundaryCondition2D fineSBoundaryCondition(fineGrid.getSuperLattice()); - createLocalBoundaryCondition2D(fineSBoundaryCondition); + sOnLatticeBoundaryCondition2D fineBoundaryCondition(fineGrid.getSuperLattice()); + createLocalBoundaryCondition2D(fineBoundaryCondition); - prepareLattice(coarseGrid, coarseBulkDynamics, coarseSBoundaryCondition); + BGKdynamics fineOutflowBulkDynamics( + fineOutflowGrid.getConverter().getLatticeRelaxationFrequency(), + instances::getBulkMomenta()); + + sOnLatticeBoundaryCondition2D fineOutflowBoundaryCondition(fineOutflowGrid.getSuperLattice()); + createLocalBoundaryCondition2D(fineOutflowBoundaryCondition); + + prepareLattice(coarseGrid, coarseBulkDynamics, coarseBoundaryCondition); - const Vector fineExtend2 {11*cylinderD, 3*cylinderD}; + const Vector fineExtend2 {4*cylinderD, 2*cylinderD}; const Vector fineOrigin2 {1*cylinderD, 2*cylinderD-fineExtend2[1]/2}; auto& fineGrid2 = fineGrid.refine(fineOrigin2, fineExtend2); @@ -248,29 +279,13 @@ int main(int argc, char* argv[]) fineGrid2.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta()); - sOnLatticeBoundaryCondition2D fineSBoundaryCondition2(fineGrid2.getSuperLattice()); - createLocalBoundaryCondition2D(fineSBoundaryCondition2); - - prepareLattice(fineGrid, fineBulkDynamics, fineSBoundaryCondition); - - const Vector fineExtend3 {1.5*cylinderD, 1.5*cylinderD}; - const Vector fineOrigin3 {2*cylinderD-fineExtend3[0]/2, 2*cylinderD-fineExtend3[1]/2}; - - auto& fineGrid3 = fineGrid2.refine(fineOrigin3, fineExtend3); - prepareGeometry(fineGrid3); - - disableRefinedArea(fineGrid2, fineGrid3); - - BGKdynamics fineBulkDynamics3( - fineGrid3.getConverter().getLatticeRelaxationFrequency(), - instances::getBulkMomenta()); - - sOnLatticeBoundaryCondition2D fineSBoundaryCondition3(fineGrid3.getSuperLattice()); - createLocalBoundaryCondition2D(fineSBoundaryCondition3); + sOnLatticeBoundaryCondition2D fineBoundaryCondition2(fineGrid2.getSuperLattice()); + createLocalBoundaryCondition2D(fineBoundaryCondition2); - prepareLattice(fineGrid2, fineBulkDynamics2, fineSBoundaryCondition2); + prepareLattice(fineGrid, fineBulkDynamics, fineBoundaryCondition); + prepareLattice(fineOutflowGrid, fineOutflowBulkDynamics, fineOutflowBoundaryCondition); - prepareLattice(fineGrid3, fineBulkDynamics3, fineSBoundaryCondition3); + prepareLattice(fineGrid2, fineBulkDynamics2, fineBoundaryCondition2); clout << "Starting simulation..." << endl; Timer timer( @@ -286,8 +301,8 @@ int main(int argc, char* argv[]) getResults("level0_", coarseGrid, iT); getResults("level1_", fineGrid, iT); + getResults("level1_outflow_", fineOutflowGrid, iT); getResults("level2_", fineGrid2, iT); - getResults("level3_", fineGrid3, iT); if (iT%statIter == 0) { timer.update(iT); -- cgit v1.2.3