TYCHO  1.3.0
 All Data Structures Files Functions Variables Enumerations Enumerator
/home/kapf/tycho_docu/data_explorer.c
Go to the documentation of this file.
1 /*
2  * data_explorer.c
3  *
4  * Author: Wolfgang Kapferer
5  *
6  * Pressure on solid
7  */
8 
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <math.h>
12 
13 #ifdef _OPENMP
14 #include <omp.h>
15 #endif
16 
17 #include "variables_global.h"
18 #include "prototypes.h"
19 
25 int velocity_field_analyser(int x, int y, int z) {
26 
27  FILE *fd;
28  char filename[600];
29  int i, j, k;
30  double velocity_x, velocity_y, velocity_z;
31  double velo_ratio;
32 
33  sprintf(filename, "%stotal_quantities_of_fluid.txt", output_dir);
34  fd = fopen(filename, "aw");
35  if (fd == NULL) {
36  printf("-----------------------------------\n");
37  printf("The output directory does not exist\n");
38  printf("-----------------------------------\n");
39  exit(13);
40  }
41 
42  velocity_x = velocity_y = velocity_z = velo_ratio = 0.0;
43 
44  if (dimension == 3) {
45 #ifdef _OPENMP
46 #pragma omp parallel default(none) \
47  private(j, i, k) \
48  shared(x, y, z, velocity_x, velocity_y, velocity_z, \
49  rho, dom, vx, vy, vz)
50  {
51 #endif
52 
53  //Here we calculate a density * velocity quantity
54  for (i = 0; i < x; i++) {
55 
56 #ifdef _OPENMP
57 #pragma omp for schedule(static)
58 #endif
59 
60  for (j = 0; j < y; j++) {
61  for (k = 0; k < z; k++) {
62  if (dom[i][j][k] == 0) {
63  velocity_x += rho[i][j][k] * vx[i][j][k];
64  velocity_y += rho[i][j][k] * vy[i][j][k];
65  velocity_z += rho[i][j][k] * vz[i][j][k];
66  }
67  }
68  }
69  }
70 
71 #ifdef _OPENMP
72  }
73 #endif
74  }
75 
76  if (dimension == 2) {
77 #ifdef _OPENMP
78 #pragma omp parallel default(none) \
79  private(j, i, k) \
80  shared(x, y, z, velocity_x, velocity_y, velocity_z, \
81  rho, dom, vx, vy, vz)
82  {
83 #endif
84 
85  k = 0;
86  //Here we calculate a density * velocity quantity
87  for (i = 0; i < x; i++) {
88 
89 #ifdef _OPENMP
90 #pragma omp for schedule(static)
91 #endif
92 
93  for (j = 0; j < y; j++) {
94  if (dom[i][j][k] == 0) {
95  velocity_x += rho[i][j][k] * vx[i][j][k];
96  velocity_y += rho[i][j][k] * vy[i][j][k];
97  velocity_z += rho[i][j][k] * vz[i][j][k];
98  }
99  }
100  }
101 
102 #ifdef _OPENMP
103  }
104 #endif
105  }
106 
107  if (dimension == 2) {
108  velo_ratio = velocity_x / velocity_y;
109  fprintf(fd, "%e %e %e %e\n", time_sim, velo_ratio, velocity_x, velocity_y);
110  }
111 
112  if (dimension == 3) {
113  fprintf(fd, "%e %e %e %e\n", time_sim, velocity_x, velocity_y, velocity_z);
114  }
115 
116  fclose(fd);
117 
118  return 0;
119 }
120 
124 int pressure_on_solid_calc(int x, int y, int z) {
125 
126  FILE *fd;
127  char filename[600];
128  int i, j, k, l;
129  double total_pressure_force;
130 
131  total_pressure_force = 0.0;
132 
133  sprintf(filename, "%stotal_pressure_on_solid.txt", output_dir);
134  fd = fopen(filename, "aw");
135  if (fd == NULL) {
136  printf("-----------------------------------\n");
137  printf("The output directory does not exist\n");
138  printf("-----------------------------------\n");
139  exit(13);
140  }
141 
142  if (dimension == 3) {
143 #ifdef _OPENMP
144 #pragma omp parallel default(none) \
145  private(j, i, k, l) \
146  shared(x, y, z, total_pressure_force, \
147  pressure_on_solid, dimension, dom, xmax, \
148  ymax)
149  {
150 #endif
151 
152  for (i = 1; i < x - 1; i++) {
153 
154 #ifdef _OPENMP
155 #pragma omp for schedule(static)
156 #endif
157 
158  for (j = 1; j < y - 1; j++) {
159  for (k = 1; k < z - 1; k++) {
160  if (dom[i][j][k] == 1) {
161  for (l = -1; l < 2; l++) {
162  if (l == 0) continue;
163  if (dom[i + l][j][k] == 0) {
164  total_pressure_force += pressure_on_solid[i + l][j][k]*(xmax / x)*(ymax / y);
165  }
166  if (dom[i][j + l][k] == 0) {
167  total_pressure_force += pressure_on_solid[i][j + l][k]*(xmax / x)*(ymax / y);
168  }
169  if (dom[i][j][k + l] == 0) {
170  total_pressure_force += pressure_on_solid[i][j][k + l]*(xmax / x)*(ymax / y);
171  }
172  }
173  }
174  }
175  }
176  }
177 
178 #ifdef _OPENMP
179  }
180 #endif
181  }
182 
183 
184  if (dimension == 2) {
185 #ifdef _OPENMP
186 #pragma omp parallel default(none) \
187  private(j, i, k) \
188  shared(x, y, z, l, \
189  pressure_on_solid, \
190  dimension, dom, \
191  total_pressure_force, \
192  xmax, ymax)
193  {
194 #endif
195 
196 
197  k = 0;
198  for (i = 1; i < x - 1; i++) {
199 
200 #ifdef _OPENMP
201 #pragma omp for schedule(static)
202 #endif
203 
204  for (j = 1; j < y - 1; j++) {
205  if (dom[i][j][k] == 1) {
206  for (l = -1; l < 2; l++) {
207  if (l == 0) continue;
208  if (dom[i + l][j][k] == 0) {
209  total_pressure_force += pressure_on_solid[i + l][j][k]*(xmax / x);
210  }
211  if (dom[i][j + l][k] == 0) {
212  total_pressure_force += pressure_on_solid[i][j + l][k]*(xmax / x);
213  }
214  }
215  }
216  }
217  }
218 
219 #ifdef _OPENMP
220  }
221 #endif
222  }
223 
224  fprintf(fd, "%e %e\n", time_sim, total_pressure_force);
225  fclose(fd);
226 
227  return 0;
228 }
229 
230