From 1bf577b1c5e606ac2c0553857297ce8c0c04ccb7 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 26 Oct 2019 15:01:39 +0200 Subject: Support passing additional string arguments to the generator --- boltzgen/kernel/template/basic.cpp.mako | 36 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'boltzgen/kernel/template') diff --git a/boltzgen/kernel/template/basic.cpp.mako b/boltzgen/kernel/template/basic.cpp.mako index bee25a7..3e16d2e 100644 --- a/boltzgen/kernel/template/basic.cpp.mako +++ b/boltzgen/kernel/template/basic.cpp.mako @@ -67,49 +67,40 @@ void collect_moments(const ${float_type}* f, % endfor } +% if 'test_example' in extras: void test(std::size_t nStep) { auto f_a = std::make_unique<${float_type}[]>(${geometry.volume*descriptor.q + 2*layout.padding()}); auto f_b = std::make_unique<${float_type}[]>(${geometry.volume*descriptor.q + 2*layout.padding()}); - auto material = std::make_unique(${geometry.volume}); // buffers are padded by maximum neighbor overreach to prevent invalid memory access ${float_type}* f_prev = f_a.get() + ${layout.padding()}; ${float_type}* f_next = f_b.get() + ${layout.padding()}; + std::vector bulk; + std::vector bc; + for (int iX = 0; iX < ${geometry.size_x}; ++iX) { for (int iY = 0; iY < ${geometry.size_y}; ++iY) { % if descriptor.d == 2: if (iX == 0 || iY == 0 || iX == ${geometry.size_x-1} || iY == ${geometry.size_y-1}) { - material[iX*${geometry.size_y} + iY] = 0; + bc.emplace_back(iX*${geometry.size_y} + iY); } else { - material[iX*${geometry.size_y} + iY] = 1; + bulk.emplace_back(iX*${geometry.size_y} + iY); } % elif descriptor.d == 3: for (int iZ = 0; iZ < ${geometry.size_z}; ++iZ) { if (iX == 0 || iY == 0 || iZ == 0 || iX == ${geometry.size_x-1} || iY == ${geometry.size_y-1} || iZ == ${geometry.size_z-1}) { - material[iX*${geometry.size_y*geometry.size_z} + iY*${geometry.size_z} + iZ] = 0; + bc.emplace_back(iX*${geometry.size_y*geometry.size_z} + iY*${geometry.size_z} + iZ); } else { - material[iX*${geometry.size_y*geometry.size_z} + iY*${geometry.size_z} + iZ] = 1; + bulk.emplace_back(iX*${geometry.size_y*geometry.size_z} + iY*${geometry.size_z} + iZ); } } % endif } } - std::vector bulk; - std::vector bc; - - for (std::size_t iCell = 0; iCell < ${geometry.volume}; ++iCell) { - if (material[iCell] == 0) { - bc.emplace_back(iCell); - } - if (material[iCell] == 1) { - bulk.emplace_back(iCell); - } - } - for (std::size_t iCell = 0; iCell < ${geometry.volume}; ++iCell) { equilibrilize(f_prev, f_next, iCell); } @@ -136,14 +127,17 @@ void test(std::size_t nStep) auto duration = std::chrono::duration_cast>( std::chrono::high_resolution_clock::now() - start); - std::cout << "MLUPS: " << nStep*${geometry.volume}/(1e6*duration.count()) << std::endl; - // calculate average rho as a basic quality check ${float_type} rho_sum = 0.0; - for (std::size_t i = 0; i < ${geometry.volume*descriptor.q}; ++i) { rho_sum += f_next[i]; } - std::cout << "avg rho: " << rho_sum/${geometry.volume} << std::endl; + std::cout << "#bulk : " << bulk.size() << std::endl; + std::cout << "#bc : " << bc.size() << std::endl; + std::cout << "#steps : " << nStep << std::endl; + std::cout << std::endl; + std::cout << "MLUPS : " << nStep*${geometry.volume}/(1e6*duration.count()) << std::endl; + std::cout << "avg rho : " << rho_sum/${geometry.volume} << std::endl; } +% endif -- cgit v1.2.3