diff options
author | Adrian Kummerlaender | 2018-08-02 21:07:30 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2018-08-02 21:07:30 +0200 |
commit | c4771584ae3b0b4c34fbef20f13c6fc7d80cd046 (patch) | |
tree | 1b376a43b6798e17ef63ac342643c27c7f08448d /src/box_obstacle.h | |
parent | 424879d10c29d550e258f91873ae7c2681e5e853 (diff) | |
download | boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar.gz boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar.bz2 boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar.lz boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar.xz boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.tar.zst boltzbub-c4771584ae3b0b4c34fbef20f13c6fc7d80cd046.zip |
Bring in some more structure
Diffstat (limited to 'src/box_obstacle.h')
-rw-r--r-- | src/box_obstacle.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/box_obstacle.h b/src/box_obstacle.h new file mode 100644 index 0000000..46660a7 --- /dev/null +++ b/src/box_obstacle.h @@ -0,0 +1,36 @@ +#pragma once + +#include "data_cell_buffer.h" +#include "boundary_conditions.h" + +struct BoxObstacle { + const std::size_t lower_x_; + const std::size_t lower_y_; + const std::size_t upper_x_; + const std::size_t upper_y_; + + BoxObstacle(std::size_t lX, std::size_t lY, std::size_t uX, std::size_t uY): + lower_x_(lX), lower_y_(lY), upper_x_(uX), upper_y_(uY) { } + + bool isInside(std::size_t x, std::size_t y) const { + return x > lower_x_ + && x < upper_x_ + && y > lower_y_ + && y < upper_y_; + } + + void applyBoundary(DataCellBuffer& pop) const { + for ( std::size_t x = lower_x_+1; x < upper_x_; ++x ) { + computeWallCell(pop, {x, lower_y_}, { 0,-1}); + computeWallCell(pop, {x, upper_y_}, { 0, 1}); + } + for ( std::size_t y = lower_y_+1; y < upper_y_; ++y ) { + computeWallCell(pop, {lower_x_, y}, {-1, 0}); + computeWallCell(pop, {upper_x_, y}, { 1, 0}); + } + computeWallCell(pop, {lower_x_, lower_y_}, {-1,-1}); + computeWallCell(pop, {upper_x_, lower_y_}, { 1,-1}); + computeWallCell(pop, {upper_x_, upper_y_}, { 1, 1}); + computeWallCell(pop, {lower_x_, upper_y_}, {-1, 1}); + } +}; |