In this routine the output-files are written.
{
FILE *fd;
char filename[600];
int i, j, k, tmp1;
double tmp;
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (isnan(tmp)) {
printf("NaN in density array %i %i %i\n", i, j, k);
exit(0);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO Temperature File\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (isnan(tmp)) {
printf("NaN in temperature array %i %i %i\n", i, j, k);
printf(
"%g %g %i\n",
pre[i][j][k],
rho[i][j][k],
dom[i][j][k]);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO Pressure File\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (
dom[i][j][k] == 0) tmp =
pre[i][j][k];
if (
dom[i][j][k] == 1) tmp = 0.0;
if (isnan(tmp)) {
printf("NaN in pressure array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO Velocity File\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (isnan(tmp)) {
printf("NaN in vx array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
if (isnan(tmp)) {
printf("NaN in vy array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
if (isnan(tmp)) {
printf("NaN in vz array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO pressure on solid File\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO dba_map\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (isnan(tmp)) {
printf("NaN in dB_map array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
fd = fopen(filename, "wb");
fprintf(fd,
"TYCHO Marker File%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z,
counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
if (isnan(tmp)) {
printf("NaN in marker array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}