Fix indexing of boundary condition vector

This commit is contained in:
Max Luebke 2022-02-11 17:37:41 +01:00
parent b985707d2c
commit 6ea3bf0182

View File

@ -229,10 +229,11 @@ void BTCSDiffusion::fillMatrixFromRow(const DVectorRowMajor &alpha, int n_cols,
if (right_constant)
A_matrix.insert(offset + (n_cols - 2), offset + (n_cols - 2)) = 1;
for (int j = 1 + left_constant; j < n_cols - (1 - right_constant); j++) {
for (int j = 1 + left_constant, k = j - 1; j < n_cols - (1 - right_constant);
j++, k++) {
double sx = (alpha[j - 1] * time_step) / (delta * delta);
if (this->bc[row * (n_cols - 2) + j].type == BTCSDiffusion::BC_CONSTANT) {
if (this->bc[row * (n_cols - 2) + k].type == BTCSDiffusion::BC_CONSTANT) {
A_matrix.insert(offset + j, offset + j) = 1;
continue;
}