From 6ea3bf01821bc8c69ad6ff9135a1f04d0b7e3688 Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Fri, 11 Feb 2022 17:37:41 +0100 Subject: [PATCH] Fix indexing of boundary condition vector --- src/BTCSDiffusion.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index b452a73..507ce21 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -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; }