mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
Change boundary_condition to struct instead of tuple
This commit is contained in:
parent
c3d82afed4
commit
e675381683
@ -45,10 +45,11 @@ void BTCSDiffusion::updateInternals() {
|
||||
|
||||
switch (grid_dim) {
|
||||
case 1:
|
||||
bc.resize(2, std::tuple<bctype, double>(BTCSDiffusion::BC_CLOSED, 0.));
|
||||
bc.resize(2, {BTCSDiffusion::BC_CLOSED, 0});
|
||||
break;
|
||||
case 2:
|
||||
bc.resize(2 * grid_cells[0] + 2 * grid_cells[1], std::tuple<bctype, double>(BTCSDiffusion::BC_CLOSED, 0.));
|
||||
bc.resize(2 * grid_cells[0] + 2 * grid_cells[1],
|
||||
{BTCSDiffusion::BC_CLOSED, 0});
|
||||
break;
|
||||
case 3:
|
||||
// TODO
|
||||
@ -154,14 +155,15 @@ void BTCSDiffusion::simulate(std::vector<double> &c,
|
||||
double BTCSDiffusion::getBCFromTuple(int index, double neighbor_c,
|
||||
double neighbor_alpha) {
|
||||
double val = -1;
|
||||
int type = std::get<0>(bc[index]);
|
||||
int type = bc[index].type;
|
||||
|
||||
if (type == BTCSDiffusion::BC_CLOSED) {
|
||||
val = neighbor_c;
|
||||
// val = neighbor_c + (this->time_step / (this->deltas[0] * this->deltas[0])) *
|
||||
// val = neighbor_c + (this->time_step / (this->deltas[0] *
|
||||
// this->deltas[0])) *
|
||||
// neighbor_alpha * std::get<1>(bc[index]);
|
||||
} else if (type == BTCSDiffusion::BC_CONSTANT){
|
||||
val = std::get<1>(bc[index]);
|
||||
} else if (type == BTCSDiffusion::BC_CONSTANT) {
|
||||
val = bc[index].value;
|
||||
} else {
|
||||
// TODO: implement error handling here. Type was set to wrong value.
|
||||
}
|
||||
@ -170,6 +172,10 @@ double BTCSDiffusion::getBCFromTuple(int index, double neighbor_c,
|
||||
}
|
||||
|
||||
void BTCSDiffusion::setBoundaryCondition(int index, double val, bctype type) {
|
||||
std::get<0>(bc[index]) = type;
|
||||
std::get<1>(bc[index]) = val;
|
||||
|
||||
bc[index].type = type;
|
||||
bc[index].value = val;
|
||||
|
||||
// std::get<0>(bc[index]) = type;
|
||||
// std::get<1>(bc[index]) = val;
|
||||
}
|
||||
|
||||
@ -42,7 +42,21 @@ public:
|
||||
* - Dirichlet boundary condition: type BC_DIRICHLET with the actual value of
|
||||
* the boundary condition
|
||||
*/
|
||||
typedef std::vector<std::tuple<bctype, double>> boundary_condition;
|
||||
typedef struct boundary_condition {
|
||||
bctype type;
|
||||
double value;
|
||||
} boundary_condition;
|
||||
|
||||
/*!
|
||||
* A boundary condition consists of two features. A type and the according
|
||||
* value. Here we can differentiate between:
|
||||
*
|
||||
* - Neumann boundary conditon: type BC_NEUMANN with the value defining the
|
||||
* gradient
|
||||
* - Dirichlet boundary condition: type BC_DIRICHLET with the actual value of
|
||||
* the boundary condition
|
||||
*/
|
||||
// typedef std::vector<std::tuple<bctype, double>> boundary_condition;
|
||||
|
||||
/*!
|
||||
* Datatype to fill the sparse matrix which is used to solve the equation
|
||||
@ -117,7 +131,7 @@ private:
|
||||
|
||||
void updateInternals();
|
||||
|
||||
boundary_condition bc;
|
||||
std::vector<boundary_condition> bc;
|
||||
|
||||
Eigen::SparseMatrix<double> A_matrix;
|
||||
Eigen::VectorXd b_vector;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user