aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-10-10 22:15:48 +0200
committerAdrian Kummerlaender2018-10-10 22:15:48 +0200
commitb4a61621fc1d2d6350c8f700ee3196950e476000 (patch)
tree77887ee774e2d204a6d7820d14ef86953859119b
parent996916a493fb55437208e50a3a9fda7c04423747 (diff)
downloadboltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar.gz
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar.bz2
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar.lz
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar.xz
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.tar.zst
boltzbub-b4a61621fc1d2d6350c8f700ee3196950e476000.zip
Separate examples
-rw-r--r--CMakeLists.txt21
-rw-r--r--cavity2d.cc89
-rw-r--r--cavity2d_with_obstacles.cc (renamed from boltz.cc)0
3 files changed, 105 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8818966..e5cbd03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,11 +10,22 @@ include_directories(
src/
)
+set(
+ BASE
+ src/lbm.cc
+ src/fluid_buffer.cc
+ src/boundary_conditions.cc
+)
+
+add_executable(
+ cavity2d
+ cavity2d.cc
+ ${BASE}
+)
+
add_executable(
- boltz
- boltz.cc
- src/lbm.cc
- src/fluid_buffer.cc
- src/boundary_conditions.cc
+ cavity2d_with_obstacles
+ cavity2d_with_obstacles.cc
+ ${BASE}
src/box_obstacle.cc
)
diff --git a/cavity2d.cc b/cavity2d.cc
new file mode 100644
index 0000000..0006252
--- /dev/null
+++ b/cavity2d.cc
@@ -0,0 +1,89 @@
+#include <iostream>
+#include <vector>
+#include <string>
+#include <algorithm>
+
+#include "lbm.h"
+#include "boundary_conditions.h"
+
+constexpr std::size_t dimX = 64;
+constexpr std::size_t dimY = dimX;
+
+constexpr double uLid = 0.1;
+constexpr double reynolds = 100;
+
+constexpr double tau = 3 * uLid * (dimX-1) / reynolds + 0.5;
+constexpr double omega = 1. / tau;
+
+DataCellBuffer pop(dimX, dimY);
+FluidBuffer fluid(dimX, dimY);
+
+void init() {
+ for ( std::size_t x = 0; x < dimX; ++x ) {
+ for ( std::size_t y = 0; y < dimY; ++y ) {
+ fluid.density(x,y) = 1.0;
+ fluid.velocity(x,y) = { 0.0, 0.0 };
+
+ static_cast<Cell&>(pop.curr(x,y)).equilibrize(
+ fluid.density(x,y), fluid.velocity(x,y));
+ static_cast<Cell&>(pop.prev(x,y)).equilibrize(
+ fluid.density(x,y), fluid.velocity(x,y));
+ }
+ }
+}
+
+void computeLbmStep() {
+ pop.swap();
+
+ for ( std::size_t x = 0; x < dimX; ++x ) {
+ for ( std::size_t y = 0; y < dimY; ++y ) {
+ streamFluidCell(pop, x, y);
+ }
+ }
+
+ // straight wall cell bounce back
+ for ( std::size_t x = 0; x < dimX; ++x ) {
+ computeZouHeVelocityWallCell(pop, {x, dimY-1}, { 0,-1}, uLid);
+ }
+ for ( std::size_t x = 1; x < dimX-1; ++x ) {
+ computeWallCell(pop, {x, 0}, { 0, 1});
+ }
+ for ( std::size_t y = 1; y < dimY-1; ++y ) {
+ computeWallCell(pop, {0, y}, { 1, 0});
+ computeWallCell(pop, {dimX-1, y}, {-1, 0});
+ }
+
+ // edge wall cell bounce back
+ computeWallCell(pop, {0, 0 }, { 1, 1});
+ computeWallCell(pop, {dimX-1, 0 }, {-1, 1});
+
+ for ( std::size_t x = 0; x < dimX; ++x ) {
+ for ( std::size_t y = 0; y < dimY; ++y ) {
+ Cell& cell = static_cast<Cell&>(pop.curr(x,y));
+ fluid.density(x,y) = cell.sum();
+ fluid.velocity(x,y) = cell.velocity(fluid.density(x,y));
+
+ collideFluidCell(omega, pop, fluid, x, y);
+ }
+ }
+}
+
+int main() {
+ init();
+
+ std::cout << "Re: " << reynolds << std::endl;
+ std::cout << "uLid: " << uLid << std::endl;
+ std::cout << "tau: " << tau << std::endl;
+
+ for ( std::size_t t = 0; t <= 6000; ++t ) {
+ computeLbmStep();
+
+ if ( t % 100 == 0 ) {
+ std::cout << ".";
+ std::cout.flush();
+ fluid.writeAsVTK("result/data_t" + std::to_string(t) + ".vtk");
+ }
+ }
+
+ std::cout << std::endl;
+}
diff --git a/boltz.cc b/cavity2d_with_obstacles.cc
index 092814e..092814e 100644
--- a/boltz.cc
+++ b/cavity2d_with_obstacles.cc