51 printf(
"\nTimothy v.%s - Tissue Modelling Framework\n",
VERSION);
52 printf(
" M.Cytowski, Z.Szymanska\n");
53 printf(
" ICM, University of Warsaw\n");
54 printf(
" http://timothy.icm.edu.pl\n\n");
65 printf(
"Exec.info: %d ",
MPIsize);
75 printf(
" %d proc./node, %dMB/proc.\n\n",
MPINodeSize,
79 printf(
"%s, little endian\n", CPUARCH);
81 printf(
"%s, big endian\n", CPUARCH);
92 (
"This help prints all Timothy parameters and their meaning.\n\n");
93 for (i = 0; i <
NPAR; i++)
96 stopRun(999, NULL, __FILE__, __LINE__);
110 strcpy(
params[nr],
"SIZEX");
111 strcpy(
desc[nr],
"box size (X coordinate)");
117 strcpy(
params[nr],
"SIZEY");
118 strcpy(
desc[nr],
"box size (Y coordinate)");
124 strcpy(
params[nr],
"SIZEZ");
125 strcpy(
desc[nr],
"box size (Z coordinate)");
131 strcpy(
params[nr],
"RSTFILE");
132 strcpy(
desc[nr],
"restart file name");
139 strcpy(
desc[nr],
"number of cells");
145 strcpy(
params[nr],
"RNG");
146 strcpy(
desc[nr],
"random number generator type");
153 strcpy(
desc[nr],
"SPH kernel function diameter");
159 strcpy(
params[nr],
"NSTEPS");
160 strcpy(
desc[nr],
"number of simulation steps");
166 strcpy(
params[nr],
"OUTDIR");
167 strcpy(
desc[nr],
"output directory");
175 "mean duration of G1 phase (in hours) - healthy tissue");
182 strcpy(
desc[nr],
"mean duration of S phase (in hours) - healthy tissue");
190 "mean duration of G2 phase (in hours) - healthy tissue");
197 strcpy(
desc[nr],
"mean duration of M phase (in hours) - healthy tissue");
203 strcpy(
params[nr],
"SECPERSTEP");
204 strcpy(
desc[nr],
"time step");
210 strcpy(
params[nr],
"DIM");
211 strcpy(
desc[nr],
"dimensionality of the system (2D/3D)");
217 strcpy(
params[nr],
"MITRAND");
218 strcpy(
desc[nr],
"mitosis random direction (1/0)");
225 strcpy(
desc[nr],
"variability of duration of cell cycles, 0<V<1");
233 "radnom death - probability (for each cell) of being marked for dying. 0.0<=RD<1.0");
239 strcpy(
params[nr],
"RSTRESET");
240 strcpy(
desc[nr],
"reset simulation parameters of restart file");
246 strcpy(
params[nr],
"NHS");
248 "number of cells needed to activate random dying (for homeostasis)");
254 strcpy(
params[nr],
"TGS");
255 strcpy(
desc[nr],
"switches on tumor growth simulation");
261 strcpy(
params[nr],
"STATOUTSTEP");
262 strcpy(
desc[nr],
"every how many steps statistics are printed");
268 strcpy(
params[nr],
"RSTOUTSTEP");
269 strcpy(
desc[nr],
"every how many steps restart file is printed");
275 strcpy(
params[nr],
"VISOUTSTEP");
276 strcpy(
desc[nr],
"every how many steps VTK file is printed");
282 strcpy(
params[nr],
"CG1");
283 strcpy(
desc[nr],
"mean duration of G1 phase (in hours) - cancer cells");
290 strcpy(
desc[nr],
"mean duration of S phase (in hours) - cancer cells");
296 strcpy(
params[nr],
"CG2");
297 strcpy(
desc[nr],
"mean duration of G2 phase (in hours) - cancer cells");
304 strcpy(
desc[nr],
"mean duration of M phase (in hours) - cancer cells");
310 strcpy(
params[nr],
"MAXSPEED");
312 "maximal displacement of cells in one time step (0.0<MAXMOVE<1.0)");
318 strcpy(
params[nr],
"GFLOGDIR");
319 strcpy(
desc[nr],
"log directory");
325 strcpy(
params[nr],
"GFDT");
327 "the length of time step for solving global fields (unit: seconds)");
333 strcpy(
params[nr],
"GFH");
335 "grid resolution for solving global fields (unit: cell size)");
341 strcpy(
params[nr],
"GFIELDS");
343 "do we use global fields in the simulation? (0 - no, 1 - yes)");
349 strcpy(
params[nr],
"OXYGEN");
351 "do we use oxygen field in the simulation? (0 - no, 1 - yes)");
357 strcpy(
params[nr],
"OXYGENDC");
358 strcpy(
desc[nr],
"oxygen field diffusion coefficient");
364 strcpy(
params[nr],
"OXYGENBC");
366 "oxygen field boundary condition (Dirichlet), mol/cm^3");
372 strcpy(
params[nr],
"OXYGENICMEAN");
373 strcpy(
desc[nr],
"oxygen field initial condition mean, mol/cm^3");
379 strcpy(
params[nr],
"OXYGENICVAR");
380 strcpy(
desc[nr],
"oxygen field initial condition variance, mol/cm^3");
386 strcpy(
params[nr],
"OXYGENCONS");
387 strcpy(
desc[nr],
"oxygen field consumption, mol/(cell s)");
393 strcpy(
params[nr],
"OXYGENPROD");
394 strcpy(
desc[nr],
"oxygen field production, mol/(cell s)");
400 strcpy(
params[nr],
"OXYGENLAMBDA");
401 strcpy(
desc[nr],
"oxygen field lambda");
407 strcpy(
params[nr],
"OXYGENCL1");
408 strcpy(
desc[nr],
"oxygen field critical level 1, mol/cm^3");
414 strcpy(
params[nr],
"OXYGENCL2");
415 strcpy(
desc[nr],
"oxygen field critical level 2, mol/cm^3");
421 strcpy(
params[nr],
"GLUCOSE");
423 "do we use glucose field in the simulation? (0 - no, 1 - yes)");
429 strcpy(
params[nr],
"GLUCOSEDC");
430 strcpy(
desc[nr],
"glucose field diffusion coefficient");
436 strcpy(
params[nr],
"GLUCOSEBC");
438 "glucose field boundary condition (Dirichlet), mol/cm^3");
444 strcpy(
params[nr],
"GLUCOSEICMEAN");
445 strcpy(
desc[nr],
"glucose field initial condition mean, mol/cm^3");
451 strcpy(
params[nr],
"GLUCOSEICVAR");
452 strcpy(
desc[nr],
"glucose field initial condition variance, mol/cm^3");
458 strcpy(
params[nr],
"GLUCOSECONS");
459 strcpy(
desc[nr],
"glucose field consumption, mol/(cell s)");
465 strcpy(
params[nr],
"GLUCOSEPROD");
466 strcpy(
desc[nr],
"glucose field production, mol/(cell s)");
472 strcpy(
params[nr],
"GLUCOSELAMBDA");
473 strcpy(
desc[nr],
"glucose field lambda");
479 strcpy(
params[nr],
"GLUCOSECL1");
480 strcpy(
desc[nr],
"glucose field critical level 1, mol/cm^3");
486 strcpy(
params[nr],
"GLUCOSECL2");
487 strcpy(
desc[nr],
"glucose field critical level 2, mol/cm^3");
493 strcpy(
params[nr],
"HYDROGENION");
495 "do we use hydrogen ion field in the simulation? (0 - no, 1 - yes)");
501 strcpy(
params[nr],
"HYDROGENIONDC");
502 strcpy(
desc[nr],
"hydrogen ion field diffusion coefficient");
508 strcpy(
params[nr],
"HYDROGENIONBC");
510 "hydrogen ion field boundary condition (Dirichlet), mol/cm^3");
516 strcpy(
params[nr],
"HYDROGENIONICMEAN");
517 strcpy(
desc[nr],
"hydrogen ion field initial condition mean, mol/cm^3");
523 strcpy(
params[nr],
"HYDROGENIONICVAR");
525 "hydrogen ion field initial condition variance, mol/cm^3");
531 strcpy(
params[nr],
"HYDROGENIONCONS");
532 strcpy(
desc[nr],
"hydrogen ion field consumption, mol/(cell s)");
538 strcpy(
params[nr],
"HYDROGENIONPROD");
539 strcpy(
desc[nr],
"hydrogen ion field production, mol/(cell s)");
545 strcpy(
params[nr],
"HYDROGENIONLAMBDA");
546 strcpy(
desc[nr],
"hydrogen ion field lambda");
552 strcpy(
params[nr],
"HYDROGENIONCL1");
553 strcpy(
desc[nr],
"hydrogen ion field critical level 1, mol/cm^3");
559 strcpy(
params[nr],
"HYDROGENIONCL2");
560 strcpy(
desc[nr],
"hydrogen ion field critical level 2, mol/cm^3");
566 strcpy(
params[nr],
"TEMPERATURE");
568 "do we use temperature field in the simulation? (0 - no, 1 - yes)");
574 strcpy(
params[nr],
"MAXCELLS");
575 strcpy(
desc[nr],
"maximum number of cells in the simulation");
581 strcpy(
params[nr],
"COUTTYPE");
582 strcpy(
desc[nr],
"type of cellular data output (VTK or POV)");
588 strcpy(
params[nr],
"FOUTTYPE");
589 strcpy(
desc[nr],
"type of fields data output (VNF)");
603 char paramFileName[
FNLEN];
604 char buf[400], buf1[100], buf2[100], buf3[100];
609 strcpy(
outdir,
"results");
611 if (strlen(argv[2]) >=
FNLEN) {
612 fprintf(stderr,
"\nERROR File name too long (>%d characters).\n",
614 stopRun(0, NULL, __FILE__, __LINE__);
616 sprintf(paramFileName,
"%s", argv[2]);
619 printf(
"Reading parameters file: %s\n", paramFileName);
621 fhandle = fopen(paramFileName,
"r");
622 if (fhandle == NULL) {
624 fprintf(stderr,
"\nERROR while opening parameter file.\n\n");
625 stopRun(0, NULL, __FILE__, __LINE__);
628 while (!feof(fhandle)) {
631 ret = fgets(buf, 200, fhandle);
633 if (sscanf(buf,
"%s%s%s", buf1, buf2, buf3) < 2)
642 for (i = 0; i <
NPAR; i++) {
643 if (strcmp(buf1,
params[i]) == 0
644 && strcmp(
params[i],
"RSTFILE") == 0) {
645 strcpy((
char *)
addr[i], buf2);
649 if (strcmp(buf1,
params[i]) == 0
650 && strcmp(
params[i],
"MAXCELLS") == 0) {
651 *((int64_t *)
addr[i]) = atol(buf2);
664 while (!feof(fhandle)) {
667 ret = fgets(buf, 200, fhandle);
669 if (sscanf(buf,
"%s%s%s", buf1, buf2, buf3) < 2)
678 for (i = 0; i <
NPAR; i++) {
680 if (
rst == 1 && strcmp(
params[i],
"NC") == 0
681 && strcmp(
params[i], buf1) == 0) {
684 (
"NC value from the parameter file will be ignored. This is a restart simulation\n");
687 if (strcmp(buf1,
params[i]) == 0) {
690 *((
float *)
addr[i]) = atof(buf2);
693 printf(
"READ %s = %f\n",
params[i], *((
float *)
addr[i]));
699 *((
double *)
addr[i]) = atof(buf2);
702 printf(
"READ %s = %f\n",
params[i], *((
double *)
addr[i]));
708 strcpy((
char *)
addr[i], buf2);
711 printf(
"READ %s = %s\n",
params[i], buf2);
717 *((
int *)
addr[i]) = atoi(buf2);
720 printf(
"READ %s = %d\n",
params[i], *((
int *)
addr[i]));
726 *((int64_t *)
addr[i]) = atol(buf2);
729 printf(
"READ %s = %lld\n",
params[i], *((int64_t *)
addr[i]));
744 for (i = 0; i <
NPAR; i++) {
746 if (strcmp(
params[i],
"OXYGENDC") == 0 &&
set[i] == 0)
747 stopRun(114,
"OXYGENDC", __FILE__, __LINE__);
748 if (strcmp(
params[i],
"OXYGENBC") == 0 &&
set[i] == 0)
749 stopRun(114,
"OXYGENBC", __FILE__, __LINE__);
750 if (strcmp(
params[i],
"OXYGENICMEAN") == 0 &&
set[i] == 0)
751 stopRun(114,
"OXYGENICMEAN", __FILE__, __LINE__);
752 if (strcmp(
params[i],
"OXYGENICVAR") == 0 &&
set[i] == 0)
753 stopRun(114,
"OXYGENICVAR", __FILE__, __LINE__);
754 if (strcmp(
params[i],
"OXYGENCONS") == 0 &&
set[i] == 0)
755 stopRun(114,
"OXYGENCONS", __FILE__, __LINE__);
756 if (strcmp(
params[i],
"OXYGENPROD") == 0 &&
set[i] == 0)
757 stopRun(114,
"OXYGENPROD", __FILE__, __LINE__);
758 if (strcmp(
params[i],
"OXYGENLAMBDA") == 0 &&
set[i] == 0)
759 stopRun(114,
"OXYGENLAMBDA", __FILE__, __LINE__);
760 if (strcmp(
params[i],
"OXYGENCL1") == 0 &&
set[i] == 0)
761 stopRun(114,
"OXYGENCL1", __FILE__, __LINE__);
762 if (strcmp(
params[i],
"OXYGENCL2") == 0 &&
set[i] == 0)
763 stopRun(114,
"OXYGENCL2", __FILE__, __LINE__);
766 if (strcmp(
params[i],
"GLUCOSEDC") == 0 &&
set[i] == 0)
767 stopRun(114,
"GLUCOSEDC", __FILE__, __LINE__);
768 if (strcmp(
params[i],
"GLUCOSEBC") == 0 &&
set[i] == 0)
769 stopRun(114,
"GLUCOSEBC", __FILE__, __LINE__);
770 if (strcmp(
params[i],
"GLUCOSEICMEAN") == 0 &&
set[i] == 0)
771 stopRun(114,
"GLUCOSEICMEAN", __FILE__, __LINE__);
772 if (strcmp(
params[i],
"GLUCOSEICVAR") == 0 &&
set[i] == 0)
773 stopRun(114,
"GLUCOSEICVAR", __FILE__, __LINE__);
774 if (strcmp(
params[i],
"GLUCOSECONS") == 0 &&
set[i] == 0)
775 stopRun(114,
"GLUCOSECONS", __FILE__, __LINE__);
776 if (strcmp(
params[i],
"GLUCOSEPROD") == 0 &&
set[i] == 0)
777 stopRun(114,
"GLUCOSEPROD", __FILE__, __LINE__);
778 if (strcmp(
params[i],
"GLUCOSELAMBDA") == 0 &&
set[i] == 0)
779 stopRun(114,
"GLUCOSELAMBDA", __FILE__, __LINE__);
780 if (strcmp(
params[i],
"GLUCOSECL1") == 0 &&
set[i] == 0)
781 stopRun(114,
"GLUCOSECL1", __FILE__, __LINE__);
782 if (strcmp(
params[i],
"GLUCOSECL2") == 0 &&
set[i] == 0)
783 stopRun(114,
"GLUCOSECL2", __FILE__, __LINE__);
786 if (strcmp(
params[i],
"HYDROGENIONDC") == 0 &&
set[i] == 0)
787 stopRun(114,
"HYDROGENIONDC", __FILE__, __LINE__);
788 if (strcmp(
params[i],
"HYDROGENIONBC") == 0 &&
set[i] == 0)
789 stopRun(114,
"HYDROGENIONBC", __FILE__, __LINE__);
790 if (strcmp(
params[i],
"HYDROGENIONICMEAN") == 0 &&
set[i] == 0)
791 stopRun(114,
"HYDROGENIONICMEAN", __FILE__, __LINE__);
792 if (strcmp(
params[i],
"HYDROGENIONICVAR") == 0 &&
set[i] == 0)
793 stopRun(114,
"HYDROGENIONICVAR", __FILE__, __LINE__);
794 if (strcmp(
params[i],
"HYDROGENIONCONS") == 0 &&
set[i] == 0)
795 stopRun(114,
"HYDROGENIONCONS", __FILE__, __LINE__);
796 if (strcmp(
params[i],
"HYDROGENIONPROD") == 0 &&
set[i] == 0)
797 stopRun(114,
"HYDROGENIONPROD", __FILE__, __LINE__);
798 if (strcmp(
params[i],
"HYDROGENIONLAMBDA") == 0 &&
set[i] == 0)
799 stopRun(114,
"HYDROGENIONLAMBDA", __FILE__, __LINE__);
800 if (strcmp(
params[i],
"HYDROGENIONCL1") == 0 &&
set[i] == 0)
801 stopRun(114,
"HYDROGENIONCL1", __FILE__, __LINE__);
802 if (strcmp(
params[i],
"HYDROGENIONCL2") == 0 &&
set[i] == 0)
803 stopRun(114,
"HYDROGENIONCL2", __FILE__, __LINE__);
810 "This is a tumor growth simulation. NHS is undefined. Define NHS in parameter file\n");
813 stopRun(0, NULL, __FILE__, __LINE__);
817 for (i = 0; i <
NPAR; i++)
818 if (
req[i] == 1 &&
set[i] == 0) {
820 fprintf(stderr,
"Missing parameter: %s - %s.\nProgram Abort.\n",
824 stopRun(0, NULL, __FILE__, __LINE__);
828 if (maxSpeed <= 0.0 || maxSpeed >= 4.0)
829 stopRun(111, NULL, __FILE__, __LINE__);
833 printf(
"SIZEX = %d. Must be a power of two.\n\n",
nx);
834 stopRun(100,
"X", __FILE__, __LINE__);
838 printf(
"SIZEY = %d. Must be a power of two.\n\n",
ny);
839 stopRun(100,
"Y", __FILE__, __LINE__);
843 printf(
"SIZEZ = %d. Must be a power of two.\n\n",
nz);
844 stopRun(100,
"Z", __FILE__, __LINE__);
847 printf(
"Box size: %dx%dx%d\n",
nx,
ny,
nz);
852 printf(
"Output directory: %s\n",
outdir);
856 printf(
"%s/ directory does not exist.\nCreating directory %s/.\n",
858 mkdir(
outdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
861 mkdir(
outdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
864 printf(
"Log directory: %s\n\n",
logdir);
868 printf(
"%s/ directory does not exist.\nCreating directory %s/.\n",
870 mkdir(
logdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
873 mkdir(
logdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
904 strcpy(
nameOut[nfOut],
"size");
916 strcpy(
nameOut[nfOut],
"rank");
924 strcpy(
nameOut[nfOut],
"phase");
936 strcpy(
nameOut[nfOut],
"tumor");
948 strcpy(
nameOut[nfOut],
"halo");
960 strcpy(
nameOut[nfOut],
"velocity");
982 strcpy(
nameOut[nfOut],
"scalarField");
988 (int64_t) &
cells[1].scalarField -
1006 float *floatVectorField;
1007 float *floatScalarField;
1008 int *integerScalarField;
1012 MPI_Offset offset, goffset;
1016 floatVectorField = (
float *) calloc(
lnc * 3,
sizeof(
float));
1017 floatScalarField = (
float *) calloc(
lnc,
sizeof(
float));
1018 integerScalarField = (
int *) calloc(
lnc,
sizeof(
int));
1020 sprintf(fstname,
"%s/step%08d.vtk",
outdir, step);
1023 MPI_File_open(MPI_COMM_WORLD, fstname, MPI_MODE_WRONLY | MPI_MODE_CREATE,
1024 MPI_INFO_NULL, &fh);
1026 MPI_File_set_size(fh, 0);
1029 "# vtk DataFile Version 2.0\nTimothy output\nBINARY\nDATASET UNSTRUCTURED_GRID\n");
1032 MPI_Allgather(&
lnc, 1, MPI_LONG_LONG,
tlnc, 1, MPI_LONG_LONG,
1040 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1042 goffset += strlen(header);
1043 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1046 memset(header, 0, 256);
1047 sprintf(header,
"\nPOINTS %" PRId64
" float\n",
nc);
1049 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1051 goffset += strlen(header);
1052 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1054 offset = nprev *
sizeof(float) * 3;
1055 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1056 for (j = 0; j <
lnc; j++) {
1057 floatVectorField[3 * j] = (float) (
cells[j].
x);
1058 floatVectorField[3 * j + 1] = (float) (
cells[j].y);
1059 floatVectorField[3 * j + 2] = (float) (
cells[j].z);
1062 swap_Nbyte((
char *) floatVectorField, lnc * 3,
sizeof(
float));
1063 MPI_File_write(fh, floatVectorField, 3 * lnc, MPI_FLOAT,
1065 goffset +=
nc *
sizeof(float) * 3;
1066 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1069 memset(header, 0, 256);
1070 sprintf(header,
"\nCELL_TYPES %" PRId64
"\n",
nc);
1072 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1074 goffset += strlen(header);
1075 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1076 offset = nprev *
sizeof(int);
1077 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1078 for (j = 0; j <
lnc; j++)
1079 integerScalarField[j] = 1;
1081 swap_Nbyte((
char *) integerScalarField, lnc,
sizeof(
int));
1082 MPI_File_write(fh, integerScalarField, lnc, MPI_INT, MPI_STATUS_IGNORE);
1083 goffset +=
nc *
sizeof(int);
1084 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1087 memset(header, 0, 256);
1088 sprintf(header,
"\nPOINT_DATA %" PRId64,
nc);
1090 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1092 goffset += strlen(header);
1093 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1096 for (i = 0; i <
nfOut; i++) {
1097 memset(header, 0, 256);
1101 sprintf(header,
"\nSCALARS %s float 1\nLOOKUP_TABLE default\n",
1104 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1106 goffset += strlen(header);
1107 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1108 for (j = 0; j <
lnc; j++)
1109 floatScalarField[j] =
1111 offset = nprev *
sizeof(float);
1112 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1114 swap_Nbyte((
char *) floatScalarField, lnc,
sizeof(
float));
1115 MPI_File_write(fh, floatScalarField, lnc, MPI_FLOAT,
1117 goffset +=
nc *
sizeof(float);
1118 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1121 sprintf(header,
"\nSCALARS %s integer 1\nLOOKUP_TABLE default\n",
1124 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1126 goffset += strlen(header);
1127 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1128 for (j = 0; j <
lnc; j++)
1129 integerScalarField[j] = *((
int *) (
addrOut[i] + j *
jumpOut[i]));
1130 offset = nprev *
sizeof(int);
1131 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1133 swap_Nbyte((
char *) integerScalarField, lnc,
sizeof(
int));
1134 MPI_File_write(fh, integerScalarField, lnc, MPI_INT,
1136 goffset +=
nc *
sizeof(int);
1137 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1144 sprintf(header,
"\nVECTORS %s float\n",
nameOut[i]);
1146 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1148 goffset += strlen(header);
1149 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1150 for (j = 0; j <
lnc; j++) {
1151 floatVectorField[3 * j] =
1153 floatVectorField[3 * j + 1] =
1155 ((
double *) (
addrOut[i] + 1 *
sizeof(double) +
1157 floatVectorField[3 * j + 2] =
1159 ((
double *) (
addrOut[i] + 2 *
sizeof(double) +
1162 offset = nprev *
sizeof(float) * 3;
1163 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1165 swap_Nbyte((
char *) floatVectorField, lnc * 3,
sizeof(
float));
1166 MPI_File_write(fh, floatVectorField, lnc * 3, MPI_FLOAT,
1168 goffset +=
nc * 3 *
sizeof(float);
1169 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1173 printf(header,
"\nVECTORS %s float\n",
nameOut[i]);
1175 MPI_File_write(fh, &header, strlen(header), MPI_BYTE,
1177 goffset += strlen(header);
1178 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1179 for (j = 0; j <
lnc; j++) {
1180 floatVectorField[3 * j] =
1182 floatVectorField[3 * j + 1] =
1184 ((
float *) (
addrOut[i] + 1 *
sizeof(
int) +
1186 floatVectorField[3 * j + 2] =
1188 ((
float *) (
addrOut[i] + 2 *
sizeof(
int) +
1191 offset = nprev *
sizeof(float) * 3;
1192 MPI_File_seek(fh, offset, MPI_SEEK_CUR);
1194 swap_Nbyte((
char *) floatVectorField, lnc * 3,
sizeof(
float));
1195 MPI_File_write(fh, floatVectorField, lnc * 3, MPI_FLOAT,
1197 goffset +=
nc * 3 *
sizeof(float);
1198 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1204 free(floatVectorField);
1205 free(floatScalarField);
1206 free(integerScalarField);
1208 MPI_File_close(&fh);
1220 (
"\n-------------------------------------------------------------------------\n");
1221 printf(
" Step %8d,%15s%8.4f%20s%14" PRId64
" ",
step,
"Time step = ",
1225 (
"\n-------------------------------------------------------------------------\n\n");
1226 printf(
" Time: %8.4f\n\n",
simTime);
1369 sprintf(fstname,
"%s/step%08d.rst",
outdir,
step);
1372 MPI_File_open(MPI_COMM_WORLD, fstname, MPI_MODE_WRONLY | MPI_MODE_CREATE,
1373 MPI_INFO_NULL, &fh);
1375 MPI_File_set_size(fh, 0);
1378 MPI_Allgather(&
lnc, 1, MPI_INT64_T,
tlnc, 1, MPI_INT64_T,
1390 for (i = 0; i <
nRst; i++) {
1395 offset +=
sizeRst[i] *
sizeof(float);
1400 offset +=
sizeRst[i] *
sizeof(int);
1405 offset +=
sizeRst[i] *
sizeof(char);
1410 offset +=
sizeRst[i] *
sizeof(double);
1415 offset +=
sizeRst[i] *
sizeof(int64_t);
1422 MPI_Bcast(&offset, 1, MPI_OFFSET, 0, MPI_COMM_WORLD);
1424 goffset = offset + nprev *
sizeof(
struct cellData);
1426 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1431 MPI_File_close(&fh);
1452 printf(
"Reading restart file: %s\n",
rstFileName);
1457 MPI_File_open(MPI_COMM_WORLD,
rstFileName, MPI_MODE_RDONLY,
1458 MPI_INFO_NULL, &fh);
1465 for (i = 0; i <
nRst; i++) {
1470 goffset +=
sizeRst[i] *
sizeof(float);
1475 goffset +=
sizeRst[i] *
sizeof(int);
1480 goffset +=
sizeRst[i] *
sizeof(char);
1485 goffset +=
sizeRst[i] *
sizeof(double);
1490 goffset +=
sizeRst[i] *
sizeof(int64_t);
1496 char *p = (
char *) &
one;
1500 printf(
"Restart file in little endian format.\n");
1503 printf(
"Conversion to big endian.\n");
1508 printf(
"Restart file in big endian format.\n");
1511 printf(
"Conversion to little endian.\n");
1517 for (i = 0; i <
nRst; i++) {
1544 stopRun(115, NULL, __FILE__, __LINE__);
1555 MPI_Allgather(&
lnc, 1, MPI_INT64_T,
tlnc, 1, MPI_INT64_T,
1560 goffset += nprev *
sizeof(
struct cellData);
1562 MPI_File_seek(fh, goffset, MPI_SEEK_SET);
1568 for (i = 0; i <
lnc; i++) {
1602 for (i = 0; i <
lnc; i++) {
1605 (
unsigned long long int) MPIrank *(
unsigned long long int)
1640 MPI_INT64_T, MPI_SUM, MPI_COMM_WORLD);
1641 MPI_Allreduce(&lcancer, &
cancer, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
1646 MPI_File_close(&fh);
1648 MPI_Barrier(MPI_COMM_WORLD);
1659 for (f = 0; f <
NFIELDS; f++) {
1677 float *floatScalarField;
1678 int *integerScalarField;
1686 MPI_Offset offset, goffset;
1687 MPI_Datatype subarray1_t, subarray2_t, float3_t;
1705 MPI_Type_vector(1, 3, 0, MPI_FLOAT, &float3_t);
1706 MPI_Type_commit(&float3_t);
1708 MPI_Type_create_subarray(bdim, gsize, bsize, bstart, MPI_ORDER_C,
1709 float3_t, &subarray1_t);
1710 MPI_Type_commit(&subarray1_t);
1722 MPI_Type_create_subarray(bdim, gsize, bsize, bstart, MPI_ORDER_C,
1723 MPI_FLOAT, &subarray2_t);
1724 MPI_Type_commit(&subarray2_t);
1726 for (f = 0; f <
NFIELDS; f++) {
1736 floatScalarField = (
float *) malloc(size *
sizeof(
float));
1737 integerScalarField = (
int *) malloc(size *
sizeof(
int));
1739 sprintf(fstname1,
"%s/%s%08dcoords.bin",
outdir,
nameOut[f], step);
1740 sprintf(fstname2,
"%s/%s%08dvalues.bin",
outdir,
nameOut[f], step);
1743 MPI_File_open(MPI_COMM_WORLD, fstname1,
1744 MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh1);
1745 MPI_File_set_view(fh1, 0, MPI_FLOAT, subarray1_t,
"native",
1748 MPI_File_set_size(fh1, 0);
1750 for (j = 0; j < size; j++) {
1756 swap_Nbyte((
char *) floatVectorField, size * 3,
sizeof(
float));
1757 MPI_File_write(fh1, floatVectorField, 3 * size, MPI_FLOAT,
1759 MPI_File_close(&fh1);
1762 MPI_File_open(MPI_COMM_WORLD, fstname2,
1763 MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh2);
1764 MPI_File_set_view(fh2, 0, MPI_FLOAT, subarray2_t,
"native",
1767 MPI_File_set_size(fh2, 0);
1769 for (j = 0; j < size; j++)
1772 swap_Nbyte((
char *) floatScalarField, size,
sizeof(
float));
1773 MPI_File_write(fh2, floatScalarField, size, MPI_FLOAT,
1776 MPI_File_close(&fh2);
1778 free(floatVectorField);
1779 free(floatScalarField);
1780 free(integerScalarField);
1783 MPI_Type_free(&subarray1_t);
1784 MPI_Type_free(&subarray2_t);
1793 dup2(fileno(stdout),
fdSave);
1795 fdNew = open(newStream, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1796 dup2(
fdNew, fileno(stdout));
1806 dup2(
fdSave, fileno(stdout));
1816 int numberOfColormaps;
1821 numberOfColormaps = 6;
1825 strcpy(
cmaps[0].name,
"medical");
1847 strcpy(
cmaps[1].name,
"rainbow");
1873 strcpy(
cmaps[2].name,
"bry");
1895 strcpy(
cmaps[3].name,
"hot");
1921 strcpy(
cmaps[4].name,
"hot1");
1947 strcpy(
cmaps[5].name,
"my");
1985 MPI_Offset disp, offset;
1986 MPI_Datatype subarray_t;
1989 "sphere{ <%10.4f,%10.4f,%10.4f>,%10.4f texture { pigment { color rgb <%6.4f,%6.4f,%6.4f> } finish { phong 0.2 ambient .1 }}} \n";
1990 char testBuffer[512];
1993 char *txtHeaderData;
1994 int numCharsPerCell;
2003 int64_t printed = 0;
2005 double fmin, fmax, fepsilon;
2010 double minCorner[3], maxCorner[3];
2011 double gMinCorner[3], gMaxCorner[3];
2013 double middlePointLocal[3];
2014 double middlePointGlobal[3];
2015 double lmass, gmass;
2019 minCorner[0] = DBL_MAX;
2020 minCorner[1] = DBL_MAX;
2021 minCorner[2] = DBL_MAX;
2022 maxCorner[0] = -DBL_MAX;
2023 maxCorner[1] = -DBL_MAX;
2024 maxCorner[2] = -DBL_MAX;
2026 for (i = 0; i <
lnc; i++) {
2046 MPI_Allreduce(minCorner, gMinCorner, 3, MPI_DOUBLE, MPI_MIN,
2048 MPI_Allreduce(maxCorner, gMaxCorner, 3, MPI_DOUBLE, MPI_MAX,
2051 middlePointLocal[0] = 0.0;
2052 middlePointLocal[1] = 0.0;
2053 middlePointLocal[2] = 0.0;
2057 for (c = 0; c <
lnc; c++) {
2064 MPI_Allreduce(middlePointLocal, middlePointGlobal, 3, MPI_DOUBLE,
2065 MPI_SUM, MPI_COMM_WORLD);
2066 MPI_Allreduce(&lmass, &gmass, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
2067 middlePointGlobal[0] /= gmass;
2068 middlePointGlobal[1] /= gmass;
2069 middlePointGlobal[2] /= gmass;
2071 middlePointGlobal[0] =
2072 gMinCorner[0] + (gMaxCorner[0] - gMinCorner[0]) / 2;
2073 middlePointGlobal[1] =
2074 gMinCorner[1] + (gMaxCorner[1] - gMinCorner[1]) / 2;
2075 middlePointGlobal[2] =
2076 gMinCorner[2] + (gMaxCorner[2] - gMinCorner[2]) / 2;
2085 cells[0].size, cr, cg, cb);
2088 (
char *) malloc(numCharsPerCell * (lnc + 16) *
sizeof(
char))))
2089 stopRun(106,
"txtData", __FILE__, __LINE__);
2090 txtData_p = txtData;
2097 sprintf(fstname,
"%s/step%08ddensity.pov",
outdir, step);
2102 sprintf(fstname,
"%s/step%08doxygen.pov",
outdir, step);
2103 MPI_Allreduce(&
fieldMin[
OXYG], &fmin, 1, MPI_DOUBLE, MPI_MIN,
2105 MPI_Allreduce(&
fieldMax[OXYG], &fmax, 1, MPI_DOUBLE, MPI_MAX,
2107 fepsilon = (fmax - fmin) * 0.1;
2113 sprintf(fstname,
"%s/step%08dphases.pov",
outdir, step);
2117 sprintf(fstname,
"%s/step%08dslice.pov",
outdir, step);
2121 sprintf(fstname,
"%s/step%08doutside.pov",
outdir, step);
2131 MPI_File_open(MPI_COMM_WORLD, fstname,
2132 MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
2133 if (error != MPI_SUCCESS)
2135 stopRun(113, NULL, __FILE__, __LINE__);
2137 MPI_File_set_size(fh, 0);
2142 float cameraLocation[3];
2144 float lightSource1[3];
2145 float lightSource2[3];
2146 float a1, a2, a3, b1, b2, b3, dist;
2150 a1 = (gMaxCorner[0] - gMinCorner[0]) / 2;
2151 a2 = (gMaxCorner[1] - gMinCorner[1]) / 2;
2152 a3 = (gMaxCorner[2] - gMinCorner[2]) / 2;
2154 b1 = a1 / (tan(30.0 * M_PI / 180.0));
2155 b2 = a2 / (tan(30.0 * M_PI / 180.0));
2156 b3 = a3 / (tan(30.0 * M_PI / 180.0));
2158 dist = (b1 >= b2 ? b1 : b2);
2159 dist = (dist >= b3 ? dist : b3);
2161 ss = sin(
beta * M_PI / 180.0);
2162 cc = cos(
beta * M_PI / 180.0);
2164 corner = sqrt(pow(a1, 2) + pow(a3, 2));
2167 -(middlePointGlobal[2] - corner - dist -
2168 middlePointGlobal[2]) * ss + middlePointGlobal[0];
2169 cameraLocation[1] = middlePointGlobal[1];
2171 (middlePointGlobal[2] - corner - dist -
2172 middlePointGlobal[2]) * cc + middlePointGlobal[2];
2174 lookAt[0] = middlePointGlobal[0];
2175 lookAt[1] = middlePointGlobal[1];
2176 lookAt[2] = middlePointGlobal[2];
2178 lightSource1[0] = cameraLocation[0];
2179 lightSource1[1] = cameraLocation[1];
2180 lightSource1[2] = cameraLocation[2];
2182 lightSource2[0] = lightSource1[0];
2183 lightSource2[1] = lightSource1[1];
2184 lightSource2[2] = lightSource1[2];
2186 txtHeaderData = (
char *) malloc(1024 *
sizeof(
char));
2189 sprintf(txtHeaderData,
2190 "#include \"colors.inc\"\ncamera { location <%f,%f,%f> look_at <%f,%f,%f> angle 60}\nlight_source { <%f,%f,%f> color White }\nlight_source { <%f,%f,%f> color White }\nbackground { color White }\n",
2191 cameraLocation[0], cameraLocation[1], cameraLocation[2],
2192 lookAt[0], lookAt[1], lookAt[2], lightSource1[0],
2193 lightSource1[1], lightSource1[2], lightSource2[0],
2194 lightSource2[1], lightSource2[2]);
2196 headerSize = headerLen *
sizeof(char);
2198 MPI_File_write(fh, txtHeaderData, headerLen, MPI_CHAR, &status);
2200 free(txtHeaderData);
2203 MPI_Bcast(&headerSize, 1, MPI_INT, 0, MPI_COMM_WORLD);
2205 for (c = 0; c <
lnc; c++) {
2209 && (
cells[c].z > middlePointGlobal[2] + 4.0 *
csize
2210 ||
cells[c].z < middlePointGlobal[2] - 4.0 *
csize))
2219 if (type == 2 || type == 3 || type == 4)
2220 color = (((float)
cells[c].phase) / 5.0);
2222 color = (((float)
MPIrank) / 512.0);
2225 color = color / 4 + 0.75;
2228 color = 1.0 - color;
2230 color = color * (1 - cmPad);
2231 if (color == 1 - cmPad)
2236 float d, dr, dg, db;
2241 if (color <=
cmaps[cm].cp[i].position) {
2259 cells[c].size, cr, cg, cb);
2280 sprintf(txtData_p, fmt, coords[0], coords[1], coords[2], size,
2281 color[0], color[1], color[2]);
2287 MPI_Allgather(&printed, 1, MPI_INT64_T, tPrinted, 1, MPI_INT64_T,
2292 isize[0] = printed * numCharsPerCell;
2294 istart[0] += tPrinted[i] * numCharsPerCell;
2297 gsize[0] += tPrinted[i] * numCharsPerCell;
2299 MPI_Type_create_subarray(gdims, gsize, isize, istart, MPI_ORDER_C,
2300 MPI_CHAR, &subarray_t);
2301 MPI_Type_commit(&subarray_t);
2303 MPI_File_set_view(fh, headerSize, MPI_CHAR, subarray_t,
"native",
2306 MPI_File_write(fh, txtData, isize[0], MPI_CHAR, &status);
2310 MPI_File_close(&fh);
2311 MPI_Type_free(&subarray_t);
void ioWriteStepPovRay(int step, int type)
void ioWriteFields(int step)
void readRstFile(int argc, char **argv)
double fieldDiffCoef[NFIELDS]
struct doubleVector3d * gridBuffer
void ioDefineOutputGlobalFields()
char fieldName[NFIELDS][128]
contains the most important global variables, arrays and defines
void * addrRst[NRSTPARAMS]
void decompositionInit(int argc, char **argv, MPI_Comm Comm)
contains defines and declarations for I/O functions
double fieldICVar[NFIELDS]
struct doubleVector3d * velocity
void ioDefineRstGlobalParams()
void switchStdOut(const char *newStream)
int64_t totalCellCount[numberOfCounts]
struct int64Vector3d gridSize
double fieldCriticalLevel2[NFIELDS]
struct int64Vector3d * gridStartIdx
double fieldCriticalLevel1[NFIELDS]
double fieldICMean[NFIELDS]
void ioDefineOutputFields()
void readParams(int argc, char **argv)
double fieldConsumption[NFIELDS]
double * fieldAddr[NFIELDS]
double densityCriticalLevel2
int64_t localCellCount[numberOfCounts]
contains variables and arrays for global fields
double fieldProduction[NFIELDS]
void swap_Nbyte(char *data, int n, int m)
void ioWriteStepVTK(int step)
double fieldLambda[NFIELDS]
void stopRun(int ierr, char *name, char *file, int line)
void initParams(int argc, char **argv)