From e1626f2eb19215482aa6f17966f5e54e3a0c4faa Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 8 Jan 2019 14:44:44 +0100 Subject: Further indicatorize geometry setup Grid refinement is at its easiest when discrete materials are set using analytical - i.e. resolution independent - indicators. --- apps/adrian/poiseuille2d/poiseuille2d.cpp | 75 ++++++++++++++++++------------- 1 file changed, 43 insertions(+), 32 deletions(-) (limited to 'apps/adrian/poiseuille2d') diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp index f30e9b4..c8a4659 100644 --- a/apps/adrian/poiseuille2d/poiseuille2d.cpp +++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp @@ -35,8 +35,8 @@ typedef double T; #define DESCRIPTOR D2Q9Descriptor -const T lx = 4.; // length of the channel -const T ly = 1.; // height of the channel +const T lx = 4.0; // length of the channel +const T ly = 1.0; // height of the channel const int N = 30; // resolution of the model const T Re = 100.; // Reynolds number const T maxPhysT = 60.; // max. simulation time in s, SI unit @@ -51,32 +51,45 @@ void prepareGeometry(UnitConverter const& converter, OstreamManager clout(std::cout,"prepareGeometry"); clout << "Prepare Geometry ..." << std::endl; - superGeometry.rename(0,2); + superGeometry.rename(0,1); + + const T physSpacing = converter.getPhysDeltaX(); + // Set material number for bounce back boundaries - superGeometry.rename(2,1,0,1); + { + const Vector wallExtend {lx+physSpacing, physSpacing/2}; + const Vector wallOrigin {-physSpacing/4, -physSpacing/4}; + + IndicatorCuboid2D lowerWall(wallExtend, wallOrigin); + superGeometry.rename(1,2,lowerWall); - T physSpacing = converter.getPhysDeltaX(); - Vector extend{ physSpacing / 2, ly }; - Vector origin{ -physSpacing / 4, 0 }; + IndicatorCuboid2D upperWall(wallExtend, wallOrigin + Vector {0,ly}); + superGeometry.rename(1,2,upperWall); + } + + // Set material number for inflow and outflow + { + const Vector extend { physSpacing/2, ly}; + const Vector origin {-physSpacing/4, -physSpacing/4}; - // Set material number for inflow - IndicatorCuboid2D inflow(extend, origin); - superGeometry.rename(1,3,1,inflow); + IndicatorCuboid2D inflow(extend, origin); + superGeometry.rename(1,3,inflow); - // Set material number for outflow - origin[0] = lx - physSpacing / 4; - IndicatorCuboid2D outflow(extend, origin); - superGeometry.rename(1,4,1,outflow); + IndicatorCuboid2D outflow(extend, origin + Vector {lx,0}); + superGeometry.rename(1,4,outflow); + } - IndicatorCuboid2D obstacle(Vector {0.2,0.1}, Vector {1.25,0.45}); - superGeometry.rename(1,5,obstacle); + // Set material number for vertically centered obstacle + { + const Vector extend {0.1, 0.1}; + const Vector origin {1.25, (ly-extend[1])/2}; + IndicatorCuboid2D obstacle(extend, origin); + superGeometry.rename(1,2,obstacle); + } - // Removes all not needed boundary voxels outside the surface superGeometry.clean(); - // Removes all not needed boundary voxels inside the surface superGeometry.innerClean(); superGeometry.checkForErrors(); - superGeometry.print(); clout << "Prepare Geometry ... OK" << std::endl; @@ -203,27 +216,25 @@ int main(int argc, char* argv[]) singleton::directories().setOutputDir("./tmp/"); OstreamManager clout(std::cout,"main"); - Vector coarseOrigin { 0.0, 0.0 }; - Vector coarseExtend { lx, ly }; + const Vector coarseOrigin {0.0, 0.0}; + const Vector coarseExtend {lx, ly}; IndicatorCuboid2D coarseCuboid(coarseExtend, coarseOrigin); - Vector fineOrigin { 0.25 * lx, 0.2 }; - Vector fineExtend { 0.6 * lx, 0.6 }; - auto coarseGrid = Grid2D::make(coarseCuboid, N, 0.8, Re); - auto fineGrid = &coarseGrid->refine(fineOrigin, fineExtend); - prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry()); + + const Vector wantedFineExtend {2.0, 0.75}; + const Vector fineOrigin = coarseGrid->alignToGrid({0.8, (ly-wantedFineExtend[1])/2}); + const Vector fineExtend = coarseGrid->alignToGrid(fineOrigin + wantedFineExtend) - fineOrigin; + + auto fineGrid = &coarseGrid->refine(fineOrigin, fineExtend); 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); - coarseGrid->getSuperGeometry().rename(1,0,overlapCuboid); - coarseGrid->getSuperGeometry().rename(2,0,overlapCuboid); - coarseGrid->getSuperGeometry().rename(5,0,overlapCuboid); + IndicatorCuboid2D refinedOverlap(fineExtend - 4*coarseDeltaX, fineOrigin + 2*coarseDeltaX); + coarseGrid->getSuperGeometry().rename(1,0,refinedOverlap); + coarseGrid->getSuperGeometry().rename(2,0,refinedOverlap); Dynamics* coarseBulkDynamics; coarseBulkDynamics = new BGKdynamics( -- cgit v1.2.3