/* Lattice Boltzmann sample, written in C++, using the OpenLB * library * * Copyright (C) 2007, 2012 Jonas Latt, Mathias J. Krause * Vojtech Cvrcek, Peter Weisbrod * E-mail contact: info@openlb.net * The most recent release of OpenLB can be downloaded at * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "olb2D.h" #include "olb2D.hh" #include using namespace olb; using namespace olb::descriptors; typedef double T; #define DESCRIPTOR D2Q9Descriptor const T lx = 4.; // length of the channel const T ly = 1.; // 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 const T physInterval = 0.25; // interval for the convergence check in s const T residuum = 1e-5; // residuum for the convergence check void prepareGeometry(UnitConverter const& converter, SuperGeometry2D& superGeometry) { OstreamManager clout(std::cout,"prepareGeometry"); clout << "Prepare Geometry ..." << std::endl; superGeometry.rename(0,2); // Set material number for bounce back boundaries superGeometry.rename(2,1,0,1); T physSpacing = converter.getPhysDeltaX(); Vector extend{ physSpacing / 2, ly }; Vector origin{ -physSpacing / 4, 0 }; // Set material number for inflow IndicatorCuboid2D inflow(extend, origin); superGeometry.rename(1,3,1,inflow); // Set material number for outflow origin[0] = lx - physSpacing / 4; IndicatorCuboid2D outflow(extend, origin); superGeometry.rename(1,4,1,outflow); IndicatorCuboid2D obstacle(Vector {0.2,0.1}, Vector {1.25,0.45}); superGeometry.rename(1,5,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; } void prepareCoarseLattice(UnitConverter const& converter, SuperLattice2D& sLattice, Dynamics& bulkDynamics, sOnLatticeBoundaryCondition2D& sBoundaryCondition, SuperGeometry2D& superGeometry) { OstreamManager clout(std::cout,"prepareLattice"); clout << "Prepare coarse lattice ..." << std::endl; const T omega = converter.getLatticeRelaxationFrequency(); sLattice.defineDynamics(superGeometry, 0, &instances::getNoDynamics()); sLattice.defineDynamics(superGeometry, 1, &bulkDynamics); // bulk sLattice.defineDynamics(superGeometry, 2, &instances::getBounceBack()); sLattice.defineDynamics(superGeometry, 3, &bulkDynamics); // inflow sLattice.defineDynamics(superGeometry, 4, &bulkDynamics); // outflow sBoundaryCondition.addVelocityBoundary(superGeometry, 3, omega); sBoundaryCondition.addPressureBoundary(superGeometry, 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(superGeometry, 1, rho, u); sLattice.iniEquilibrium(superGeometry, 1, rho, u); sLattice.defineRhoU(superGeometry, 2, rho, u); sLattice.iniEquilibrium(superGeometry, 2, rho, u); sLattice.defineRhoU(superGeometry, 3, rho, u); sLattice.iniEquilibrium(superGeometry, 3, rho, u); sLattice.defineRhoU(superGeometry, 4, rho, u); sLattice.iniEquilibrium(superGeometry, 4, rho, u); sLattice.initialize(); clout << "Prepare coarse lattice ... OK" << std::endl; } void prepareFineLattice(UnitConverter const& converter, SuperLattice2D& sLattice, Dynamics& bulkDynamics, sOnLatticeBoundaryCondition2D& sBoundaryCondition, SuperGeometry2D& superGeometry) { OstreamManager clout(std::cout,"prepareLattice"); clout << "Prepare fine lattice ..." << std::endl; const T omega = converter.getLatticeRelaxationFrequency(); sLattice.defineDynamics(superGeometry, 0, &instances::getNoDynamics()); sLattice.defineDynamics(superGeometry, 1, &bulkDynamics); // bulk sLattice.defineDynamics(superGeometry, 2, &instances::getBounceBack()); 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(superGeometry, 1, rho, u); sLattice.iniEquilibrium(superGeometry, 1, rho, u); sLattice.defineRhoU(superGeometry, 2, rho, u); sLattice.iniEquilibrium(superGeometry, 2, rho, u); sLattice.initialize(); clout << "Prepare fine lattice ... OK" << std::endl; } void getResults(const std::string& prefix, SuperLattice2D& sLattice, UnitConverter const& converter, int iT, SuperGeometry2D& superGeometry, Timer& timer, bool hasConverged) { OstreamManager clout(std::cout,"getResults"); SuperVTMwriter2D vtmWriter(prefix + "poiseuille2d"); SuperLatticePhysVelocity2D velocity(sLattice, converter); SuperLatticePhysPressure2D pressure(sLattice, converter); SuperLatticeGeometry2D geometry( sLattice, superGeometry ); vtmWriter.addFunctor(geometry); vtmWriter.addFunctor(velocity); vtmWriter.addFunctor(pressure); const int statIter = converter.getLatticeTime(maxPhysT/10.); if (iT==0) { vtmWriter.createMasterFile(); } if (iT%100==0) { vtmWriter.write(iT); } if (iT%statIter==0 || hasConverged) { timer.update(iT); timer.printStep(); sLattice.getStatistics().print(iT,converter.getPhysTime(iT)); } } template class DESCRIPTOR> class FineCoupler; template class DESCRIPTOR> class CoarseCoupler; template class DESCRIPTOR> class Grid { private: std::unique_ptr> _converter; std::unique_ptr> _cuboids; std::unique_ptr> _balancer; std::unique_ptr> _geometry; std::unique_ptr> _lattice; std::vector>> _fineGrids; std::vector>> _fineCouplers; std::vector>> _coarseCouplers; public: static std::unique_ptr> make(IndicatorF2D& domainF, int resolution, T tau, int re) { return std::unique_ptr>( new Grid(domainF, resolution, tau, re) ); } Grid(IndicatorF2D& domainF, int resolution, T tau, int re): _converter(new UnitConverterFromResolutionAndRelaxationTime( resolution, // resolution: number of voxels per charPhysL tau, // latticeRelaxationTime: relaxation time, has to be greater than 0.5! T{1}, // charPhysLength: reference length of simulation geometry T{1}, // charPhysVelocity: maximal/highest expected velocity during simulation in __m / s__ T{1./re}, // physViscosity: physical kinematic viscosity in __m^2 / s__ T{1}, // physDensity: physical density in __kg / m^3__ T{1})), _cuboids(new CuboidGeometry2D( domainF, _converter->getConversionFactorLength(), 1)), _balancer(new HeuristicLoadBalancer( *_cuboids)), _geometry(new SuperGeometry2D( *_cuboids, *_balancer, 2)), _lattice(new SuperLattice2D( *_geometry)) { _converter->print(); } UnitConverter& getConverter() { return *_converter; } CuboidGeometry2D& getCuboidGeometry() { return *_cuboids; } LoadBalancer& getLoadBalancer() { return *_balancer; } SuperGeometry2D& getSuperGeometry() { return *_geometry; } SuperLattice2D& getSuperLattice() { return *_lattice; } T getScalingFactor() { return 4. - _converter->getLatticeRelaxationFrequency(); } T getInvScalingFactor() { return 1./getScalingFactor(); } void collideAndStream() { for ( auto& fineCoupler : _fineCouplers ) { fineCoupler->store(); } this->getSuperLattice().collideAndStream(); for ( auto& fineGrid : _fineGrids ) { fineGrid->getSuperLattice().collideAndStream(); } for ( auto& fineCoupler : _fineCouplers ) { fineCoupler->interpolate(); fineCoupler->couple(); } for ( auto& fineGrid : _fineGrids ) { fineGrid->getSuperLattice().collideAndStream(); } for ( auto& fineCoupler : _fineCouplers ) { fineCoupler->store(); fineCoupler->couple(); } for ( auto& coarseCoupler : _coarseCouplers ) { coarseCoupler->couple(); } } Grid* refine(Vector origin, Vector extend) { IndicatorCuboid2D fineCuboid(extend, origin); _fineGrids.emplace_back( new Grid( fineCuboid, 2*getConverter().getResolution(), 2.0*getConverter().getLatticeRelaxationTime() - 0.5, getConverter().getReynoldsNumber() )); Grid* const fineGrid = _fineGrids.back().get(); const T coarseDeltaX = getConverter().getPhysDeltaX(); _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})); _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})); return fineGrid; } }; template class DESCRIPTOR> void computeFeq(const Cell& cell, T fEq[DESCRIPTOR::q]) { T rho{}; T u[2] {}; cell.computeRhoU(rho, u); const T uSqr = u[0]*u[0] + u[1]*u[1]; for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { fEq[iPop] = lbHelpers::equilibrium(iPop, rho, u, uSqr); } } template class DESCRIPTOR> void computeFneq(const Cell& cell, T fNeq[DESCRIPTOR::q]) { T rho{}; T u[2] {}; cell.computeRhoU(rho, u); lbHelpers::computeFneq(cell, fNeq, rho, u); } T order4interpolation(T fm3, T fm1, T f1, T f3) { return 9./16. * (fm1 + f1) - 1./16. * (fm3 + f3); } T order3interpolation(T fm1, T f1, T f3) { return 3./8. * fm1 + 3./4. * f1 - 1./8. * f3; } T order2interpolation(T f0, T f1) { return 0.5 * (f0 + f1); } template class DESCRIPTOR> class Coupler { protected: Grid& _coarse; Grid& _fine; const int _coarseSize; const int _fineSize; const bool _vertical; Vector _physOrigin; Vector _coarseOrigin; Vector _fineOrigin; Vector getFineLatticeR(int y) const { if (_vertical) { return _fineOrigin + Vector {0, 0, y}; } else { return _fineOrigin + Vector {0, y, 0}; } } Vector getCoarseLatticeR(int y) const { if (_vertical) { return _coarseOrigin + Vector {0, 0, y}; } else { return _coarseOrigin + Vector {0, y, 0}; } } public: Coupler(Grid& coarse, Grid& fine, Vector origin, Vector extend): _coarse(coarse), _fine(fine), _coarseSize(floor(extend.norm() / coarse.getConverter().getPhysDeltaX() + 0.5)+1), _fineSize(2*_coarseSize-1), _vertical(util::nearZero(extend[0])) { OLB_ASSERT(util::nearZero(extend[0]) || util::nearZero(extend[1]), "Coupling is only implemented alongside unit vectors"); const auto& coarseGeometry = _coarse.getCuboidGeometry(); const auto& fineGeometry = _fine.getCuboidGeometry(); Vector tmpLatticeOrigin{}; coarseGeometry.getLatticeR(origin, tmpLatticeOrigin); _physOrigin = coarseGeometry.getPhysR(tmpLatticeOrigin.toStdVector()); coarseGeometry.getLatticeR(_physOrigin, _coarseOrigin); fineGeometry.getLatticeR(_physOrigin, _fineOrigin); } }; template class DESCRIPTOR> class FineCoupler : public Coupler { private: std::vector _c2f_rho; std::vector> _c2f_u; std::vector::q>> _c2f_fneq; public: FineCoupler(Grid& coarse, Grid& fine, Vector origin, Vector extend): Coupler(coarse, fine, origin, extend), _c2f_rho(this->_coarseSize), _c2f_u(this->_coarseSize, Vector(T{})), _c2f_fneq(this->_coarseSize, Vector::q>(T{})) { OstreamManager clout(std::cout,"C2F"); clout << "coarse origin: " << this->_coarseOrigin[0] << " " << this->_coarseOrigin[1] << " " << this->_coarseOrigin[2] << std::endl; clout << "fine origin: " << this->_fineOrigin[0] << " " << this->_fineOrigin[1] << " " << this->_fineOrigin[2] << std::endl; clout << "fine size: " << this->_fineSize << std::endl; } void store() { auto& coarseLattice = this->_coarse.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { const auto pos = this->getCoarseLatticeR(y); T rho{}; T u[2] {}; T fNeq[DESCRIPTOR::q] {}; coarseLattice.get(pos).computeRhoU(rho, u); computeFneq(coarseLattice.get(pos), fNeq); _c2f_rho[y] = rho; _c2f_u[y] = Vector(u); _c2f_fneq[y] = Vector::q>(fNeq); } } void interpolate() { auto& coarseLattice = this->_coarse.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { const auto coarsePos = this->getCoarseLatticeR(y); T rho{}; T u[2] {}; coarseLattice.get(coarsePos).computeRhoU(rho, u); _c2f_rho[y] = order2interpolation(rho, _c2f_rho[y]); _c2f_u[y][0] = order2interpolation(u[0], _c2f_u[y][0]); _c2f_u[y][1] = order2interpolation(u[1], _c2f_u[y][1]); T fNeq[DESCRIPTOR::q] {}; computeFneq(coarseLattice.get(coarsePos), fNeq); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { _c2f_fneq[y][iPop] = order2interpolation(fNeq[iPop], _c2f_fneq[y][iPop]); } } } void couple() { auto& coarseLattice = this->_coarse.getSuperLattice(); auto& fineLattice = this->_fine.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { const auto coarsePos = this->getCoarseLatticeR(y); const auto finePos = this->getFineLatticeR(2*y); T fEq[DESCRIPTOR::q] {}; computeFeq(coarseLattice.get(coarsePos), fEq); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { fineLattice.get(finePos)[iPop] = fEq[iPop] + this->_coarse.getScalingFactor() * _c2f_fneq[y][iPop]; } } for (int y=1; y < this->_coarseSize-2; ++y) { const T rho = order4interpolation( _c2f_rho[y-1], _c2f_rho[y], _c2f_rho[y+1], _c2f_rho[y+2] ); T u[2] {}; u[0] = order4interpolation( _c2f_u[y-1][0], _c2f_u[y][0], _c2f_u[y+1][0], _c2f_u[y+2][0] ); u[1] = order4interpolation( _c2f_u[y-1][1], _c2f_u[y][1], _c2f_u[y+1][1], _c2f_u[y+2][1] ); const T uSqr = u[0]*u[0] + u[1]*u[1]; const auto finePos = this->getFineLatticeR(1+2*y); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { const T fneq = order4interpolation( _c2f_fneq[y-1][iPop], _c2f_fneq[y][iPop], _c2f_fneq[y+1][iPop], _c2f_fneq[y+2][iPop] ); fineLattice.get(finePos)[iPop] = lbHelpers::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; } } { const T rho = order3interpolation( _c2f_rho[0], _c2f_rho[1], _c2f_rho[2] ); T u[2] {}; u[0] = order3interpolation( _c2f_u[0][0], _c2f_u[1][0], _c2f_u[2][0] ); u[1] = order3interpolation( _c2f_u[0][1], _c2f_u[1][1], _c2f_u[2][1] ); const T uSqr = u[0]*u[0] + u[1]*u[1]; const auto finePos = this->getFineLatticeR(1); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { const T fneq = order3interpolation( _c2f_fneq[0][iPop], _c2f_fneq[1][iPop], _c2f_fneq[2][iPop] ); fineLattice.get(finePos)[iPop] = lbHelpers::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; } } { const T rho = order3interpolation( _c2f_rho[this->_coarseSize-1], _c2f_rho[this->_coarseSize-2], _c2f_rho[this->_coarseSize-3] ); T u[2] {}; u[0] = order3interpolation( _c2f_u[this->_coarseSize-1][0], _c2f_u[this->_coarseSize-2][0], _c2f_u[this->_coarseSize-3][0] ); u[1] = order3interpolation( _c2f_u[this->_coarseSize-1][1], _c2f_u[this->_coarseSize-2][1], _c2f_u[this->_coarseSize-3][1] ); const T uSqr = u[0]*u[0] + u[1]*u[1]; const auto finePos = this->getFineLatticeR(this->_fineSize-2); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { const T fneq = order3interpolation( _c2f_fneq[this->_coarseSize-1][iPop], _c2f_fneq[this->_coarseSize-2][iPop], _c2f_fneq[this->_coarseSize-3][iPop] ); fineLattice.get(finePos)[iPop] = lbHelpers::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; } } } }; template class DESCRIPTOR> void computeRestrictedFneq(const SuperLattice2D& lattice, Vector pos, T restrictedFneq[DESCRIPTOR::q]) { for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { T fNeq[DESCRIPTOR::q] {}; computeFneq(lattice.get(pos[0], pos[1] + DESCRIPTOR::c[iPop][0], pos[2] + DESCRIPTOR::c[iPop][1]), fNeq); for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) { restrictedFneq[jPop] += fNeq[jPop]; } } for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { restrictedFneq[iPop] /= DESCRIPTOR::q; } } template class DESCRIPTOR> class CoarseCoupler : public Coupler { public: CoarseCoupler(Grid& coarse, Grid& fine, Vector origin, Vector extend): Coupler(coarse, fine, origin, extend) { OstreamManager clout(std::cout,"F2C"); clout << "coarse origin: " << this->_coarseOrigin[0] << " " << this->_coarseOrigin[1] << " " << this->_coarseOrigin[2] << std::endl; clout << "fine origin: " << this->_fineOrigin[0] << " " << this->_fineOrigin[1] << " " << this->_fineOrigin[2] << std::endl; clout << "coarse size: " << this->_coarseSize << std::endl; } void couple() { auto& fineLattice = this->_fine.getSuperLattice(); auto& coarseLattice = this->_coarse.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { const auto finePos = this->getFineLatticeR(2*y); const auto coarsePos = this->getCoarseLatticeR(y); T fEq[DESCRIPTOR::q] {}; computeFeq(fineLattice.get(finePos), fEq); T fNeq[DESCRIPTOR::q] {}; computeRestrictedFneq(fineLattice, finePos, fNeq); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { coarseLattice.get(coarsePos)[iPop] = fEq[iPop] + this->_coarse.getInvScalingFactor() * fNeq[iPop]; } } } }; int main(int argc, char* argv[]) { olbInit(&argc, &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); Vector fineOrigin { 0.25 * lx, 0.2 }; Vector fineExtend { 0.6 * lx, 0.6 }; auto coarseGrid = Grid::make(coarseCuboid, N, 0.8, Re); auto fineGrid = coarseGrid->refine(fineOrigin, fineExtend); prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry()); prepareGeometry(fineGrid->getConverter(), fineGrid->getSuperGeometry()); 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); Dynamics* coarseBulkDynamics; coarseBulkDynamics = new BGKdynamics( coarseGrid->getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta()); sOnLatticeBoundaryCondition2D coarseSBoundaryCondition(coarseGrid->getSuperLattice()); createLocalBoundaryCondition2D(coarseSBoundaryCondition); prepareCoarseLattice( coarseGrid->getConverter(), coarseGrid->getSuperLattice(), *coarseBulkDynamics, coarseSBoundaryCondition, coarseGrid->getSuperGeometry()); Dynamics* fineBulkDynamics; fineBulkDynamics = new BGKdynamics( fineGrid->getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta()); sOnLatticeBoundaryCondition2D fineSBoundaryCondition(fineGrid->getSuperLattice()); createLocalBoundaryCondition2D(fineSBoundaryCondition); prepareFineLattice( fineGrid->getConverter(), fineGrid->getSuperLattice(), *fineBulkDynamics, fineSBoundaryCondition, fineGrid->getSuperGeometry()); clout << "starting simulation..." << endl; Timer timer( coarseGrid->getConverter().getLatticeTime(maxPhysT), coarseGrid->getSuperGeometry().getStatistics().getNvoxel()); util::ValueTracer converge( fineGrid->getConverter().getLatticeTime(physInterval), residuum); timer.start(); for (int iT = 0; iT < coarseGrid->getConverter().getLatticeTime(maxPhysT); ++iT) { if (converge.hasConverged()) { clout << "Simulation converged." << endl; break; } coarseGrid->collideAndStream(); getResults( "coarse_", coarseGrid->getSuperLattice(), coarseGrid->getConverter(), iT, coarseGrid->getSuperGeometry(), timer, converge.hasConverged()); getResults( "fine_", fineGrid->getSuperLattice(), fineGrid->getConverter(), iT, fineGrid->getSuperGeometry(), timer, converge.hasConverged()); converge.takeValue(fineGrid->getSuperLattice().getStatistics().getAverageEnergy(), true); } timer.stop(); timer.printSummary(); }