diff --git a/src/BTCSBoundaryCondition.cpp b/src/BTCSBoundaryCondition.cpp index eef46be..c45abd6 100644 --- a/src/BTCSBoundaryCondition.cpp +++ b/src/BTCSBoundaryCondition.cpp @@ -2,8 +2,8 @@ #include #include -#include "grid/BTCSBoundaryCondition.hpp" #include "BTCSUtils.hpp" +#include "grid/BTCSBoundaryCondition.hpp" constexpr uint8_t DIM_1D = 2; constexpr uint8_t DIM_2D = 4; @@ -126,10 +126,8 @@ auto Diffusion::BTCSBoundaryCondition::getInnerRow(uint32_t i) const -> bc_vec { throw_out_of_range("Index is out of range"); } - bc_vec::const_iterator start = - this->special_cells.begin() + (i * this->sizes[Y_DIM]); - bc_vec::const_iterator end = - this->special_cells.begin() + ((i + 1) * this->sizes[Y_DIM]); + auto start = this->special_cells.begin() + (i * this->sizes[Y_DIM]); + auto end = this->special_cells.begin() + ((i + 1) * this->sizes[Y_DIM]); bc_vec row(start, end); @@ -139,7 +137,8 @@ auto Diffusion::BTCSBoundaryCondition::getInnerRow(uint32_t i) const -> bc_vec { auto Diffusion::BTCSBoundaryCondition::getInnerCol(uint32_t i) const -> bc_vec { if (this->dim != 2) { throw_invalid_argument("getInnerCol is only applicable for 2D grids"); - } else if (i >= this->sizes[X_DIM]) { + } + if (i >= this->sizes[X_DIM]) { throw_out_of_range("Index is out of range"); } diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index 90d4354..9678b99 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -244,9 +244,10 @@ void Diffusion::BTCSDiffusion::fillMatrixFromRow( A_matrix.insert(0, 0) = 1; if (bc_inner[0].type != BC_UNSET) { - if (bc_inner[0].type != BC_TYPE_CONSTANT) + if (bc_inner[0].type != BC_TYPE_CONSTANT) { throw_invalid_argument("Inner boundary conditions with other type than " "BC_TYPE_CONSTANT are currently not supported."); + } A_matrix.insert(1, 1) = 1; } else { sx = (alpha[0] * time_step) / (dx * dx); @@ -257,9 +258,10 @@ void Diffusion::BTCSDiffusion::fillMatrixFromRow( for (int j = 2, k = j - 1; k < size - 1; j++, k++) { if (bc_inner[k].type != BC_UNSET) { - if (bc_inner[k].type != BC_TYPE_CONSTANT) + if (bc_inner[k].type != BC_TYPE_CONSTANT) { throw_invalid_argument("Inner boundary conditions with other type than " "BC_TYPE_CONSTANT are currently not supported."); + } A_matrix.insert(j, j) = 1; continue; } @@ -271,9 +273,10 @@ void Diffusion::BTCSDiffusion::fillMatrixFromRow( } if (bc_inner[size - 1].type != BC_UNSET) { - if (bc_inner[size - 1].type != BC_TYPE_CONSTANT) + if (bc_inner[size - 1].type != BC_TYPE_CONSTANT) { throw_invalid_argument("Inner boundary conditions with other type than " "BC_TYPE_CONSTANT are currently not supported."); + } A_matrix.insert(A_size - 2, A_size - 2) = 1; } else { sx = (alpha[size - 1] * time_step) / (dx * dx);