From 4eb1efbc9fe9661762a097f03934a9bc52024f28 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 8 Jan 2019 09:58:11 +0100 Subject: Tidy up grid coupler construction --- apps/adrian/poiseuille2d/poiseuille2d.cpp | 77 ++++++++++++++++++------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp index 9f92c2a..9ef1ce8 100644 --- a/apps/adrian/poiseuille2d/poiseuille2d.cpp +++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp @@ -313,45 +313,58 @@ public: } } - Grid* refine(Vector origin, Vector extend) + FineCoupler& addFineCoupling( + Grid& fineGrid, Vector origin, Vector extend) + { + _fineCouplers.emplace_back( + new FineCoupler( + *this, fineGrid, origin, extend)); + return *_fineCouplers.back(); + } + + CoarseCoupler& addCoarseCoupling( + Grid& fineGrid, Vector origin, Vector extend) + { + _coarseCouplers.emplace_back( + new CoarseCoupler( + *this, fineGrid, origin, extend)); + return *_coarseCouplers.back(); + } + + Grid& refine(IndicatorF2D& domainF) { - IndicatorCuboid2D fineCuboid(extend, origin); _fineGrids.emplace_back( new Grid( - fineCuboid, + domainF, 2*getConverter().getResolution(), 2.0*getConverter().getLatticeRelaxationTime() - 0.5, getConverter().getReynoldsNumber() )); - Grid* const fineGrid = _fineGrids.back().get(); + return *_fineGrids.back(); + } - const T coarseDeltaX = getConverter().getPhysDeltaX(); + Grid& refine(Vector origin, Vector extend) + { + IndicatorCuboid2D fineCuboid(extend, origin); + auto& fineGrid = refine(fineCuboid); - _fineCouplers.emplace_back( - new FineCoupler( - *this, *fineGrid, origin, Vector {0,extend[1]})); - _fineCouplers.emplace_back( - new FineCoupler( - *this, *fineGrid, origin + Vector {extend[0],0}, Vector {0,extend[1]})); - _fineCouplers.emplace_back( - new FineCoupler( - *this, *fineGrid, origin + Vector(0,extend[1]), Vector {extend[0],0})); - _fineCouplers.emplace_back( - new FineCoupler( - *this, *fineGrid, origin, Vector {extend[0],0})); + const Vector extendX = {extend[0],0}; + const Vector extendY = {0,extend[1]}; - _coarseCouplers.emplace_back( - new CoarseCoupler( - *this, *fineGrid, origin + coarseDeltaX, Vector {0,extend[1]-2*coarseDeltaX})); - _coarseCouplers.emplace_back( - new CoarseCoupler( - *this, *fineGrid, origin + Vector(extend[0]-coarseDeltaX,coarseDeltaX), Vector {0,extend[1]-2*coarseDeltaX})); - _coarseCouplers.emplace_back( - new CoarseCoupler( - *this, *fineGrid, origin + Vector {coarseDeltaX,extend[1]-coarseDeltaX}, Vector {extend[0]-2*coarseDeltaX,0})); - _coarseCouplers.emplace_back( - new CoarseCoupler( - *this, *fineGrid, origin + coarseDeltaX, Vector {extend[0]-2*coarseDeltaX,0})); + addFineCoupling(fineGrid, origin, extendY); + addFineCoupling(fineGrid, origin + extendX, extendY); + addFineCoupling(fineGrid, origin + extendY, extendX); + addFineCoupling(fineGrid, origin, extendX); + + const T coarseDeltaX = getConverter().getPhysDeltaX(); + const Vector innerOrigin = origin + coarseDeltaX; + const Vector innerExtendX = extendX - Vector {2*coarseDeltaX,0}; + const Vector innerExtendY = extendY - Vector {0,2*coarseDeltaX}; + + addCoarseCoupling(fineGrid, innerOrigin, innerExtendY); + addCoarseCoupling(fineGrid, innerOrigin + innerExtendX, innerExtendY); + addCoarseCoupling(fineGrid, innerOrigin + innerExtendY, innerExtendX); + addCoarseCoupling(fineGrid, innerOrigin, innerExtendX); return fineGrid; } @@ -684,8 +697,6 @@ int main(int argc, char* argv[]) singleton::directories().setOutputDir("./tmp/"); OstreamManager clout(std::cout,"main"); - const T coarseDeltaX = 1./N; - Vector coarseOrigin { 0.0, 0.0 }; Vector coarseExtend { lx, ly }; IndicatorCuboid2D coarseCuboid(coarseExtend, coarseOrigin); @@ -694,11 +705,13 @@ int main(int argc, char* argv[]) Vector fineExtend { 0.6 * lx, 0.6 }; auto coarseGrid = Grid::make(coarseCuboid, N, 0.8, Re); - auto fineGrid = coarseGrid->refine(fineOrigin, fineExtend); + auto fineGrid = &coarseGrid->refine(fineOrigin, fineExtend); prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry()); prepareGeometry(fineGrid->getConverter(), fineGrid->getSuperGeometry()); + const T coarseDeltaX = coarseGrid->getConverter().getPhysDeltaX(); + fineGrid->getSuperGeometry().rename(2,1); fineGrid->getSuperGeometry().rename(5,2); IndicatorCuboid2D overlapCuboid(fineExtend - 4*coarseDeltaX, fineOrigin + 2*coarseDeltaX); -- cgit v1.2.3