diff --git a/include/tug/Boundary.hpp b/include/tug/Boundary.hpp index 6e94537..3a2df00 100644 --- a/include/tug/Boundary.hpp +++ b/include/tug/Boundary.hpp @@ -1,4 +1,5 @@ #include +#include "Grid.hpp" using namespace Eigen; @@ -20,24 +21,10 @@ class Boundary { /** * @brief Construct a new Boundary object * - * @param dim + * @param grid + * @param type */ - Boundary(int dim); - - /** - * @brief Construct a new Boundary object - * - * @param dim - * @param type - */ - Boundary(int dim, BC_TYPE type); - - /** - * @brief Set the Boundary Condition Type object - * - * @param type - */ - void setBoundaryConditionType(BC_TYPE type); + Boundary(Grid grid, BC_TYPE type); /** * @brief Get the Boundary Condition Type object @@ -65,7 +52,7 @@ class Boundary { private: - int dim; + Grid grid; BC_TYPE type; VectorXd left, right, top, bottom; }; diff --git a/include/tug/Grid.hpp b/include/tug/Grid.hpp index 9534357..35ccb2e 100644 --- a/include/tug/Grid.hpp +++ b/include/tug/Grid.hpp @@ -8,17 +8,17 @@ class Grid { /** * @brief Construct a new Grid object * - * @param n + * @param col */ - Grid(int n); + Grid(int col); /** * @brief Construct a new Grid object * - * @param n - * @param m + * @param row + * @param col */ - Grid(int n, int m); + Grid(int row, int col); /** * @brief Set the Concentrations object @@ -49,12 +49,18 @@ class Grid { */ void setAlpha(Matrix2d alpha_x, Matrix2d alpha_y); + auto getDim(); + + auto getRow(); + + auto getCol(); + private: int dim; - int n; - int m; + int row; + int col; Matrix2d concentrations; Matrix2d alpha_x; Matrix2d alpha_y; diff --git a/src/Boundary.cpp b/src/Boundary.cpp index e69de29..865a60f 100644 --- a/src/Boundary.cpp +++ b/src/Boundary.cpp @@ -0,0 +1,20 @@ +#include +#include + +using namespace std; + +Boundary::Boundary(Grid grid, BC_TYPE type) { + this->type = type; + + if (type == BC_TYPE_CONSTANT) { + if (grid.getDim() == 1) { + 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); + } else { + throw invalid_argument("Dimension must be 1 or 2!"); + } + } +} \ No newline at end of file diff --git a/src/Grid.cpp b/src/Grid.cpp index e69de29..9b60a8d 100644 --- a/src/Grid.cpp +++ b/src/Grid.cpp @@ -0,0 +1,48 @@ +#include + +Grid::Grid(int col) { + this->col = col; + + this->dim = 1; + this->concentrations = Matrix2d::Constant(1, col, 1); + this->alpha_x = Matrix2d::Constant(1, col, 1); +} + +Grid::Grid(int row, int col) { + this->row = row; + this->col = col; + + this->dim = 2; + this->concentrations = Matrix2d::Constant(row, col, 1); + this->alpha_x = Matrix2d::Constant(row, col, 1); + this->alpha_y = Matrix2d::Constant(row, col, 1); +} + +void Grid::setConcentrations(Matrix2d concentrations) { + this->concentrations = concentrations; +} + +auto Grid::getConcentrations() { + return this->concentrations; +} + +void Grid::setAlpha(Matrix2d alpha) { + this->alpha_x = alpha; +} + +void Grid::setAlpha(Matrix2d alpha_x, Matrix2d alpha_y) { + this->alpha_x = alpha_x; + this->alpha_y = alpha_y; +} + +auto Grid::getDim() { + return dim; +} + +auto Grid::getRow() { + return row; +} + +auto Grid::getCol() { + return col; +} \ No newline at end of file