Skip to content

Commit 522dc33

Browse files
committed
progress on cart_cell.cc
1 parent e4e77d2 commit 522dc33

File tree

3 files changed

+18
-125
lines changed

3 files changed

+18
-125
lines changed

clang_output.txt

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,9 @@
22
Suppressed 102341 warnings (102179 in non-user code, 162 NOLINT).
33
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
44
src/cart_cell.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell.cc\",\"lines\":[[1,321]]},{\"name\":\"src/cart_cell.h\",\"lines\":[[1,250]]},{\"name\":\"src/cart_tumor.cc\",\"lines\":[[1,133]]},{\"name\":\"src/cart_tumor.h\",\"lines\":[[1,36]]},{\"name\":\"src/diffusion_thomas_algorithm.cc\",\"lines\":[[1,319]]},{\"name\":\"src/diffusion_thomas_algorithm.h\",\"lines\":[[1,194]]},{\"name\":\"src/forces_tumor_cart.cc\",\"lines\":[[1,163]]},{\"name\":\"src/forces_tumor_cart.h\",\"lines\":[[1,60]]},{\"name\":\"src/hyperparams.h\",\"lines\":[[1,216]]},{\"name\":\"src/tumor_cell.cc\",\"lines\":[[1,673]]},{\"name\":\"src/tumor_cell.h\",\"lines\":[[1,301]]},{\"name\":\"src/utils_aux.cc\",\"lines\":[[1,176]]},{\"name\":\"src/utils_aux.h\",\"lines\":[[1,96]]}] --enable-check-profile -store-check-profile=clang-tidy-review-profile --config-file=.clang-tidy --export-fixes=/tmp/tmpb2o1s_sd/tmp_yehqeyw.yaml src/cart_cell.cc
5-
/github/workspace/src/cart_cell.cc:23:1: warning: #includes are not sorted properly [llvm-include-order]
6-
23 | #include <algorithm>
7-
| ^ ~~~~~~~~~~~
8-
| "hyperparams.h"
9-
24 | #include <cstdint>
10-
| ~~~~~~~~~
11-
| "tumor_cell.h"
12-
25 | #include <stdexcept>
13-
| ~~~~~~~~~~~
14-
| "utils_aux.h"
15-
26 | #include <string>
16-
| ~~~~~~~~
17-
| <algorithm>
18-
27 | #include "hyperparams.h"
19-
| ~~~~~~~~~~~~~~~
20-
| <cstdint>
21-
28 | #include "tumor_cell.h"
22-
| ~~~~~~~~~~~~~~
23-
| <stdexcept>
24-
29 | #include "utils_aux.h"
25-
| ~~~~~~~~~~~~~
26-
| <string>
275
/github/workspace/src/cart_cell.cc:33:1: warning: constructor does not initialize these fields: current_live_time_, fluid_fraction_, nuclear_volume_, target_cytoplasm_solid_, target_nucleus_solid_, target_fraction_fluid_, target_relation_cytoplasm_nucleus_, oxygen_consumption_rate_, immunostimulatory_factor_secretion_rate_, constant1_oxygen_, constant2_oxygen_ [cppcoreguidelines-pro-type-member-init]
286
33 | CartCell::CartCell(const Real3& position) {
297
| ^
30-
/github/workspace/src/cart_cell.cc:33:26: warning: no header providing "bdm::Real3" is directly included [misc-include-cleaner]
31-
27 | #include "hyperparams.h"
32-
28 | #include "tumor_cell.h"
33-
29 | #include "utils_aux.h"
34-
30 |
35-
31 | namespace bdm {
36-
32 |
37-
33 | CartCell::CartCell(const Real3& position) {
38-
| ^
398
/github/workspace/src/cart_cell.cc:36:3: warning: 'state_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
409
33 | CartCell::CartCell(const Real3& position) {
4110
| : state_(CartCellState::kAlive)
@@ -68,11 +37,6 @@ src/cart_cell.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell
6837
/github/workspace/src/cart_cell.cc:76:1: warning: no header providing "bdm::real_t" is directly included [misc-include-cleaner]
6938
27 | real_t CartCell::GetTargetTotalVolume() const {
7039
| ^
71-
/github/workspace/src/cart_cell.cc:87:5: warning: 3 adjacent parameters of 'ChangeVolumeExponentialRelaxationEquation' of similar type ('real_t') are easily swapped by mistake [bugprone-easily-swappable-parameters]
72-
87 | real_t relaxation_rate_cytoplasm, real_t relaxation_rate_nucleus,
73-
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74-
88 | real_t relaxation_rate_fluid) {
75-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7640
/github/workspace/src/cart_cell.cc:87:12: note: the first parameter in the range is 'relaxation_rate_cytoplasm'
7741
87 | real_t relaxation_rate_cytoplasm, real_t relaxation_rate_nucleus,
7842
| ^~~~~~~~~~~~~~~~~~~~~~~~~
@@ -123,39 +87,6 @@ src/cart_cell.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell
12387
138 | real_t new_volume = new_total_solid + new_fluid;
12488
| ^
12589
| const
126-
/github/workspace/src/cart_cell.cc:141:3: warning: variable 'new_fraction_fluid' of type 'real_t' (aka 'double') can be declared 'const' [misc-const-correctness]
127-
141 | real_t new_fraction_fluid = new_fluid / (1e-16 + new_volume);
128-
| ^
129-
| const
130-
/github/workspace/src/cart_cell.cc:141:44: warning: 1e-16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
131-
141 | real_t new_fraction_fluid = new_fluid / (1e-16 + new_volume);
132-
| ^
133-
/github/workspace/src/cart_cell.cc:156:45: warning: no header providing "bdm::InteractionForce" is directly included [misc-include-cleaner]
134-
27 | Real3 CartCell::CalculateDisplacement(const InteractionForce* force,
135-
| ^
136-
/github/workspace/src/cart_cell.cc:175:9: warning: no header providing "bdm::L2F" is directly included [misc-include-cleaner]
137-
27 | L2F([&](Agent* neighbor, real_t /*squared_distance*/) {
138-
| ^
139-
/github/workspace/src/cart_cell.cc:175:17: warning: no header providing "bdm::Agent" is directly included [misc-include-cleaner]
140-
27 | L2F([&](Agent* neighbor, real_t /*squared_distance*/) {
141-
| ^
142-
/github/workspace/src/cart_cell.cc:206:42: warning: 2 adjacent parameters of 'ConsumeSecreteSubstance' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters]
143-
206 | real_t CartCell::ConsumeSecreteSubstance(int substance_id,
144-
| ^~~~~~~~~~~~~~~~~
145-
207 | real_t old_concentration) {
146-
| ~~~~~~~~~~~~~~~~~~~~~~~~
147-
/github/workspace/src/cart_cell.cc:206:46: note: the first parameter in the range is 'substance_id'
148-
206 | real_t CartCell::ConsumeSecreteSubstance(int substance_id,
149-
| ^~~~~~~~~~~~
150-
/github/workspace/src/cart_cell.cc:207:49: note: the last parameter in the range is 'old_concentration'
151-
207 | real_t old_concentration) {
152-
| ^~~~~~~~~~~~~~~~~
153-
/github/workspace/src/cart_cell.cc:206:42: note:
154-
206 | real_t CartCell::ConsumeSecreteSubstance(int substance_id,
155-
| ^
156-
/github/workspace/src/cart_cell.cc:207:42: note: 'int' and 'real_t' may be implicitly converted: 'int' -> 'real_t' (as 'double'), 'real_t' (as 'double') -> 'int'
157-
207 | real_t old_concentration) {
158-
| ^
15990
/github/workspace/src/cart_cell.cc:208:10: warning: variable 'res' is not initialized [cppcoreguidelines-init-variables]
16091
23 | real_t res;
16192
| ^
@@ -164,64 +95,13 @@ src/cart_cell.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell
16495
235 | real_t volume = GetVolume();
16596
| ^
16697
| const
167-
/github/workspace/src/cart_cell.cc:264:26: warning: 1e-10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
168-
264 | 1e-10)) { // Probability of death= 1/CurrentLiveTime,
169-
| ^
17098
/github/workspace/src/cart_cell.cc:294:29: warning: narrowing conversion from 'real_t' (aka 'double') to 'int' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
17199
294 | cell->SetTimerState(cell->GetTimerState() + kDtCycle);
172100
| ^
173-
/github/workspace/src/cart_cell.cc:312:9: warning: no header providing "bdm::Log" is directly included [misc-include-cleaner]
174-
27 | Log::Error("StateControlCart::Run", "Unknown CartCellState");
175-
| ^
176-
src/forces_tumor_cart.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/cart_cell.cc\",\"lines\":[[1,321]]},{\"name\":\"src/cart_cell.h\",\"lines\":[[1,250]]},{\"name\":\"src/cart_tumor.cc\",\"lines\":[[1,133]]},{\"name\":\"src/cart_tumor.h\",\"lines\":[[1,36]]},{\"name\":\"src/diffusion_thomas_algorithm.cc\",\"lines\":[[1,319]]},{\"name\":\"src/diffusion_thomas_algorithm.h\",\"lines\":[[1,194]]},{\"name\":\"src/forces_tumor_cart.cc\",\"lines\":[[1,163]]},{\"name\":\"src/forces_tumor_cart.h\",\"lines\":[[1,60]]},{\"name\":\"src/hyperparams.h\",\"lines\":[[1,216]]},{\"name\":\"src/tumor_cell.cc\",\"lines\":[[1,673]]},{\"name\":\"src/tumor_cell.h\",\"lines\":[[1,301]]},{\"name\":\"src/utils_aux.cc\",\"lines\":[[1,176]]},{\"name\":\"src/utils_aux.h\",\"lines\":[[1,96]]}] --enable-check-profile -store-check-profile=clang-tidy-review-profile --config-file=.clang-tidy --export-fixes=/tmp/tmpb2o1s_sd/tmpkduc6546.yaml src/forces_tumor_cart.cc
177-
/github/workspace/src/forces_tumor_cart.cc:23:1: warning: #includes are not sorted properly [llvm-include-order]
178-
23 | #include <algorithm>
179-
| ^ ~~~~~~~~~~~
180-
| "hyperparams.h"
181-
24 | #include <cmath>
182-
| ~~~~~~~
183-
| "tumor_cell.h"
184-
25 | #include "hyperparams.h"
185-
| ~~~~~~~~~~~~~~~
186-
| "utils_aux.h"
187-
26 | #include "tumor_cell.h"
188-
| ~~~~~~~~~~~~~~
189-
| <algorithm>
190-
27 | #include "utils_aux.h"
191-
| ~~~~~~~~~~~~~
192-
| <cmath>
193-
/github/workspace/src/forces_tumor_cart.cc:31:1: warning: no header providing "bdm::Real4" is directly included [misc-include-cleaner]
194-
25 | #include "hyperparams.h"
195-
26 | #include "tumor_cell.h"
196-
27 | #include "utils_aux.h"
197-
28 |
198-
29 | namespace bdm {
199-
30 |
200-
31 | Real4 InteractionVelocity::Calculate(const Agent* lhs, const Agent* rhs) const {
201-
| ^
202-
/github/workspace/src/forces_tumor_cart.cc:31:44: warning: no header providing "bdm::Agent" is directly included [misc-include-cleaner]
203-
25 | #include "hyperparams.h"
204-
26 | #include "tumor_cell.h"
205-
27 | #include "utils_aux.h"
206-
28 |
207-
29 | namespace bdm {
208-
30 |
209-
31 | Real4 InteractionVelocity::Calculate(const Agent* lhs, const Agent* rhs) const {
210-
| ^
211101
/github/workspace/src/forces_tumor_cart.cc:32:3: warning: 'auto *a' can be declared as 'const auto *a' [readability-qualified-auto]
212102
32 | auto* a = dynamic_cast<const Cell*>(lhs);
213103
| ^
214104
| const
215-
/github/workspace/src/forces_tumor_cart.cc:32:32: warning: no header providing "bdm::Cell" is directly included [misc-include-cleaner]
216-
25 | #include "hyperparams.h"
217-
26 | #include "tumor_cell.h"
218-
27 | #include "utils_aux.h"
219-
28 |
220-
29 | namespace bdm {
221-
30 |
222-
31 | Real4 InteractionVelocity::Calculate(const Agent* lhs, const Agent* rhs) const {
223-
32 | auto* a = dynamic_cast<const Cell*>(lhs);
224-
| ^
225105
/github/workspace/src/forces_tumor_cart.cc:33:3: warning: 'auto *b' can be declared as 'const auto *b' [readability-qualified-auto]
226106
33 | auto* b = dynamic_cast<const Cell*>(rhs);
227107
| ^
@@ -232,9 +112,6 @@ src/forces_tumor_cart.cc: clang-tidy-18 -p=build -line-filter=[{\"name\":\"src/c
232112
| {
233113
37 | return {0.0, 0.0, 0.0, 0.0};
234114
|
235-
/github/workspace/src/forces_tumor_cart.cc:39:3: warning: no header providing "bdm::Real3" is directly included [misc-include-cleaner]
236-
39 | Real3 displacement = a->GetPosition() - b->GetPosition();
237-
| ^
238115
/github/workspace/src/forces_tumor_cart.cc:52:3: warning: variable 'dist_sq' of type 'double' can be declared 'const' [misc-const-correctness]
239116
52 | double dist_sq = displacement[0] * displacement[0] +
240117
| ^

src/cart_cell.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
#include <stdexcept>
2626
#include <string>
2727
#include "hyperparams.h"
28+
#include "core/util/root.h"
29+
#include "core/agent/agent.h"
30+
#include "core/agent/cell.h"
31+
#include "core/behavior/behavior.h"
32+
#include "core/diffusion/diffusion_grid.h"
33+
#include "core/container/math_array.h"
34+
#include "core/functor.h"
35+
#include "core/agent/new_agent_event.h"
36+
#include "core/real_t.h"
37+
#include "core/util/log.h"
38+
#include "core/interaction_force.h"
2839
#include "tumor_cell.h"
2940
#include "utils_aux.h"
3041

@@ -83,6 +94,7 @@ real_t CartCell::GetTargetTotalVolume() const {
8394
// volume (and proportions) smoothly toward a desired target volume over time
8495
// whe the cell is apoptotic. The relaxations rate controls the speed of
8596
// convergence
97+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
8698
void CartCell::ChangeVolumeExponentialRelaxationEquation(
8799
real_t relaxation_rate_cytoplasm, real_t relaxation_rate_nucleus,
88100
real_t relaxation_rate_fluid) {
@@ -138,7 +150,7 @@ void CartCell::ChangeVolumeExponentialRelaxationEquation(
138150
real_t new_volume = new_total_solid + new_fluid;
139151

140152
// Avoid division by zero
141-
real_t new_fraction_fluid = new_fluid / (1e-16 + new_volume);
153+
real_t new_fraction_fluid = new_fluid / (kEpsilon + new_volume);
142154

143155
// Update the cell's properties
144156
// if the volume has changed
@@ -203,6 +215,7 @@ Real3 CartCell::CalculateDisplacement(const InteractionForce* force,
203215

204216
// Compute new oxygen or immunostimulatory factor concentration after
205217
// consumption/ secretion
218+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
206219
real_t CartCell::ConsumeSecreteSubstance(int substance_id,
207220
real_t old_concentration) {
208221
real_t res;
@@ -261,7 +274,7 @@ void StateControlCart::Run(Agent* agent) {
261274
if (sim->GetRandom()->Uniform(1.0) <
262275
kDtCycle /
263276
std::max(cell->GetCurrentLiveTime(),
264-
1e-10)) { // Probability of death= 1/CurrentLiveTime,
277+
kEpsilon)) { // Probability of death= 1/CurrentLiveTime,
265278
// avoiding division by 0
266279
// the cell Dies
267280
cell->SetState(CartCellState::kApoptotic);

src/hyperparams.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ constexpr real_t kDt = kDtMechanics;
103103
/// computed to avoid errors with fmod
104104
constexpr int kStepsPerCycle = kDtCycle / kDt;
105105

106+
/// Epsilon for avoiding division by 0
107+
constexpr real_t kEpsilon = 1e-10;
108+
106109
/// Output little summary each half a day
107110
constexpr int kOutputCsvInterval = 12 * 60 / kDt;
108111

0 commit comments

Comments
 (0)