Skip to content

Commit ff70156

Browse files
committed
Annotate bad ptr arithm
1 parent af43e1a commit ff70156

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/diffusion_thomas_algorithm.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ void DiffusionThomasAlgorithm::InitializeThomasAlgorithmVectors(
8888

8989
// Apply Dirichlet boundary conditions to the grid
9090
void DiffusionThomasAlgorithm::ApplyDirichletBoundaryConditions() {
91+
// FIXME: Fix BioDynaMo by returning a view or c++20 std::span.
9192
const auto* dimensions_ptr = GetDimensionsPtr();
92-
const real_t origin = dimensions_ptr
93-
[0]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
93+
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
94+
const real_t origin = dimensions_ptr[0];
9495
const real_t simulated_time = GetSimulatedTime();
9596
#pragma omp parallel
9697
{
@@ -166,10 +167,12 @@ void DiffusionThomasAlgorithm::ApplyDirichletBoundaryConditions() {
166167

167168
// Sets the concentration at a specific voxel
168169
void DiffusionThomasAlgorithm::SetConcentration(size_t idx, real_t amount) {
170+
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
169171
const auto* all_concentrations = GetAllConcentrations();
170172
const real_t current_concentration = all_concentrations[idx];
171173
ChangeConcentrationBy(idx, amount - current_concentration,
172174
InteractionMode::kAdditive, false);
175+
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
173176
}
174177

175178
// Flattens the 3D coordinates (x, y, z) into a 1D index
@@ -270,6 +273,7 @@ void DiffusionThomasAlgorithm::ForwardElimination(
270273
const std::vector<real_t>& thomas_denom, unsigned int jump) {
271274
// Get initial index based on direction
272275
size_t ind = GetLoopIndex(direction, outer, middle, 0);
276+
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
273277
const auto* all_concentrations = GetAllConcentrations();
274278
const real_t initial_concentration = all_concentrations[ind];
275279
SetConcentration(ind, initial_concentration / thomas_denom[0]);
@@ -283,11 +287,13 @@ void DiffusionThomasAlgorithm::ForwardElimination(
283287
(current_concentration + constant1_ * prev_concentration) /
284288
thomas_denom[inner]);
285289
}
290+
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
286291
}
287292

288293
void DiffusionThomasAlgorithm::BackSubstitution(
289294
unsigned int direction, unsigned int outer, unsigned int middle,
290295
const std::vector<real_t>& thomas_c, unsigned int jump) {
296+
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
291297
const auto* all_concentrations = GetAllConcentrations();
292298

293299
// Back substitution loop
@@ -300,6 +306,7 @@ void DiffusionThomasAlgorithm::BackSubstitution(
300306
ind, current_concentration -
301307
thomas_c[static_cast<size_t>(inner)] * next_concentration);
302308
}
309+
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
303310
}
304311

305312
size_t DiffusionThomasAlgorithm::GetLoopIndex(unsigned int direction,

0 commit comments

Comments
 (0)