From f72650254067bfee063c184dedcce41fdfa32931 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 17 Oct 2018 20:33:40 +0200 Subject: Print avg. error of Poiseuille outflow velocity --- poiseuille.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/poiseuille.cc b/poiseuille.cc index e0ee4cf..b6c9616 100644 --- a/poiseuille.cc +++ b/poiseuille.cc @@ -9,7 +9,7 @@ constexpr std::size_t dimY = 20; constexpr std::size_t dimX = 5*dimY; constexpr double uInflow = 0.02; -constexpr double reynolds = 10; +constexpr double reynolds = 100; constexpr double tau = 3. * uInflow * (dimX-1) / reynolds + 0.5; constexpr double omega = 1. / tau; @@ -72,23 +72,33 @@ void computeLbmStep() { } } +double error(std::size_t x) { + double acc = 0.0; + + for ( std::size_t y = 1; y < dimY-1; ++y ) { + acc += std::abs(poiseuille(y) - fluid.velocity(x,y)[0]); + } + + return acc / (dimY-2); +} + int main() { init(); + std::cout << "dim: " << dimX << "x" << dimY << std::endl; std::cout << "Re: " << reynolds << std::endl; std::cout << "uInflow: " << uInflow << std::endl; std::cout << "tau: " << tau << std::endl; std::cout << "omega: " << omega << std::endl; + std::cout << std::endl; + for ( std::size_t t = 0; t <= 10000; ++t ) { computeLbmStep(); - if ( t % 100 == 0 ) { - std::cout << "."; - std::cout.flush(); + if ( t % 1000 == 0 ) { + std::cout << error(dimX-1) << std::endl; fluid.writeAsVTK("result/data_t" + std::to_string(t) + ".vtk"); } } - - std::cout << std::endl; } -- cgit v1.2.3