aboutsummaryrefslogtreecommitdiff
path: root/cavity2d.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-10-11 21:12:22 +0200
committerAdrian Kummerlaender2018-10-11 21:12:22 +0200
commit4e8921427d4dd6717ff4ef262e7c04bbbd21a906 (patch)
tree25b6ca1f98c2c9f483739a881ce28366980acaa5 /cavity2d.cc
parent52c2bf1526abbbf17f5de44310137f77a60f5e35 (diff)
downloadboltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar.gz
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar.bz2
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar.lz
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar.xz
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.tar.zst
boltzbub-4e8921427d4dd6717ff4ef262e7c04bbbd21a906.zip
Rename examples
Diffstat (limited to 'cavity2d.cc')
-rw-r--r--cavity2d.cc90
1 files changed, 0 insertions, 90 deletions
diff --git a/cavity2d.cc b/cavity2d.cc
deleted file mode 100644
index ca4b030..0000000
--- a/cavity2d.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <iostream>
-#include <vector>
-#include <string>
-#include <algorithm>
-
-#include "lbm.h"
-#include "boundary_conditions.h"
-
-constexpr std::size_t dimX = 100;
-constexpr std::size_t dimY = dimX;
-
-constexpr double uLid = 0.4;
-constexpr double reynolds = 1000;
-
-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;
- std::cout << "omega: " << omega << std::endl;
-
- for ( std::size_t t = 0; t <= 10000; ++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;
-}