aboutsummaryrefslogtreecommitdiff
path: root/src/box_obstacle.cc
blob: 9cb6ad05f72e60aa089b42ae02760b011c8fc234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "box_obstacle.h"

#include "boundary_conditions.h"

BoxObstacle::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 BoxObstacle::isInside(std::size_t x, std::size_t y) const {
	return x > lower_x_
		&& x < upper_x_
		&& y > lower_y_
		&& y < upper_y_;
}

void BoxObstacle::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});
}