Timothy  0.9
Tissue Modelling Framework
 All Data Structures Files Functions Variables Typedefs Macros
global.h
Go to the documentation of this file.
1 /* **************************************************************************
2  * This file is part of Timothy
3  *
4  * Copyright (c) 2014/15 Maciej Cytowski
5  * Copyright (c) 2014/15 ICM, University of Warsaw, Poland
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  * *************************************************************************/
22 
23 #include <zoltan.h>
24 
29 #define VERSION "1.0"
30 
31 #define POWER_OF_TWO(x) !(x&(x-1))
32 
33 /* architecture */
34 #if defined(__ia64) || defined(__itanium__) || defined(_M_IA64)
35  #define CPUARCH "Itanium"
36 #endif
37 #if defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
38 #if defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
39  defined(__64BIT__) || defined(_LP64) || defined(__LP64__)
40  #define CPUARCH "POWER64"
41 #else
42  #define CPUARCH "POWER32"
43 #endif
44 #endif
45 #if defined(__sparc)
46  #define CPUARCH "SPARC"
47 #endif
48 #if defined(__x86_64__) || defined(_M_X64)
49  #define CPUARCH "x86_64"
50 #elif defined(__i386) || defined(_M_IX86)
51  #define CPUARCH "x86_32"
52 #endif
53 
54 /* cell data structure */
55 #pragma pack(1)
56 struct cellData {
57  int lifetime; /* age of the cell */
58  int phase; /* actual phase of the cell (0=G0,1=G1,2=S,3=G2,4=M,5=Necrotic) */
59  int age; /* cell's age */
60  int death;
61  int halo;
62  float phasetime; /* actual phase time */
63  float g1;
64  float s;
65  float g2;
66  float m;
67  float young;
68  ZOLTAN_ID_TYPE gid; /* global ID of the particle */
69  double x; /* x coordinate of the particle position */
70  double y; /* y coordinate of the particle position */
71  double z; /* z coordinate of the particle position */
72  double size; /* radius of the cell */
73  double h; /* neighbourhood of the cell */
74  double v; /* particle potential */
75  double density; /* particle density */
76  double scalarField; /* additional scalar field which can be used for analysis of results (printed to the output VTK files) */
77  unsigned char tumor;
78 };
79 
80 /* !!!!!!!!!!!!!!!!!!!!!!! */
81 /* the most important data */
82 struct cellData *cells;
83 double **cellFields;
85 /* !!!!!!!!!!!!!!!!!!!!!!! */
86 
87 int64_t maxCells;
88 #define numberOfCounts 8
89 
92 
93 #define nc totalCellCount[0]
94 #define g0nc totalCellCount[1]
95 #define g1nc totalCellCount[2]
96 #define snc totalCellCount[3]
97 #define g2nc totalCellCount[4]
98 #define mnc totalCellCount[5]
99 #define cnc totalCellCount[6]
100 #define nnc totalCellCount[7]
101 
102 #define lnc localCellCount[0]
103 #define lg0nc localCellCount[1]
104 #define lg1nc localCellCount[2]
105 #define lsnc localCellCount[3]
106 #define lg2nc localCellCount[4]
107 #define lmnc localCellCount[5]
108 #define lcnc localCellCount[6]
109 #define lnnc localCellCount[7]
110 
111 int64_t *tlnc;
112 
113 /* Parallelization */
114 
115 #pragma pack(1)
116 struct partData { /* this structure keeps cell data needed in potential computations */
117  double x;
118  double y;
119  double z;
120  double h;
121  double size;
122  double young;
123 };
124 
125 #pragma pack(1)
126 struct densPotData { /* this structure keeps additional cell data (potential & density) */
127  double v;
128  double density;
129 };
130 
131 //#define MAX_CELLS_PER_PROC 10485760
133 
134 int MPIrank; /* MPI rank */
135 int MPIsize; /* MPI size */
136 int MPIdim[3]; /* processor topology dimensions (MPI_Dims_create) */
137 int OMPthreads; /* number of OpenMP threads in use */
138 
142 
143 MPI_Comm MPI_CART_COMM;
144 int **MPIcoords;
145 
146 struct Zoltan_Struct *ztn;
147 
152 
153 int numExp;
154 int numImp;
155 
156 /* system */
157 int endian; /* =0 - big endian, =1 - little endian */
158 
159 /* model setup */
160 int sdim; /* dimensionality of the system */
161 int mitrand; /* mitosis random direction */
162 int nx; /* box x size */
163 int ny; /* box y size */
164 int nz; /* box z size */
165 char rstFileName[128]; /* restart file name */
166 char outdir[128]; /* output directory */
167 char logdir[128]; /* log directory */
168 char rng[3]; /* type of the Random Number Generator */
169 int nsteps; /* number of simulation steps */
170 
171 /* simulation */
172 int simStart; /* start simulation flag */
173 int step; /* step number */
174 float tstep; /* time step size */
175 float simTime; /* time of the simulation */
176 float maxSpeed; /* maximal displacement of cells in a single time step given by fraction of cell size */
177 float maxSpeedInUnits; /* maximal displacement in cm/s */
178 char cOutType[3];
179 char fOutType[3];
180 int vtkout;
181 int povout;
182 int vnfout;
183 
184 /* cell cycle */
185 float g1; /* mean duration of G1 phase - healthy tissue */
186 float s; /* mean duration of S phase - healthy tissue */
187 float g2; /* mean duration of G2 phase - healthy tissue */
188 float m; /* mean duration of M phase - healthy tissue */
189 float v; /* variability of duration of cell cycles */
190 float rd; /* random death probability */
191 
192 float cg1; /* mean duration of G1 phase - cancer cells */
193 float cs; /* mean duration of S phase - cancer cells */
194 float cg2; /* mean duration of G2 phase - cancer cells */
195 float cm; /* mean duration of M phase - cancer cells */
196 
197 double csize; /* cell initial size, no units */
198 double csizeInUnits; /* cell size in micrometers */
199 double cellVolume; /* cell volume */
200 double h; /* cell neighbourhood radius */
201 double h2; /* 2nd power of h */
202 double h3; /* 3rd power of h */
203 double h4; /* 4th power of h */
204 
205 int cancer;
206 int64_t rsum;
207 
210 
211 int rst;
213 
217 
218 int64_t nhs; /* number of cells to activate random dying - homeostasis of cell colony */
219 
220 int tgs; /* - tumor growth simulation, 0 - no tumor growth */
221 
223  double x;
224  double y;
225  double z;
226 };
227 
229  int64_t x;
230  int64_t y;
231  int64_t z;
232 };
233 
235  float x;
236  float y;
237  float z;
238 };
239 
240 int64_t localID;
241 
242 float dummy; /* dummy float parameter in the restart file (it can be used if necessary) */
243 
244 double boxmin[3],boxmax[3];
245 double boxsize;
246 
248 
249 float gfDt;
250 float gfH;
251 
252 int gfIter;
254 
255 /* statistics */
257  double minsize; /* Minimum size of cells */
258  double maxsize; /* Maximum size of cells */
259  double mindist; /* Minimum distance between neighbourhood cells */
260  double maxvel; /* Maximum velocity in the system */
261  double minvel; /* Minimum velocity in the system */
262  double maxdens; /* Maximum density */
263  double mindens; /* Minimum density */
264  double densdev; /* Density deviation */
265  double densavg; /* Average density */
266 };
267 
269 
272 
273 /* randomization */
274 #define SEED 985456376
275 int *stream;
276 
277 /* tree */
278 struct bht_node {
279  double len;
280  double center[3];
281  int partnum;
282  struct bht_node* father;
283  struct bht_node* child[8];
284  unsigned char leaf;
285  unsigned char isempty;
286 };
287 
288 struct bht_node *tree;
290 struct bht_node** leafs;
291 
292 int nnodes;
294 
295 int tnc;
296 
297 int ni;
double density
Definition: global.h:75
double h
Definition: global.h:120
int statOutStep
Definition: global.h:214
int64_t x
Definition: global.h:229
int MPINodeRank
Definition: global.h:139
double z
Definition: global.h:225
float secondsPerStep
Definition: global.h:247
int64_t * tlnc
Definition: global.h:111
int MPIdim[3]
Definition: global.h:136
double csizeInUnits
Definition: global.h:198
int MPIrank
Definition: global.h:134
float s
Definition: global.h:186
float z
Definition: global.h:237
int povout
Definition: global.h:181
double densavg
Definition: global.h:265
float g1
Definition: global.h:185
int memPerProc
Definition: global.h:141
float g2
Definition: global.h:65
char fOutType[3]
Definition: global.h:179
float m
Definition: global.h:66
unsigned char leaf
Definition: global.h:284
int64_t localID
Definition: global.h:240
int nnodes
Definition: global.h:292
struct partData * sendData
Definition: global.h:148
double z
Definition: global.h:119
float young
Definition: global.h:67
int simStart
Definition: global.h:172
float dummy
Definition: global.h:242
int tgs
Definition: global.h:220
double scalarField
Definition: global.h:76
int mitrand
Definition: global.h:161
int64_t nhs
Definition: global.h:218
int gfIter
Definition: global.h:252
unsigned char tumor
Definition: global.h:77
int vtkOutStep
Definition: global.h:216
int MPIsize
Definition: global.h:135
int rst
Definition: global.h:211
char cOutType[3]
Definition: global.h:178
double densdev
Definition: global.h:264
int nsteps
Definition: global.h:169
#define numberOfCounts
Definition: global.h:88
float cm
Definition: global.h:195
double maxdens
Definition: global.h:262
double h4
Definition: global.h:203
double mindist
Definition: global.h:259
int cancer
Definition: global.h:205
float maxSpeed
Definition: global.h:176
float phasetime
Definition: global.h:62
int64_t z
Definition: global.h:231
double maxsize
Definition: global.h:258
double size
Definition: global.h:72
struct partData * recvData
Definition: global.h:149
double h3
Definition: global.h:202
float tstep
Definition: global.h:174
float gfH
Definition: global.h:250
struct densPotData * sendDensPotData
Definition: global.h:150
struct Zoltan_Struct * ztn
Definition: global.h:146
ZOLTAN_ID_TYPE gid
Definition: global.h:68
int numExp
Definition: global.h:153
struct doubleVector3d * velocity
Definition: global.h:84
int death
Definition: global.h:60
float m
Definition: global.h:188
int ni
Definition: global.h:297
unsigned char isempty
Definition: global.h:285
int sdim
Definition: global.h:160
double minsize
Definition: global.h:257
int rstOutStep
Definition: global.h:215
int vtkout
Definition: global.h:180
int OMPthreads
Definition: global.h:137
int tnc
Definition: global.h:295
char rstFileName[128]
Definition: global.h:165
int step
Definition: global.h:173
int64_t totalCellCount[numberOfCounts]
Definition: global.h:91
double y
Definition: global.h:224
int64_t maxCells
Definition: global.h:87
struct bht_node * child[8]
Definition: global.h:283
struct statisticsData statistics
Definition: global.h:268
char logdir[128]
Definition: global.h:167
double x
Definition: global.h:69
double x
Definition: global.h:223
double center[3]
Definition: global.h:280
int rstReset
Definition: global.h:212
int partnum
Definition: global.h:281
char rng[3]
Definition: global.h:168
int maxCellsPerProc
Definition: global.h:132
double csize
Definition: global.h:197
struct bht_node * bht_root
Definition: global.h:289
int MPINodeSize
Definition: global.h:140
struct bht_node ** leafs
Definition: global.h:290
int numImp
Definition: global.h:154
int phase
Definition: global.h:58
struct cellData * cells
Definition: global.h:82
struct bht_node * father
Definition: global.h:282
float g2
Definition: global.h:187
double densityCriticalLevel1
Definition: global.h:208
float x
Definition: global.h:235
int gfIterPerStep
Definition: global.h:253
double v
Definition: global.h:127
float v
Definition: global.h:189
float gfDt
Definition: global.h:249
double size
Definition: global.h:121
int nz
Definition: global.h:164
double maxvel
Definition: global.h:260
float y
Definition: global.h:236
int * stream
Definition: global.h:275
double z
Definition: global.h:71
int age
Definition: global.h:59
float simTime
Definition: global.h:175
int lifetime
Definition: global.h:57
double boxmax[3]
Definition: global.h:244
double h2
Definition: global.h:201
struct densPotData * recvDensPotData
Definition: global.h:151
float g1
Definition: global.h:63
int64_t y
Definition: global.h:230
double y
Definition: global.h:70
int vnfout
Definition: global.h:182
double densityCriticalLevel2
Definition: global.h:209
struct bht_node * tree
Definition: global.h:288
float rd
Definition: global.h:190
int64_t localCellCount[numberOfCounts]
Definition: global.h:90
double h
Definition: global.h:73
float cs
Definition: global.h:193
double globalMinVel
Definition: global.h:270
int endian
Definition: global.h:157
double young
Definition: global.h:122
int ** MPIcoords
Definition: global.h:144
double ** cellFields
Definition: global.h:83
float cg1
Definition: global.h:192
int ny
Definition: global.h:163
double boxsize
Definition: global.h:245
double cellVolume
Definition: global.h:199
int halo
Definition: global.h:61
int nx
Definition: global.h:162
double globalMaxVel
Definition: global.h:271
double len
Definition: global.h:279
double x
Definition: global.h:117
double v
Definition: global.h:74
double y
Definition: global.h:118
int64_t rsum
Definition: global.h:206
double mindens
Definition: global.h:263
float maxSpeedInUnits
Definition: global.h:177
char outdir[128]
Definition: global.h:166
float cg2
Definition: global.h:194
MPI_Comm MPI_CART_COMM
Definition: global.h:143
float s
Definition: global.h:64
double density
Definition: global.h:128
int nnodes_init
Definition: global.h:293
double minvel
Definition: global.h:261
double boxmin[3]
Definition: global.h:244
double h
Definition: global.h:200