TYCHO  1.3.0
 All Data Structures Files Functions Variables Enumerations Enumerator
/home/kapf/tycho_docu/initiate_grid.c
Go to the documentation of this file.
1 /*
2  * initiate_grid.c
3  *
4  * Author: Wolfgang Kapferer
5  */
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 #include "variables_global.h"
11 #include "prototypes.h"
12 
16 int initiate_grid(int x, double xmin, double xmax, int y, double ymin, double ymax, int z, double zmin, double zmax) {
17  int i, j, k;
18  double dxfac, dyfac, dzfac;
19 
20  // spacing in all three directions
21  dxfac = (xmax - xmin) / (double) x;
22  dyfac = (ymax - ymin) / (double) y;
23  dzfac = (zmax - zmin) / (double) z;
24 
25  // the coordinate at the cell boundary and the cell centre in x-direction
26  for (i = 0; i < x; i++) {
27  zxa[i] = xmin + (double) (i) * dxfac;
28  zdx[i] = dxfac;
29  zxc[i] = zxa[i] + 0.5 * zdx[i];
30  }
31 
32  // the coordinate at the cell boundary and the cell centre in x-direction
33  for (j = 0; j < y; j++) {
34  zya[j] = ymin + (double) (j) * dyfac;
35  zdy[j] = dyfac;
36  zyc[j] = zya[j] + 0.5 * zdy[j];
37  }
38 
39  // the coordiante at the cell boundary and the cell centre in x-direction
40  for (k = 0; k < z; k++) {
41  zza[k] = zmin + (double) (k) * dzfac;
42  zdz[k] = dzfac;
43  zzc[k] = zza[k] + 0.5 * zdz[k];
44  }
45 
46  printf("Initiate grid done.\n");
47 
48 
49  //A spacing in all directions
50  spacing = dxfac;
51  return 0;
52 }