43 static inline int outsideTheBox(
int p)
52 if (x - r < 0 || x + r > (
double)
nx)
54 if (y - r < 0 || y + r > (
double)
ny)
56 if (
sdim == 3 && (z - r < 0 || z + r > (
double)
nz))
70 int64_t cellsActualSize;
84 stopRun(106,
"cells", __FILE__, __LINE__);
90 stopRun(106,
"velocity", __FILE__, __LINE__);
97 stopRun(106,
"cellFields", __FILE__, __LINE__);
99 if (!(
tlnc = (int64_t *) calloc(
MPIsize,
sizeof(int64_t))))
100 stopRun(106,
"tlnc", __FILE__, __LINE__);
138 if (!strcmp(
rng,
"UNB")) {
146 D =
csize * pow(8.0 *
nc, 1.0 / 2.0);
148 D =
csize * pow(8.0 *
nc, 1.0 / 3.0);
153 for (i = 0; i <
lnc; i++) {
170 (
unsigned long long int)
MPIrank *(
unsigned long long int)
190 if (!strcmp(
rng,
"BM")) {
201 D =
csize * pow(8.0 *
nc, 1.0 / 2.0);
203 D =
csize * pow(8.0 *
nc, 1.0 / 3.0);
208 for (i = 0; i <
lnc; i++) {
214 while (r1 == 0 || r1 >= 1.0) {
215 x1 = sprng(
stream) * 2 - 1;
216 x2 = sprng(
stream) * 2 - 1;
217 x3 = sprng(
stream) * 2 - 1;
218 r1 = x1 * x1 + x2 * x2 + x3 * x3;
220 l = sqrt(-2 * log(r1) / r1);
225 r2 = z1 * z1 + z2 * z2 + z3 * z3;
237 (
unsigned long long int)
MPIrank *(
unsigned long long int)
273 stopRun(109, NULL, __FILE__, __LINE__);
289 while (accept == 0) {
290 shift[0] = sprng(
stream) * 2.0 - 1.0;
291 shift[1] = sprng(
stream) * 2.0 - 1.0;
293 shift[2] = sprng(
stream) * 2.0 - 1.0;
296 sc = sqrt(pow(shift[0], 2) + pow(shift[1], 2) + pow(shift[2], 2));
300 shift[0] = sc * shift[0];
301 shift[1] = sc * shift[1];
302 shift[2] = sc * shift[2];
335 (
unsigned long long int)
MPIrank *(
unsigned long long int)
390 for (c = 0; c <
lnc; c++) {
397 MPI_Allreduce(center, gcenter, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
401 lmdist.val = INT_MAX;
404 for (c = 0; c <
lnc; c++) {
406 sqrt((
cells[c].
x - gcenter[0]) * (
cells[c].
x - gcenter[0]) +
407 (
cells[c].y - gcenter[1]) * (
cells[c].y - gcenter[1]) +
408 (
cells[c].z - gcenter[2]) * (
cells[c].z - gcenter[2]));
409 if (dist < lmdist.val) {
416 MPI_Allreduce(&lmdist, &gmdist, 1, MPI_DOUBLE_INT, MPI_MINLOC,
453 for (c = 0; c <
lnc; c++) {
460 if (c != pos &&
celld[c] == 0)
466 switch (
cells[c].phase) {
483 if (
cells[c].tumor == 1)
495 MPI_Allgather(&
lnc, 1, MPI_INT64_T,
tlnc, 1, MPI_INT64_T,
498 MPI_INT64_T, MPI_SUM, MPI_COMM_WORLD);
509 printf(
" Cells movement...");
517 printf(
"\nSimulation started.\n");
521 for (c = 0; c <
lnc; c++) {
541 double eps, epsCancer;
549 for (c = 0; c < lncAtThisStep; c++) {
551 if (outsideTheBox(c)) {
562 if (
cells[c].phase != 0
563 && ((
cells[c].tumor == 0 &&
cells[c].density <= eps)
564 || (
cells[c].tumor == 1 &&
cells[c].density <= epsCancer)))
567 switch (
cells[c].phase) {
579 if ((
cells[c].tumor == 0 &&
cells[c].density <= eps) ||
580 (
cells[c].tumor == 1 &&
cells[c].density <= epsCancer) ||
591 if ((
cells[c].tumor == 0 &&
cells[c].density > eps) ||
592 (
cells[c].tumor == 1 &&
cells[c].density > epsCancer) ||
611 -(1.0 / 3.0)) *
csize) * (
gfDt) / (3600.0 *
622 if (
cells[c].tumor == 0) {
623 death = (sprng(
stream) <
rd ? 1 : 0);
663 if (
cells[c].tumor == 0) {
664 death = (sprng(
stream) <
rd ? 1 : 0);
694 MPI_Allreduce(&
lnc, &
nc, 1, MPI_INT64_T, MPI_SUM, MPI_COMM_WORLD);
707 for (c = 0; c <
lnc; c++) {
708 if (
cells[c].tumor == 1)
723 celld = (
unsigned char *) calloc(lnc_old,
sizeof(
unsigned char));
void updateCellCounters()
contains various Timothy inline functions
contains the most important global variables, arrays and defines
struct doubleVector3d * velocity
void updateCellPositions()
int64_t totalCellCount[numberOfCounts]
struct statisticsData statistics
double fieldCriticalLevel2[NFIELDS]
double fieldCriticalLevel1[NFIELDS]
double densityCriticalLevel1
void markMiddleCancerCell()
double densityCriticalLevel2
int64_t localCellCount[numberOfCounts]
contains variables and arrays for global fields
void additionalScalarField()
void stopRun(int ierr, char *name, char *file, int line)
void cellsDeath(int lnc_old)