From f234abc7b3474a4ea3d2a1544108a151f1189fd5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 17 Jan 2019 16:21:42 +0100 Subject: Attenuate cylinder2d inflow velocity increase --- apps/adrian/cylinder2d/cylinder2d.cpp | 89 ++++++++++++++++++----------------- src/refinement/coupler2D.hh | 6 +-- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/apps/adrian/cylinder2d/cylinder2d.cpp b/apps/adrian/cylinder2d/cylinder2d.cpp index 739c02c..33028c0 100644 --- a/apps/adrian/cylinder2d/cylinder2d.cpp +++ b/apps/adrian/cylinder2d/cylinder2d.cpp @@ -42,10 +42,7 @@ const T ly = 2.0; // height of the channel const int N = 100; // resolution of the model const T Re = 1000.; // Reynolds number const T baseTau = 0.52; // Relaxation time of coarsest grid -const T maxPhysT = 60.; // max. simulation time in s, SI unit -const T physInterval = 0.25; // interval for the convergence check in s -const T residuum = 1e-5; // residuum for the convergence check - +const T maxPhysT = 120.; // max. simulation time in s, SI unit void prepareGeometry(Grid2D& grid) { @@ -83,10 +80,10 @@ void prepareGeometry(Grid2D& grid) sGeometry.rename(1,4,outflow); } - // Set material number for vertically centered obstacle + // Set material number for vertically centered cylinder { const Vector origin {1.25, ly/2}; - IndicatorCircle2D obstacle(origin, 0.15); + IndicatorCircle2D obstacle(origin, 0.2); sGeometry.rename(1,2,obstacle); } @@ -120,35 +117,50 @@ void prepareLattice(Grid2D& grid, sBoundaryCondition.addVelocityBoundary(sGeometry, 3, omega); sBoundaryCondition.addPressureBoundary(sGeometry, 4, omega); - const T Lx = converter.getLatticeLength(lx); - const T Ly = converter.getLatticeLength(ly); - const T p0 = 8.*converter.getLatticeViscosity()*converter.getCharLatticeVelocity()*Lx/(Ly*Ly); - AnalyticalLinear2D rho(-p0/lx*DESCRIPTOR::invCs2, 0, p0*DESCRIPTOR::invCs2+1); - - const T maxVelocity = converter.getCharLatticeVelocity(); - const T radius = ly/2; - std::vector axisPoint{0, ly/2}; - std::vector axisDirection{1, 0}; - Poiseuille2D u(axisPoint, axisDirection, maxVelocity, radius); - - sLattice.defineRhoU(sGeometry, 1, rho, u); - sLattice.iniEquilibrium(sGeometry, 1, rho, u); - sLattice.defineRhoU(sGeometry, 2, rho, u); - sLattice.iniEquilibrium(sGeometry, 2, rho, u); + AnalyticalConst2D rho0(1.0); + AnalyticalConst2D u0(0.0, 0.0); - sLattice.defineRhoU(sGeometry, 3, rho, u); - sLattice.iniEquilibrium(sGeometry, 3, rho, u); - sLattice.defineRhoU(sGeometry, 4, rho, u); - sLattice.iniEquilibrium(sGeometry, 4, rho, u); + auto materials = sGeometry.getMaterialIndicator({1, 3, 4}); + sLattice.defineRhoU(materials, rho0, u0); + sLattice.iniEquilibrium(materials, rho0, u0); sLattice.initialize(); clout << "Prepare lattice ... OK" << std::endl; } +void setBoundaryValues(Grid2D& grid, int iT) +{ + auto& converter = grid.getConverter(); + auto& sGeometry = grid.getSuperGeometry(); + auto& sLattice = grid.getSuperLattice(); + + const int iTmaxStart = converter.getLatticeTime(0.1 * maxPhysT); + const int iTupdate = 50; + + if ( iT % iTupdate == 0 && iT <= iTmaxStart ) { + OstreamManager clout(std::cout,"setBoundaryValues"); + clout << "Update inflow." << std::endl; + + PolynomialStartScale StartScale(iTmaxStart, 1.0); + + T iTvec[1] { T(iT) }; + T frac[1] { }; + StartScale(frac, iTvec); + + const T maxVelocity = converter.getCharLatticeVelocity() * frac[0]; + const T radius = ly/2; + std::vector axisPoint{0, ly/2}; + std::vector axisDirection{1, 0}; + Poiseuille2D u(axisPoint, axisDirection, maxVelocity, radius); + + sLattice.defineU(sGeometry, 3, u); + } +} + void getResults(const std::string& prefix, Grid2D& grid, - int iT, Timer& timer, bool hasConverged) + int iT, Timer& timer) { OstreamManager clout(std::cout,"getResults"); @@ -174,7 +186,7 @@ void getResults(const std::string& prefix, vtmWriter.write(iT); } - if (iT%statIter==0 || hasConverged) { + if (iT%statIter==0 ) { timer.update(iT); timer.printStep(); @@ -221,7 +233,7 @@ int main(int argc, char* argv[]) sOnLatticeBoundaryCondition2D fineSBoundaryCondition(fineGrid.getSuperLattice()); createLocalBoundaryCondition2D(fineSBoundaryCondition); - const Vector fineExtend2 {0.8, 0.6}; + const Vector fineExtend2 {1.2, 0.8}; const Vector fineOrigin2 {0.95, (ly-fineExtend2[1])/2}; auto& fineGrid2 = fineGrid.refine(fineOrigin2, fineExtend2); @@ -242,20 +254,14 @@ int main(int argc, char* argv[]) prepareLattice(fineGrid2, fineBulkDynamics2, fineSBoundaryCondition2); - clout << "starting simulation..." << endl; + clout << "Starting simulation..." << endl; Timer timer( coarseGrid.getConverter().getLatticeTime(maxPhysT), coarseGrid.getSuperGeometry().getStatistics().getNvoxel()); - util::ValueTracer converge( - fineGrid2.getConverter().getLatticeTime(physInterval), - residuum); timer.start(); for (int iT = 0; iT < coarseGrid.getConverter().getLatticeTime(maxPhysT); ++iT) { - if (converge.hasConverged()) { - clout << "Simulation converged." << endl; - break; - } + setBoundaryValues(coarseGrid, iT); coarseGrid.collideAndStream(); @@ -263,22 +269,17 @@ int main(int argc, char* argv[]) "coarse_", coarseGrid, iT, - timer, - converge.hasConverged()); + timer); getResults( "fine_", fineGrid, iT, - timer, - converge.hasConverged()); + timer); getResults( "fine2_", fineGrid2, iT, - timer, - converge.hasConverged()); - - converge.takeValue(fineGrid2.getSuperLattice().getStatistics().getAverageEnergy(), true); + timer); } timer.stop(); diff --git a/src/refinement/coupler2D.hh b/src/refinement/coupler2D.hh index 78aad46..92c8d26 100644 --- a/src/refinement/coupler2D.hh +++ b/src/refinement/coupler2D.hh @@ -201,9 +201,9 @@ void FineCoupler2D::couple() } for (int y=1; y < this->_coarseSize-2; ++y) { - const auto rho = order2interpolation(_c2f_rho, y); - const auto u = order2interpolation(_c2f_u, y); - const auto fneq = order2interpolation(_c2f_fneq, y); + const auto rho = order4interpolation(_c2f_rho, y); + const auto u = order4interpolation(_c2f_u, y); + const auto fneq = order4interpolation(_c2f_fneq, y); const T uSqr = u*u; -- cgit v1.2.3