hydrocode_Radial_Lag 0.3
This is an implementation of fully explict forward Euler scheme for multi-D radially symmetric compressible flows on Lagrangian coordinate
file_1D_out.c
浏览该文件的文档.
1
6#include <math.h>
7#include <string.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <time.h>
11
12#include "../include/var_struc.h"
13#include "../include/file_io.h"
14
15
19#define PRINT_NC(v, v_print) \
20 do { \
21 strcpy(file_data, add_out); \
22 strcat(file_data, #v); \
23 strcat(file_data, ".dat"); \
24 if((fp_write = fopen(file_data, "w")) == NULL) \
25 { \
26 printf("Cannot open solution output file: %s!\n", #v); \
27 exit(1); \
28 } \
29 for(k = 0; k < N; ++k) \
30 { \
31 for(j = 0; j < m; ++j) \
32 fprintf(fp_write, "%.10g\t", (v_print)); \
33 fprintf(fp_write, "\n"); \
34 } \
35 fclose(fp_write); \
36 } while (0)
37
49void file_1D_write(const int m, const int N, const struct cell_var_stru CV,
50 double * X[], const double * cpu_time, const char * problem, const double time_plot[])
51{
52 // Records the time when the program is running.
53 /*
54 struct tm * local_time;
55 time_t t;
56 t=time(NULL);
57 local_time=localtime(&t);
58 char str_time[100];
59 sprintf(str_time, "_%02d%02d%02d%02d%02d%02d", local_time->tm_year-100, local_time->tm_mon+1, local_time->tm_mday, local_time->tm_hour, local_time->tm_min, local_time->tm_sec);
60 */
61 char add_out[FILENAME_MAX+40];
62 // Get the address of the output data folder of the test example.
63 example_io(problem, add_out, 0);
64
65 char file_data[FILENAME_MAX+40];
66 FILE * fp_write;
67
68//===================Write Output Data File=========================
69
70 int k, j;
71 PRINT_NC(RHO, CV.RHO[k][j]);
72 PRINT_NC(U, CV.U[k][j]);
73 PRINT_NC(P, CV.P[k][j]);
74 PRINT_NC(E, CV.E[k][j]);
75#ifdef RADIAL_BASICS
76 PRINT_NC(R, X[k][j]);
77#else
78 PRINT_NC(X, 0.5 * (X[k][j] + X[k][j+1]));
79#endif
80
81 strcpy(file_data, add_out);
82 strcat(file_data, "time_plot.dat");
83 printf("%s\n",file_data);
84 if((fp_write = fopen(file_data, "w")) == NULL)
85 {
86 printf("Cannot open solution output file: time_plot!\n");
87 exit(1);
88 }
89 for(k = 0; k < N; ++k)
90 fprintf(fp_write, "%.10g\n", time_plot[k]);
91 fclose(fp_write);
92
93//======================Write Log File============================
94 config_write(add_out, cpu_time, problem);
95}
void config_write(const char *add_out, const double *cpu_time, const char *name)
This function write configuration data and program record into the file 'log.dat'.
void file_1D_write(const int m, const int N, const struct cell_var_stru CV, double *X[], const double *cpu_time, const char *problem, const double time_plot[])
This function write the 1-D solution into output '.dat' files.
Definition: file_1D_out.c:49
#define PRINT_NC(v, v_print)
Print out fluid variable 'v' with array data element 'v_print'.
Definition: file_1D_out.c:19
void example_io(const char *example, char *add_mkdir, const int i_or_o)
This function produces folder path for data input or output.
Definition: io_control.c:40
pointer structure of VARiables on STRUctural computational grid CELLs.
Definition: var_struc.h:61
double ** E
specific total energy.
Definition: var_struc.h:62
double ** U
Definition: var_struc.h:63
double ** RHO
Definition: var_struc.h:63
double ** P
density, velocity components in direction x and y, pressure.
Definition: var_struc.h:63