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

contains driving functions for the global fields More...

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

Go to the source code of this file.

Functions

void fieldsInit ()
 
void fieldsSolve ()
 

Detailed Description

contains driving functions for the global fields

Definition in file fields.c.

Function Documentation

void fieldsInit ( )

This function intializes the fields. Various parameters are set and the Hypre initialization of the system is executed.

Definition at line 45 of file fields.c.

References chemEnvInitBC(), chemEnvInitSolver(), chemEnvInitSystem(), chemField, densityField, fieldAddr, fieldBC, fieldCriticalLevel1, fieldCriticalLevel2, fieldDiffCoef, fieldDt, fieldICMean, fieldICVar, fieldName, fieldType, gfDt, gfields, glucose, gridSize, hydrogenIon, NCHEM, oxygen, SCALAR_FIELD, secondsPerStep, tempEnvInitBC(), tempEnvInitSolver(), tempEnvInitSystem(), temperature, tempField, int64Vector3d::x, int64Vector3d::y, and int64Vector3d::z.

46 {
47  int nf, i;
48  int chf;
49 
50  if (!gfields)
51  return;
52 
53  nf = 0;
54 
55  strcpy(fieldName[nf], "density");
56  fieldType[nf] = SCALAR_FIELD;
57  fieldAddr[nf] =
58  (double *) calloc(gridSize.x * gridSize.y * gridSize.z,
59  sizeof(double));
60  densityField = (double *) fieldAddr[nf];
61  for (i = 0; i < gridSize.x * gridSize.y * gridSize.z; i++)
62  densityField[i] = 0.0;
63  nf++;
64 
65  strcpy(fieldName[nf], "temp");
66  fieldType[nf] = SCALAR_FIELD;
67  fieldAddr[nf] =
68  (double *) calloc(gridSize.x * gridSize.y * gridSize.z,
69  sizeof(double));
70  tempField = (double *) fieldAddr[nf];
71  for (i = 0; i < gridSize.x * gridSize.y * gridSize.z; i++)
72  tempField[i] = 0.0;
73  fieldDiffCoef[nf] = 1 * 1e-5;
74  fieldBC[nf] = 42.0;
75  fieldICMean[nf] = 36.0;
76  fieldICVar[nf] = 0;
77 
78  nf++;
79 
80  /* set default values for chemical parameters */
81  for (chf = 0; chf < NCHEM; chf++) {
82  if (chf == 0) {
83  strcpy(fieldName[nf], "oxygen");
84  fieldDt[nf] = gfDt;
85  fieldCriticalLevel1[nf] *= gfDt; //*(boxVolume/cellVolume);
86  fieldCriticalLevel2[nf] *= gfDt; //*(boxVolume/cellVolume);
87  }
88  if (chf == 1) {
89  strcpy(fieldName[nf], "glucose");
90  fieldDt[nf] = secondsPerStep;
91  }
92  if (chf == 2) {
93  strcpy(fieldName[nf], "hydrogenIon");
94  fieldDt[nf] = secondsPerStep;
95  }
96  fieldType[nf] = SCALAR_FIELD;
97  fieldAddr[nf] =
98  (double *) calloc(gridSize.x * gridSize.y * gridSize.z,
99  sizeof(double));
100  chemField[chf] = (double *) fieldAddr[nf];
101  for (i = 0; i < gridSize.x * gridSize.y * gridSize.z; i++)
102  chemField[chf][i] = 0.0;
103  nf++;
104  }
105 
106  /* initialize temperature field */
107  if (temperature) {
109  tempEnvInitBC();
111  }
112 
113  /* initialize chemical fields */
114  for (i = 0; i < NCHEM; i++) {
115  if (i == 0 && !oxygen)
116  continue;
117  if (i == 1 && !glucose)
118  continue;
119  if (i == 2 && !hydrogenIon)
120  continue;
122  chemEnvInitBC(i);
124  }
125 }
int64_t x
Definition: global.h:229
float secondsPerStep
Definition: global.h:247
double * tempField
Definition: fields.h:76
void chemEnvInitSystem(int nch)
Definition: chemf.c:130
void tempEnvInitSystem()
Definition: tempf.c:126
double * chemField[NCHEM]
Definition: fields.h:77
double fieldDiffCoef[NFIELDS]
Definition: fields.h:55
int64_t z
Definition: global.h:231
double fieldDt[NFIELDS]
Definition: fields.h:60
char fieldName[NFIELDS][128]
Definition: fields.h:51
double fieldICVar[NFIELDS]
Definition: fields.h:59
int hydrogenIon
Definition: fields.h:36
struct int64Vector3d gridSize
Definition: fields.h:41
double fieldBC[NFIELDS]
Definition: fields.h:57
int glucose
Definition: fields.h:35
double fieldCriticalLevel2[NFIELDS]
Definition: fields.h:70
double fieldCriticalLevel1[NFIELDS]
Definition: fields.h:69
double fieldICMean[NFIELDS]
Definition: fields.h:58
int temperature
Definition: fields.h:37
void chemEnvInitSolver(int nch)
Definition: chemf.c:390
#define SCALAR_FIELD
Definition: fields.h:30
float gfDt
Definition: global.h:249
void tempEnvInitSolver()
Definition: tempf.c:428
#define NCHEM
Definition: fields.h:29
double * fieldAddr[NFIELDS]
Definition: fields.h:52
int64_t y
Definition: global.h:230
void chemEnvInitBC(int nch)
Definition: chemf.c:260
void tempEnvInitBC()
Definition: tempf.c:219
int fieldType[NFIELDS]
Definition: fields.h:53
double * densityField
Definition: fields.h:75
int oxygen
Definition: fields.h:34
int gfields
Definition: fields.h:33

Here is the call graph for this function:

Here is the caller graph for this function:

void fieldsSolve ( )

This is a driving function for global field solver. It is called in each step of the simulation.

Definition at line 131 of file fields.c.

References chemEnvSolve(), gfields, gfIter, gfIterPerStep, glucose, hydrogenIon, NCHEM, oxygen, tempEnvSolve(), temperature, and updateCellStates().

132 {
133  int i;
134  if (!gfields)
135  return;
136  for (gfIter = 0; gfIter < gfIterPerStep; gfIter++) {
137  /* update cell state (if more than one iteration) */
138  if (gfIter > 0)
140  /* solve temperature field */
141  if (temperature)
142  tempEnvSolve();
143  /* solve chemical fields */
144  for (i = 0; i < NCHEM; i++) {
145  if (i == 0 && !oxygen)
146  continue;
147  if (i == 1 && !glucose)
148  continue;
149  if (i == 2 && !hydrogenIon)
150  continue;
151  chemEnvSolve(i);
152  }
153  }
154 }
int gfIter
Definition: global.h:252
void chemEnvSolve(int nch)
Definition: chemf.c:431
int hydrogenIon
Definition: fields.h:36
int glucose
Definition: fields.h:35
int gfIterPerStep
Definition: global.h:253
int temperature
Definition: fields.h:37
void tempEnvSolve()
Definition: tempf.c:467
#define NCHEM
Definition: fields.h:29
void updateCellStates()
Definition: cells.c:718
int oxygen
Definition: fields.h:34
int gfields
Definition: fields.h:33

Here is the call graph for this function:

Here is the caller graph for this function: