Timothy  0.9
Tissue Modelling Framework
 All Data Structures Files Functions Variables Typedefs Macros
vessel.c
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 <stdio.h>
24 #include <stdlib.h>
25 #include <mpi.h>
26 #include <math.h>
27 #include <inttypes.h>
28 
29 #include "global.h"
30 
39 {
40  int i, j, k;
41  int lenght;
42  int nEndothelial;
43  int nRings;
44  double intersect;
45  double circumradius;
46  double startPoint[3];
47  double direction[3];
48  double point[3];
49  double radius[3];
50  double t;
51  double angle;
52 
53  if (MPIrank == 0) {
54 
55  startPoint[0] = nx / 2.0;
56  startPoint[1] = ny / 2.0;
57  startPoint[2] = 0.05 * nz;
58 
59  direction[0] = 0.0;
60  direction[1] = 0.0;
61  direction[2] = 0.1;
62 
63  t = sqrt(direction[0] * direction[0] + direction[1] * direction[1] +
64  direction[2] * direction[2]);
65 
66  direction[0] /= t * 2 * csize * (1.0 - intersect);
67  direction[1] /= t * 2 * csize * (1.0 - intersect);
68  direction[2] /= t * 2 * csize * (1.0 - intersect);
69 
70  lenght = nz;
71  nEndothelial = 8;
72  intersect = 0.2;
73 
74  circumradius =
75  (2 * csize * (1.0 - intersect)) / (2 *
76  sin(M_PI /
77  (double) nEndothelial));
78  printf("circumradius=%f\n", circumradius);
79 
80  nRings = lenght / (2 * csize * (1.0 - intersect));
81 
82  printf("nRings=%d\n", nRings);
83  printf("lnc=%" PRId64 "\n", lnc);
84 
85  angle = (360 / nEndothelial) * (M_PI / 180);
86 
87  radius[0] = 0.0;
88  radius[1] = 1.0;
89  radius[2] = 0.0;
90 
91  lnc = 0;
92 
93  for (i = 0; i < nRings; i++) {
94  point[0] = startPoint[0];
95  point[1] = startPoint[1];
96  point[2] = startPoint[2];
97  for (j = 0; j < nEndothelial; j++) {
98  double x, y;
99  double alpha;
100  x = radius[0];
101  y = radius[1];
102  alpha = j * angle;
103  radius[0] = x * cos(alpha) - y * sin(alpha);
104  radius[1] = x * sin(alpha) + y * cos(alpha);
105  radius[2] = 0.0; //i*csize*(1.0-intersect);
106  t = sqrt(pow(radius[0], 2) + pow(radius[1], 2) +
107  pow(radius[2], 2));
108  radius[0] /= t;
109  radius[1] /= t;
110  radius[2] /= t;
111  radius[2] = i * csize * (1.0 - intersect);
112  cells[lnc].x = point[0] + circumradius * radius[0];
113  cells[lnc].y = point[1] + circumradius * radius[1];
114  cells[lnc].z = point[2] + radius[2];
115  cells[lnc].size = csize;
116  lnc++;
117  }
118  }
119 
120  }
121 }
int MPIrank
Definition: global.h:134
#define lnc
Definition: global.h:102
HYPRE_SStructVector x
Definition: tempf.c:41
double size
Definition: global.h:72
int initVessel()
Definition: vessel.c:38
contains the most important global variables, arrays and defines
double x
Definition: global.h:69
double csize
Definition: global.h:197
struct cellData * cells
Definition: global.h:82
int nz
Definition: global.h:164
double z
Definition: global.h:71
double y
Definition: global.h:70
int ny
Definition: global.h:163
int nx
Definition: global.h:162