diff --git a/include/tug/Boundary.hpp b/include/tug/Boundary.hpp index 4989ba7..fb59f47 100644 --- a/include/tug/Boundary.hpp +++ b/include/tug/Boundary.hpp @@ -39,7 +39,7 @@ class Boundary { * @param side * @param values */ - void setBoundaryConditionValue(BC_SIDE side, VectorXd values); + void setBoundaryConditionValue(BC_SIDE side, VectorXd &values); /** * @brief Get the Boundary Condition Value object @@ -51,7 +51,6 @@ class Boundary { private: - Grid grid; BC_TYPE type; VectorXd left, right, top, bottom; diff --git a/include/tug/Grid.hpp b/include/tug/Grid.hpp index 6af953c..7736b73 100644 --- a/include/tug/Grid.hpp +++ b/include/tug/Grid.hpp @@ -51,9 +51,9 @@ class Grid { int getDim(); - auto getRow(); + int getRow(); - auto getCol(); + int getCol(); private: diff --git a/src/Boundary.cpp b/src/Boundary.cpp index 150b9f2..4156eb5 100644 --- a/src/Boundary.cpp +++ b/src/Boundary.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -11,10 +12,55 @@ Boundary::Boundary(Grid &grid, BC_TYPE type) : grid(grid) { this->left = VectorXd::Constant(1, 1, 1); this->right = VectorXd::Constant(1, 1, 1); } else if (grid.getDim() == 2) { - this->left = VectorXd::Constant(1, 1, 1); - this->right = VectorXd::Constant(1, 1, 1); + this->left = VectorXd::Constant(grid.getRow(), 1, 1); + this->right = VectorXd::Constant(grid.getRow(), 1, 1); + this->top = VectorXd::Constant(1, grid.getCol(), 1); + this->bottom = VectorXd::Constant(1, grid.getCol(), 1); } else { throw invalid_argument("Dimension must be 1 or 2!"); } + } +} + +auto Boundary::getBoundaryConditionType() { + return this->type; +} + +void Boundary::setBoundaryConditionValue(BC_SIDE side, VectorXd &values) { + if (type != BC_TYPE_CONSTANT) { + // TODO check if correct way for handling warning + cerr << "Values will not be used, wrong BC_TYPE!"; + } + + switch (side) { + case BC_SIDE_LEFT: + this->left = values; + break; + case BC_SIDE_RIGHT: + this->right = values; + break; + case BC_SIDE_TOP: + this->top = values; + break; + case BC_SIDE_BOTTOM: + this->bottom = values; + break; + default: + throw invalid_argument("Invalid side given!"); + } +} + +auto Boundary::getBoundaryConditionValue(BC_SIDE side) { + switch (side) { + case BC_SIDE_LEFT: + return this->left; + case BC_SIDE_RIGHT: + return this->right; + case BC_SIDE_TOP: + return this->top; + case BC_SIDE_BOTTOM: + return this->bottom; + default: + throw invalid_argument("Invalid side given!"); } } \ No newline at end of file diff --git a/src/Grid.cpp b/src/Grid.cpp index 4e92f01..65fe6cc 100644 --- a/src/Grid.cpp +++ b/src/Grid.cpp @@ -39,10 +39,10 @@ int Grid::getDim() { return dim; } -auto Grid::getRow() { +int Grid::getRow() { return row; } -auto Grid::getCol() { +int Grid::getCol() { return col; } \ No newline at end of file