diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index fcebc92..251eb59 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -16,37 +16,32 @@ #include #include #include +#include -const BCSide BTCSDiffusion::LEFT = 0; -const BCSide BTCSDiffusion::RIGHT = 1; +const int BTCSDiffusion::BC_NEUMANN = 0; +const int BTCSDiffusion::BC_DIRICHLET = 1; BTCSDiffusion::BTCSDiffusion(int x) : dim_x(x) { this->grid_dim = 1; // per default use Neumann condition with gradient of 0 at the end of the grid - this->bc.resize(2, -1); + this->bc.resize(2, std::tuple(0,0.)); } BTCSDiffusion::BTCSDiffusion(int x, int y) : dim_x(x), dim_y(y) { - this->grid_dim = 2; + // this->grid_dim = 2; - this->bc.reserve(x * 2 + y * 2); - // per default use Neumann condition with gradient of 0 at the end of the grid - std::fill(this->bc.begin(), this->bc.end(), -1); + // this->bc.reserve(x * 2 + y * 2); + // // per default use Neumann condition with gradient of 0 at the end of the grid + // std::fill(this->bc.begin(), this->bc.end(), -1); } BTCSDiffusion::BTCSDiffusion(int x, int y, int z) : dim_x(x), dim_y(y), dim_z(z) { - this->grid_dim = 3; + // this->grid_dim = 3; // TODO: reserve memory for boundary conditions } -void BTCSDiffusion::setBoundaryCondition(std::vector input, - BCSide side) { - if (this->grid_dim == 1) { - bc[side] = input[0]; - } -} void BTCSDiffusion::simulate(std::vector &c, std::vector &alpha, double timestep) { // calculate dx diff --git a/src/BTCSDiffusion.hpp b/src/BTCSDiffusion.hpp index cadc1e7..8d0bc3e 100644 --- a/src/BTCSDiffusion.hpp +++ b/src/BTCSDiffusion.hpp @@ -2,19 +2,17 @@ #define BTCSDIFFUSION_H_ #include +#include #include -/*! - * Type defining the side of given boundary condition. - */ -typedef int BCSide; - /*! * Datatype to fill the sparse matrix which is used to solve the equation * system. */ typedef Eigen::Triplet T; +typedef std::vector> boundary_condition; + /*! * Class implementing a solution for a 1/2/3D diffusion equation using backward * euler. @@ -22,15 +20,9 @@ typedef Eigen::Triplet T; class BTCSDiffusion { public: - /*! - * Set left boundary condition. - */ - static const BCSide LEFT; - /*! - * Set right boundary condition. - */ - static const BCSide RIGHT; + static const int BC_NEUMANN; + static const int BC_DIRICHLET; /*! * Create 1D-diffusion module. @@ -56,17 +48,6 @@ public: */ BTCSDiffusion(int x, int y, int z); - /*! - * Sets internal boundary condition at the end of the grid/ghost zones. - * Currently only implemented for 1D diffusion. - * - * @param input Vector containing all the values to initialize the ghost - * zones. - * @param side Sets the side of the boundary condition. See BCSide for more - * information. - */ - void setBoundaryCondition(std::vector input, BCSide side); - /*! * With given ghost zones simulate diffusion. Only 1D allowed at this moment. * @@ -79,7 +60,9 @@ public: double timestep); private: - std::vector bc; + + boundary_condition bc; + int grid_dim; int dim_x; int dim_y;