style: fix various code style recommendations from clang

This commit is contained in:
Max Lübke 2022-08-16 15:35:14 +02:00
parent 67ca71404c
commit b7c9dbb535
2 changed files with 11 additions and 9 deletions

View File

@ -2,8 +2,8 @@
#include <bits/stdint-uintn.h> #include <bits/stdint-uintn.h>
#include <vector> #include <vector>
#include "grid/BTCSBoundaryCondition.hpp"
#include "BTCSUtils.hpp" #include "BTCSUtils.hpp"
#include "grid/BTCSBoundaryCondition.hpp"
constexpr uint8_t DIM_1D = 2; constexpr uint8_t DIM_1D = 2;
constexpr uint8_t DIM_2D = 4; 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"); throw_out_of_range("Index is out of range");
} }
bc_vec::const_iterator start = auto start = this->special_cells.begin() + (i * this->sizes[Y_DIM]);
this->special_cells.begin() + (i * this->sizes[Y_DIM]); auto end = this->special_cells.begin() + ((i + 1) * this->sizes[Y_DIM]);
bc_vec::const_iterator end =
this->special_cells.begin() + ((i + 1) * this->sizes[Y_DIM]);
bc_vec row(start, end); 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 { auto Diffusion::BTCSBoundaryCondition::getInnerCol(uint32_t i) const -> bc_vec {
if (this->dim != 2) { if (this->dim != 2) {
throw_invalid_argument("getInnerCol is only applicable for 2D grids"); 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"); throw_out_of_range("Index is out of range");
} }

View File

@ -244,9 +244,10 @@ void Diffusion::BTCSDiffusion::fillMatrixFromRow(
A_matrix.insert(0, 0) = 1; A_matrix.insert(0, 0) = 1;
if (bc_inner[0].type != BC_UNSET) { 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 " throw_invalid_argument("Inner boundary conditions with other type than "
"BC_TYPE_CONSTANT are currently not supported."); "BC_TYPE_CONSTANT are currently not supported.");
}
A_matrix.insert(1, 1) = 1; A_matrix.insert(1, 1) = 1;
} else { } else {
sx = (alpha[0] * time_step) / (dx * dx); 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++) { 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_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 " throw_invalid_argument("Inner boundary conditions with other type than "
"BC_TYPE_CONSTANT are currently not supported."); "BC_TYPE_CONSTANT are currently not supported.");
}
A_matrix.insert(j, j) = 1; A_matrix.insert(j, j) = 1;
continue; continue;
} }
@ -271,9 +273,10 @@ void Diffusion::BTCSDiffusion::fillMatrixFromRow(
} }
if (bc_inner[size - 1].type != BC_UNSET) { 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 " throw_invalid_argument("Inner boundary conditions with other type than "
"BC_TYPE_CONSTANT are currently not supported."); "BC_TYPE_CONSTANT are currently not supported.");
}
A_matrix.insert(A_size - 2, A_size - 2) = 1; A_matrix.insert(A_size - 2, A_size - 2) = 1;
} else { } else {
sx = (alpha[size - 1] * time_step) / (dx * dx); sx = (alpha[size - 1] * time_step) / (dx * dx);