replace names of boundary condition variables

This commit is contained in:
Max Luebke 2022-01-14 12:36:39 +01:00
parent 89a01d3e13
commit e8dae917d5
2 changed files with 16 additions and 9 deletions

View File

@ -8,15 +8,16 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
const int BTCSDiffusion::BC_NEUMANN = 0; const int BTCSDiffusion::BC_CONSTANT = 0;
const int BTCSDiffusion::BC_DIRICHLET = 1; const int BTCSDiffusion::BC_CLOSED = 1;
const int BTCSDiffusion::BC_FLUX = 2;
BTCSDiffusion::BTCSDiffusion(int x) : n_x(x) { BTCSDiffusion::BTCSDiffusion(int x) : n_x(x) {
this->grid_dim = 1; this->grid_dim = 1;
this->dx = 1. / (x - 1); this->dx = 1. / (x - 1);
// per default use Neumann condition with gradient of 0 at the end of the grid // per default use Neumann condition with gradient of 0 at the end of the grid
this->bc.resize(2, std::tuple<bctype, double>(BTCSDiffusion::BC_NEUMANN, 0.)); this->bc.resize(2, std::tuple<bctype, double>(BTCSDiffusion::BC_CONSTANT, 0.));
} }
BTCSDiffusion::BTCSDiffusion(int x, int y) : n_x(x), n_y(y) { BTCSDiffusion::BTCSDiffusion(int x, int y) : n_x(x), n_y(y) {
@ -109,10 +110,10 @@ double BTCSDiffusion::getBCFromTuple(int index, double neighbor_c,
double val = -1; double val = -1;
int type = std::get<0>(bc[index]); int type = std::get<0>(bc[index]);
if (type == BTCSDiffusion::BC_NEUMANN) { if (type == BTCSDiffusion::BC_CONSTANT) {
val = neighbor_c + (this->time_step / (dx * dx)) * neighbor_alpha * val = neighbor_c + (this->time_step / (dx * dx)) * neighbor_alpha *
std::get<1>(bc[index]); std::get<1>(bc[index]);
} else if (type == BTCSDiffusion::BC_DIRICHLET) { } else if (type == BTCSDiffusion::BC_CLOSED) {
val = std::get<1>(bc[index]); val = std::get<1>(bc[index]);
} else { } else {
// TODO: implement error handling here. Type was set to wrong value. // TODO: implement error handling here. Type was set to wrong value.

View File

@ -35,13 +35,19 @@ class BTCSDiffusion {
public: public:
/*! /*!
* Defines a Neumann boundary condition. * Defines a constant/Dirichlet boundary condition.
*/ */
static const int BC_NEUMANN; static const int BC_CONSTANT;
/*! /*!
* Defines a Dirichlet boundary condition. * Defines a closed/Neumann boundary condition.
*/ */
static const int BC_DIRICHLET; static const int BC_CLOSED;
/*!
* Defines a flux/Cauchy boundary condition.
*/
static const int BC_FLUX;
/*! /*!
* Create 1D-diffusion module. * Create 1D-diffusion module.