Timothy  0.9
Tissue Modelling Framework
 All Data Structures Files Functions Variables Typedefs Macros
vessel.c File Reference

contains functions defining virtual vessels More...

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <math.h>
#include <inttypes.h>
#include "global.h"
Include dependency graph for vessel.c:

Go to the source code of this file.

Functions

int initVessel ()
 

Detailed Description

contains functions defining virtual vessels

Definition in file vessel.c.

Function Documentation

int initVessel ( )

This functions builds a tube vessel from spheres.

Definition at line 38 of file vessel.c.

References cells, csize, lnc, MPIrank, nx, ny, nz, cellData::size, x, cellData::x, cellData::y, and cellData::z.

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
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