TYCHO  1.3.0
 All Data Structures Files Functions Variables Enumerations Enumerator
/home/kapf/tycho_docu/start_file_reader.c
Go to the documentation of this file.
1 /*
2  * start_file_reader.c
3  *
4  * Author : Wolfgang Kapferer
5  *
6  */
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <math.h>
12 
13 #include "variables_global.h"
14 #include "prototypes.h"
15 
19 int start_file_reader(char filename[]) {
20 
21  char data[55][200];
22  int l;
23  FILE *fd;
24  char buffer[200];
25 
26  fd = fopen(filename, "r");
27  if (fd == NULL) {
28  printf("The Parameter File you specified does not exist.\n");
29  exit(10);
30  }
31 
32  l = 0;
33  while (feof(fd) == 0) {
34  fgets(data[l], 200, fd);
35  if ((data[l][0] == '#') || (data[l][0] == '\n')) continue;
36  data[l][strlen(data[l]) - 1] = '\0';
37  l++;
38  }
39  fclose(fd);
40 
41 
42 
43  filetype = atoi(data[0]);
44 
45  make_ics = atoi(data[1]);
46 
47  sprintf(dens_ic, "%s", data[2]);
48 
49  sprintf(temp_ic, "%s", data[3]);
50 
51  sprintf(vel_ic, "%s", data[4]);
52 
53  sprintf(wind_ic, "%s", data[5]);
54 
55  sprintf(obst_ic, "%s", data[6]);
56 
57  sprintf(sound_ic, "%s", data[7]);
58 
59  sprintf(marker_ic, "%s", data[8]);
60 
61  intial_velocity_file = atoi(data[9]);
62 
63  sprintf(output_dir, "%s", data[10]);
64 
65  strat_const_atmos = atoi(data[11]);
66 
67  x = atoi(data[12]);
68  y = atoi(data[13]);
69  z = atoi(data[14]);
70 
71  dimension = atoi(data[15]);
72 
73  xmax = atof(data[16]);
74  ymax = atof(data[17]);
75  zmax = atof(data[18]);
76 
77  bound.down = atoi(data[19]);
78  bound.up = atoi(data[20]);
79  bound.left = atoi(data[21]);
80  bound.right = atoi(data[22]);
81  bound.front = atoi(data[23]);
82  bound.back = atoi(data[24]);
83 
84  inflow_velocity = atof(data[25]);
85  inflow_density = atof(data[26]);
86  inflow_temperature = atof(data[27]);
87  starting_flow = atoi(data[28]);
88 
89  endtime_sim = atof(data[29]);
91 
92  output_frequency = atof(data[30]);
93 
94  restart_frequency = atof(data[31]);
95 
96  courant = atof(data[32]);
97 
98  gravity_on_off = atoi(data[33]);
99 
100  gasconstant = atof(data[34]);
101 
102  Gamma1 = atof(data[35]);
103 
104  wind_on_off = atoi(data[36]);
105 
106  wind_speed = atof(data[37]);
107 
108  number_of_threads = atoi(data[38]);
109 
110  with_obstacles = atoi(data[39]);
111 
112  obstacle_density = atof(data[40]);
113 
114  obstacle_temperature = atof(data[41]);
116 
117  obstacle_heat_conductivity = atof(data[42]);
118 
119  specific_heat_capacity_gas = atof(data[43]);
120 
121  specific_heat_capacity_obstacle = atof(data[44]);
122 
123  advection = atoi(data[45]);
124 
125  marker_density = atof(data[46]);
126 
127  viscosity_on_off = atoi(data[47]);
128 
129  with_sound_emitter = atoi(data[48]);
130 
131  sound_pressure_level = atof(data[49]);
132 
133  sound_pressure_level = pow(10, (sound_pressure_level / 20))*2.0E-5 * sqrt(2.0);
134 
135  with_one_pulse = atoi(data[50]);
136 
137  sound_frequency = atof(data[51]);
138 
139  sound_reflexion = atof(data[52]);
140 
141  obstalce_absorption_coefficient = atof(data[53]);
144 
145  //printf("%g\n", obstalce_absorption_coefficient);
146 
147  //for debug
148  //printf("%i\n", l);
149 
150  if (l != 54) {
151  printf("Simulation stops, because of too few data in the start file.\n");
152  exit(99);
153  }
154 
155  return 0;
156 }